Exemple #1
0
        ///// <summary>
        ///// 生成用户权限表格
        ///// </summary>
        ///// <param name="UserID">用户代码ID</param>
        //private void FillRightTable(string GroupID)
        //{
        //    GroupAuthorization clsGroup = new GroupAuthorization();
        //    String[,] strProgram = clsGroup.ShowGroupRightInPrograms(ViewState["GroupID"].ToString());
        //    if (strProgram != null)
        //    {
        //        //生成表体部分
        //        int j = 0;
        //        CheckBoxList cblTmp;
        //        while (strProgram[j, 0] != null && strProgram[j, 0] != String.Empty)
        //        {
        //            cblTmp = (CheckBoxList)FindControl("cbl" + strProgram[j, 0]);

        //            //判断是否有权限,如果没有,则CheckBox为“未选”状态。
        //            if (strProgram[j, 2] != null && strProgram[j, 2] != "")
        //            {
        //                if (strProgram[j, 2].IndexOf('r') != -1)
        //                    cblTmp.Items[0].Selected = true;

        //                if (strProgram[j, 2].IndexOf('m') != -1)
        //                    cblTmp.Items[1].Selected = true;

        //                if (strProgram[j, 2].IndexOf('a') != -1)
        //                    cblTmp.Items[2].Selected = true;

        //                if (strProgram[j, 2].IndexOf('d') != -1)
        //                    cblTmp.Items[3].Selected = true;
        //            }
        //            j++;
        //        }
        //    }
        //}
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (this.ddlCity.SelectedIndex == 0)
                {
                    Common.ShowMsg("请选择所在市!");
                    return;
                }
                if (this.ddlDistrict.SelectedIndex == 0)
                {
                    Common.ShowMsg("请选择所在县!");
                    return;
                }
                if (this.ddlProvince.SelectedIndex == 0)
                {
                    Common.ShowMsg("请选择所在省!");
                    return;
                }
                DBManager db  = DBManager.Instance();
                string    sql = "select * from Mem where Identitycard = '" + this.txtIdentitycard.Text.Trim() + "' and memid <> '" + this.txtMemId.Text.Trim() + "'";
                DataTable dt  = new DataTable();
                dt = db.GetDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    Common.ShowMsg("身份证号已存在!请修改!");
                    return;
                }


                //创建用户数据表操作类对象
                Member mem = new Member();


                if (ViewState["OperateStatus"].ToString() == "AddData")
                {
                    string memid    = this.txtMemId.Text.Trim();
                    string memname  = this.txtMemName.Text.Trim();
                    string cardid   = this.txtCardID.Text.Trim();
                    string pwd      = this.txtPwd.Text.Trim();
                    string sex      = this.ddlSex.Items.Count > 0?ddlSex.SelectedItem.Value : "";
                    string levelid  = this.ddlMemLevelID.Items.Count > 0 ? ddlMemLevelID.SelectedItem.Value : "";
                    string tel      = this.txtTel.Text.Trim();
                    string mobile   = this.txtMobi.Text.Trim();
                    string birthday = this.txtBirthday.Text.Trim();
                    string age      = this.txtAge.Text.Trim();
                    string job      = this.txtJob.Text.Trim();

                    string   Identitycard  = this.txtIdentitycard.Text.Trim();
                    string   OpeningBank   = this.txtOpeningBank.Text.Trim();
                    string   AccountNumber = this.txtAccountNumber.Text.Trim();
                    string   AccountName   = this.txtAccountName.Text.Trim();
                    string   Province      = this.ddlProvince.SelectedItem.Value;
                    string   City          = this.ddlCity.SelectedItem.Value;
                    string   District      = this.ddlDistrict.SelectedItem.Value;
                    int      status        = ddlStatus.SelectedIndex;
                    string   addr          = this.txtAddr.Text.Trim();
                    int      account       = 0;
                    int      jifen         = 0;
                    DateTime createdate    = DateTime.Now;
                    string   father        = Session["UserID"].ToString();
                    //增加用户数据
                    db  = DBManager.Instance();
                    sql = "select * from Mem where memid = '" + memid + "'";
                    dt  = new DataTable();
                    dt  = db.GetDataTable(sql);
                    if (dt.Rows.Count > 0)
                    {
                        Common.ShowMsg("此用户ID已存在!添加会员失败!");
                        return;
                    }
                    sql = "select * from Mem_card where CardId = '" + cardid + "'";
                    dt  = db.GetDataTable(sql);
                    if (dt.Rows.Count > 0)
                    {
                        Common.ShowMsg("此会员卡号已存在!添加会员失败!");
                        return;
                    }

                    if (mem.AddMember(memid, memname, cardid, sex, age, job, tel, mobile, createdate, birthday, status, addr, Identitycard, OpeningBank, AccountNumber, AccountName,
                                      Province, City, District, father))
                    {
                        mem.AddMemCard(cardid, pwd, levelid, status);
                        Common.ShowMsg("添加成功!");
                        //记录操作员操作
                        RecordOperate.SaveRecord(Session["UserID"].ToString(), "会员管理", "增加会员;卡号:" + cardid);
                    }
                    else
                    {
                        return;
                    }
                }

                if (ViewState["OperateStatus"].ToString() == "EditData")
                {
                    string memid   = this.txtMemId.Text.Trim();
                    string memname = this.txtMemName.Text.Trim();

                    string sex = this.ddlSex.SelectedItem.Value;

                    string tel           = this.txtTel.Text.Trim();
                    string mobile        = this.txtMobi.Text.Trim();
                    string birthday      = this.txtBirthday.Text;
                    string addr          = this.txtAddr.Text.Trim();
                    string age           = this.txtAge.Text.Trim();
                    string job           = this.txtJob.Text.Trim();
                    string Identitycard  = this.txtIdentitycard.Text.Trim();
                    string OpeningBank   = this.txtOpeningBank.Text.Trim();
                    string AccountNumber = this.txtAccountNumber.Text.Trim();
                    string AccountName   = this.txtAccountName.Text.Trim();
                    string Province      = this.ddlProvince.SelectedItem.Value;
                    string City          = this.ddlCity.SelectedItem.Value;
                    string District      = this.ddlDistrict.SelectedItem.Value;

                    string cardid  = this.txtCardID.Text.Trim();
                    string pwd     = this.txtPwd.Text.Trim();
                    string levelid = this.ddlMemLevelID.Items.Count > 0 ? ddlMemLevelID.SelectedItem.Value : "";


                    MemberDB memdb;
                    int      status = -1;
                    memdb = mem.FindMemByMemId(Request.QueryString["MemID"]);
                    if (this.ddlStatus.SelectedIndex.ToString() == "0")
                    {
                        status = 0;
                    }
                    else if (this.ddlStatus.SelectedIndex.ToString() == "1")
                    {
                        status = 1;
                    }
                    try
                    {
                        //更新用户数据

                        if (mem.UpdateMember(memid, memname, cardid, sex, age, job, tel, mobile, birthday, addr, Identitycard, OpeningBank, AccountNumber, AccountName, Province, City, District, status))
                        {
                            mem.UpdateMemCard(cardid, pwd, levelid, status);
                            Common.ShowMsg("更新成功!");
                            //记录操作员操作
                            RecordOperate.SaveRecord(Session["UserID"].ToString(), "会员管理", "更新会员信息;卡号:" + cardid);
                        }
                        else
                        {
                            return;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            Server.Transfer("MemManager_View.aspx?AgentID=" + this.txtAgent.Text);
        }