コード例 #1
0
ファイル: List.aspx.cs プロジェクト: sufeng136540/sufeng
        public void BindData()
        {
            #region
            //if (!Context.User.Identity.IsAuthenticated)
            //{
            //    return;
            //}
            //AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name);
            //if (user.HasPermissionID(PermId_Modify))
            //{
            //    gridView.Columns[6].Visible = true;
            //}
            //if (user.HasPermissionID(PermId_Delete))
            //{
            //    gridView.Columns[7].Visible = true;
            //}
            #endregion

            DataSet       ds       = new DataSet();
            StringBuilder strWhere = new StringBuilder();
            if (txtKeyword.Text.Trim() != "")
            {
                #warning 代码生成警告:请修改 keywordField 为需要匹配查询的真实字段名称
                //strWhere.AppendFormat("keywordField like '%{0}%'", txtKeyword.Text.Trim());
            }
            ds = bll.GetList(strWhere.ToString());
            gridView.DataSource = ds;
            gridView.DataBind();
        }
コード例 #2
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void LinkButton2_Click(object sender, EventArgs e)
 {
     try
     {
         //获取button 控件
         LinkButton lb = (LinkButton)sender;
         //获取传过来的commwntid
         int     id = Convert.ToInt32(lb.CommandArgument);
         DataSet ds = ot.GetList(" HomemadeID=" + id + "");
         if (ds.Tables[0].Rows.Count > 0)
         {
             Model.Homemadetab hom = hot.GetModel(id);
             hom.BY1 = 0;
             bool bb = hot.Update(hom);
             if (bb == true)
             {
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('停用成功!');</script>");
                 bind(sql);
             }
             else
             {
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('停用失败!');</script>");
                 bind(sql);
             }
         }
         else
         {
             bool aa = hot.Delete(id);
             if (aa == true)
             {
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('删除成功!');</script>");
                 bind(sql);
             }
             else
             {
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('删除失败!');</script>");
                 bind(sql);
             }
         }
     }
     catch (Exception ee)
     {
         //Response.Write("<script>alert('确定异常 " + ee.Message + "')</script>");
         ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('删除异常 " + ee.Message + "');</script>");
     }
 }
コード例 #3
0
 /// <summary>
 /// 添加部门(确定按钮)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ImageButton1_Click(object sender, EventArgs e)
 {
     try
     {
         if (DropDownList1.Text != "0")
         {
             if (TextBox1.Text.Trim() != "")
             {
                 if (TextBox6.Text.Trim() != "")
                 {
                     if (TextBox6.Text.Trim() == TextBox7.Text.Trim())
                     {
                         DataSet dss = op.GetList(" name like '" + TextBox1.Text + "' and pwd like '" + FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox6.Text.Trim(), "MD5") + "'");
                         if (dss.Tables[0].Rows.Count > 0)
                         {
                             ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('账号密码以存在!');</script>");
                             TextBox1.Text = "";
                             TextBox6.Text = "";
                             TextBox7.Text = "";
                             ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>");
                         }
                         else
                         {
                             Maticsoft.Model.Operator czy = new Model.Operator();
                             czy.StaffmemberID = Convert.ToInt32(DropDownList1.Text);
                             czy.name          = TextBox1.Text;
                             czy.pwd           = FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox6.Text.Trim(), "MD5");
                             czy.Beizhu        = TextBox2.Text;
                             czy.BranchID      = 1;
                             int a = op.Add(czy);
                             if (a > 0)
                             {
                                 DataSet er = op.GetList(" name like '" + TextBox1.Text + "' and pwd like '" + FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox6.Text.Trim(), "MD5") + "' and StaffmemberID like '" + DropDownList1.Text + "' and BranchID like '1'");
                                 Model.Permissionstab per = new Model.Permissionstab();
                                 per.Operatorid = Convert.ToInt32(er.Tables[0].Rows[0]["id"]);
                                 per.Look       = 0;
                                 per.Audit      = 0;
                                 int aa = pe.Add(per);
                                 if (aa > 0)
                                 {
                                     ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('添加成功!');</script>");
                                     bind(sql);
                                 }
                                 else
                                 {
                                     ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('权限添加失败!');</script>");
                                     ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>");
                                 }
                             }
                             else
                             {
                                 ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('添加失败!');</script>");
                                 bind(sql);
                             }
                         }
                     }
                     else
                     {
                         ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('2次输入的密码不一致请重新输入!');</script>");
                         TextBox6.Text = "";
                         TextBox7.Text = "";
                         ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>");
                     }
                 }
                 else
                 {
                     ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('密码不能为空!');</script>");
                     ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>");
                 }
             }
             else
             {
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('账号不能为空!');</script>");
                 ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>");
             }
         }
         else
         {
             ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('没选职员!');</script>");
             ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>");
         }
     }
     catch (Exception ee)
     {
         //Response.Write("<script>alert('确定异常 " + ee.Message + "')</script>");
         ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('确定异常 " + ee.Message + "');</script>");
     }
 }