<%@ Page Title="" Language="C#" MasterPageFile="~/KhabarMaster.master" AutoEventWireup="true" CodeFile="AddPrivateUsers.aspx.cs" Inherits="Default2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<fieldset id="Fieldset2" dir="rtl" style="width: 650px; padding-bottom: 20px;">
                    <legend dir="rtl">درج نام کاربران مجاز به مشاهده خاطره</legend>
                    <table cellpadding="0" cellspacing="0" dir="rtl" style="width: 99%">
                        <tr>
                            <td>
                                <asp:Label ID="Lbl_UserNames" runat="server" Text="انتخاب کاربران:"></asp:Label>
                            </td>
                            <td style="text-align: right">
                                <asp:DropDownList ID="Drp_UserNames" runat="server" 
                                    DataSourceID="LinqDataSourceUsers" DataTextField="UserName" 
                                    DataValueField="UerID">
                                </asp:DropDownList>
                                <asp:LinqDataSource ID="LinqDataSourceUsers" runat="server" 
                                    ContextTypeName="LSC_KhateratDataContext" EntityTypeName="" 
                                    Select="new (UerID, UserName)" TableName="Users" Where="UserName != @UserName">
                                    <WhereParameters>
                                        <asp:SessionParameter Name="UserName" SessionField="UserName" Type="String" />
                                    </WhereParameters>
                                </asp:LinqDataSource>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Drp_UserNames"
                                    ErrorMessage="نام کاربری وارد نشده است" ValidationGroup="2"></asp:RequiredFieldValidator></td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Lbl_Khaterat" runat="server" Text="خاطرات کاربر:"></asp:Label>
                            </td>
                            <td style="text-align: right">
                                <asp:DropDownList ID="Drp_Khaterat" runat="server" 
                                    DataSourceID="LinqDataSource1" DataTextField="NewsTitle" 
                                    DataValueField="NewsID">
                                </asp:DropDownList>
                                <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                                    ContextTypeName="LSC_KhateratDataContext" EntityTypeName="" 
                                    OrderBy="NewsID desc" Select="new (NewsID, NewsTitle)" TableName="tblKhaterats" 
                                    Where="UserName == @UserName &amp;&amp; KhaterehTypeID == @KhaterehTypeID">
                                    <WhereParameters>
                                        <asp:SessionParameter Name="UserName" SessionField="UserName" Type="String" />
                                        <asp:Parameter DefaultValue="2" Name="KhaterehTypeID" Type="Int32" />
                                    </WhereParameters>
                                </asp:LinqDataSource>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Drp_Khaterat"
                                    ErrorMessage="هیچ خاطره ای انتخاب نشده است" ValidationGroup="2"></asp:RequiredFieldValidator></td>
                        </tr>
                        <tr>
                            <td style="height: 24px">
                            </td>
                            <td style="height: 24px">
                                <asp:Button ID="Btn_Insert" runat="server" OnClick="Btn_Insert_Click" 
                                    Text="درج" ValidationGroup="2"
                                    Width="69px" />&nbsp;<asp:Label ID="Lbl_Err" runat="server" ForeColor="Red" Text="رکورد وارد شده تکراری است"
                                    Visible="False"></asp:Label></td>
                            <td style="height: 24px">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <asp:GridView ID="Grd_KhateratPermiss" runat="server" AllowPaging="True" 
                                    AutoGenerateColumns="False" CellPadding="4" DataKeyNames="RowID" 
                                    DataSourceID="LinqDataSource2" ForeColor="#333333" GridLines="None" 
                                    onselectedindexchanged="Grd_KhateratPermiss_SelectedIndexChanged" Width="96%">
                                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                    <Columns>
                                        <asp:CommandField HeaderText="حذف" SelectText="حذف" ShowSelectButton="True" />
                                        <asp:BoundField DataField="RowID" HeaderText="ردیف" ReadOnly="True" 
                                            SortExpression="RowID" />
                                        <asp:BoundField DataField="NewsTitle" HeaderText="عنوان خاطره" ReadOnly="True" 
                                            SortExpression="NewsTitle" />
                                        <asp:BoundField DataField="SharedFor" HeaderText="اشتراک کاربر" ReadOnly="True" 
                                            SortExpression="SharedFor" />
                                    </Columns>
                                    <EditRowStyle BackColor="#999999" />
                                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                                </asp:GridView>
                                <asp:LinqDataSource ID="LinqDataSource2" runat="server" 
                                    ContextTypeName="LSC_KhateratDataContext" EnableDelete="True" 
                                    EnableInsert="True" EnableUpdate="True" EntityTypeName="" OrderBy="RowID desc" 
                                    Select="new (RowID, NewsTitle, SharedFor)" TableName="XtblKhaterehPrivates" 
                                    Where="UserAdmName == @UserAdmName">
                                    <WhereParameters>
                                        <asp:SessionParameter Name="UserAdmName" SessionField="UserName" 
                                            Type="String" />
                                    </WhereParameters>
                                </asp:LinqDataSource>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                        </tr>
                    </table>
                </fieldset>
</asp:Content>

