TelPhoneFun.aspx

/******************** TelPhoneFun.aspx ********************/

<asp:GridView ID="gvwTelPhoneFun" runat="server" AutoGenerateColumns="False" 
        CssClass="tbGvw" Width="100%" onrowcommand="gvwTelPhoneFun_RowCommand">
        <Columns>
            <asp:BoundField DataField="phonefun_key" HeaderText="phonefun_key" HeaderStyle-CssClass="dn" ItemStyle-CssClass="dn"></asp:BoundField>
            <asp:BoundField DataField="zt_flg" HeaderText="zt_flg" HeaderStyle-CssClass="dn" ItemStyle-CssClass="dn"></asp:BoundField>
            <asp:TemplateField HeaderText="序号" HeaderStyle-Width="50px">
                <ItemTemplate>
                     <%# gvwTelPhoneFun.Rows.Count + 1%>   
                </ItemTemplate>                            
            </asp:TemplateField>
            <asp:TemplateField HeaderText="电话功能服务项">
                <ItemTemplate>
                    <asp:TextBox ID="txtPhonefunName" runat="server" Text='<%# Bind("phonefun_name") %>' CssClass="Underline"  Width="300px"></asp:TextBox>                                
                </ItemTemplate>                           
            </asp:TemplateField>
            <asp:TemplateField HeaderText="备 注">
                <ItemTemplate>
                    <asp:TextBox ID="txtBz" runat="server" Text='<%# Bind("bz") %>' CssClass="Underline"  Width="300px"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="状 态">
                    <ItemTemplate>
                        <asp:DropDownList ID="ddlZtFlg" runat="server">
                            <asp:ListItem Value="1">可用</asp:ListItem>
                            <asp:ListItem Value="0">不可用</asp:ListItem>
                        </asp:DropDownList>
                    </ItemTemplate>                            
                </asp:TemplateField>
            <asp:TemplateField HeaderText="操作" ItemStyle-Width="50px">
                <ItemTemplate>
                    <asp:ImageButton ID="imeBtOK" runat="server" CommandName="BtOK" CommandArgument='<%# gvwTelPhoneFun.Rows.Count %>'
                        ImageUrl="../images/ico_save.gif" ToolTip="保存" OnClientClick="if(!window.confirm('确定要保存吗?'))return false;else return true;"/>
                </ItemTemplate>
            </asp:TemplateField>
            
        </Columns>
    </asp:GridView>
    <script type="text/javascript">
        $(function(){
            $("#aspnetForm").submit(function(){
            if($("input[id$='txtPhonefunName']").val()==""){ alert("请填写功能名称"); $("input[id$='txtPhonefunName']").focus(); return false; }
            });
        });
    </script>

/******************** TelPhoneFun.aspx.cs ********************/

        LRMO.DAL.Telephone.phone telPhone = new LRMO.DAL.Telephone.phone(); 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }
        //绑定电话功能服务项列表
        private void BindData()
        {
            gvwTelPhoneFun.DataSource = telPhone.Get_PhoneFun();
            gvwTelPhoneFun.DataBind();
            for (int i = 0; i < gvwTelPhoneFun.Rows.Count; i++)
            {
                DropDownList ddlZtFlg = (DropDownList)gvwTelPhoneFun.Rows[i].FindControl("ddlZtFlg");
                ddlZtFlg.SelectedIndex = -1;
                try
                {
                    ddlZtFlg.Items.FindByValue(gvwTelPhoneFun.Rows[i].Cells[1].Text.Trim()).Selected = true;
                }
                catch
                {
                    ddlZtFlg.SelectedIndex = -1;
                }
            }
        }
        //操作
        protected void gvwTelPhoneFun_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int i = int.Parse(e.CommandArgument.ToString());
            int phonefun_key = int.Parse(gvwTelPhoneFun.Rows[i].Cells[0].Text);
            if (e.CommandName == "BtOK")
            {
                TextBox txtPhonefunName = (TextBox)gvwTelPhoneFun.Rows[i].FindControl("txtPhonefunName");
                TextBox txtBz = (TextBox)gvwTelPhoneFun.Rows[i].FindControl("txtBz");
                DropDownList ddlZtFlg = (DropDownList)gvwTelPhoneFun.Rows[i].FindControl("ddlZtFlg");
                if (txtPhonefunName.Text.Trim() == "")
                {
                    UI.Alert(this, "电话功能服务项不能为空!");
                    return;
                }
                if (telPhone.Maint_PhoneFunByID(phonefun_key,txtPhonefunName.Text,txtBz.Text,Convert.ToInt32(ddlZtFlg.SelectedValue))>0)
                {
                    UI.Alert(this, "操作成功!");
                }
                else
                {
                    UI.Alert(this, "操作失败!");
                    return;
                }
            }
            BindData();
        } 

/******************** phone.cs ********************/

        /// <summary>
        /// 获取使用电话所开通的功能信息
        /// </summary>
        /// <param name="zt_flg"></param>
        /// <returns></returns>
        public DataSet Get_PhoneFun()
        {
            string StrSql = "SELECT phonefun_key,phonefun_name,bz,zt_flg FROM tel_phone_fun"
                + " UNION ALL"
                + " SELECT 9999 AS phonefun_key,'' AS phonefun_name,'' AS bz,1 AS zt_flg"
                + " ORDER BY phonefun_key ";
            Database db = DatabaseFactory.CreateDatabase();
            return db.ExecuteDataSet(CommandType.Text, StrSql);
        } 

 

posted @ 2014-08-18 11:42  linyongqin  阅读(250)  评论(0编辑  收藏  举报