protected void Button5_Click(object sender, EventArgs e)
    {
        if (TextBox2.Text.Trim() != "" && TextBox6.Text.Trim() != "" && TextBox3.Text.Trim() != "" && TextBox4.Text.Trim() != "" && TextBox5.Text.Trim() != "" && TextBox11.Text.Trim() != "")
        {
            if (Button5.Text == "确定修改")             //修改信息的操作
            {
                if (TextBox5.Text.Length == 18)
                {
                    if (TextBox11.Text.Length <= 16 && TextBox11.Text.Length >= 6)
                    {
                        staff sf = new DAL.StaffDAO().getStaffByNum(TextBox6.Text.Trim());
                        sf.StaffName   = TextBox3.Text.Trim();
                        sf.IdCard      = TextBox4.Text.Trim();
                        sf.PhoneNumber = TextBox5.Text.Trim();

                        SysUser s = new DAL.SysUserDAO().getUserByNum(sf.StaffNum);
                        s.Password = TextBox11.Text;
                        bool sta   = new DAL.StaffDAO().updateStaff(sf);
                        bool systa = new DAL.SysUserDAO().updateUser(s);
                        if (sta && systa)
                        {
                            new Warehouse.Tools.AddSysLog().addlog("1", "用户管理", "修改");
                            Response.Write("<script>alert('信息修改成功!')</script>");
                            add.Visible    = false;
                            update.Visible = false;
                            search.Visible = true;
                            refresh();
                            clea();
                        }
                        else
                        {
                            Response.Write("<script>alert('信息修改失败!')</script>");
                        }
                    }

                    else
                    {
                        Label27.Text = "密码要在8-16位之间";
                    }
                }
                else
                {
                    Label10.Text = "身份证号长度为18位";
                }
            }
            else                //添加用户的操作
            {
            }
        }
        else
        {
            Response.Write("<script>alert('所有信息不能为空!')</script>");
        }
    }
Beispiel #2
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     //ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>validate();</script>");
     if (TextBox1.Text.Trim() == "" || TextBox1.Text.Trim() == null)        //判断账号框是否为空,为空提示,不为空继续进行
     {
         Response.Write("<script>alert('编号不能为空!')</script>");
         //ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('编号不能为空!');", true);
         //ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>alert('编号不能为空!');</script>");
     }
     else
     {
         if (TextBox2.Text.Trim() == "" || TextBox2.Text.Trim() == null)         //判断密码框是否为空,为空提示,不为空继续进行
         {
             Response.Write("<script>alert('密码不能为空!')</script>");
         }
         else
         {
             if (input.Text.Trim() == "" || input.Text.Trim() == null)           //判断验证码框是否为空,为空提示,否则继续执行
             {
                 Response.Write("<script>alert('验证码不能为空!')</script>");
             }
             else
             {
                 if (input.Text.Trim() != Session["vcode"].ToString())
                 {
                     Response.Write("<script>alert('验证码输入错误!')</script>");
                 }
                 else
                 {
                     SysUser sys = new DAL.SysUserDAO().getUserByNum(TextBox1.Text.Trim());
                     if (sys == null)
                     {
                         Response.Write("<script>alert('用户不存在,请检查账号或密码!')</script>");
                     }
                     else
                     {
                         if (sys.Password == TextBox2.Text.Trim())               //如果密码也和账号关联的用户的密码相同就跳转网页,不同就提示
                         {
                             new Warehouse.Tools.AddSysLog().addlog("1", "登录", "登录");
                             Session.Add("UserName", sys.Staff.StaffName);
                             Session.Add("UserId", sys.UserId);
                             Response.Redirect("主页.aspx");
                         }
                         else
                         {
                             Response.Write("<script>alert('密码错误!')</script>");
                         } //end else --> password is wrong
                     }     //end else --> sys==null
                 }
             }
         } // end else --> password is null
     }     //end else --> ID is null
 }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        bool success = new DAL.SysUserDAO().deleteUserByNum(GridView1.DataKeys[e.RowIndex].Value.ToString());

        if (success)
        {
            new Warehouse.Tools.AddSysLog().addlog("1", "用户管理", "删除");
            ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除成功!');", true);
        }
        else
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败!');", true);
        }
        refresh();
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "editt")
        {
            cleartip();
            int xy = Convert.ToInt32(e.CommandArgument);

            add.Visible    = false;
            search.Visible = false;
            update.Visible = true;

            Button      btn = sender as Button;
            GridViewRow row = GridView1.Rows[xy];
            SysUser     s   = new DAL.SysUserDAO().getUserByNum(row.Cells[2].Text);

            TextBox2.Text  = s.UserId;
            TextBox6.Text  = row.Cells[2].Text;
            TextBox3.Text  = row.Cells[3].Text;
            TextBox4.Text  = row.Cells[4].Text;
            TextBox5.Text  = row.Cells[5].Text;
            TextBox11.Text = s.Password;
        }
        if (e.CommandName == "deletee")
        {
            int    x      = Convert.ToInt32(e.CommandArgument);
            string sysnum = GridView1.Rows[x].Cells[2].Text;
            bool   yy     = new DAL.SysUserDAO().deleteUserByNum(sysnum);
            if (yy)
            {
                new DAL.StaffDAO().deleteStaffByNum(sysnum);
                new Warehouse.Tools.AddSysLog().addlog("1", "用户管理", "删除");

                ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除成功!');", true);
                syss = new Warehouse.Controllor.Users_Controllor().getUsers();
                refresh();
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败!');", true);
            }
        }
    }
Beispiel #5
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "reup")
        {
            int            xy  = Convert.ToInt32(e.CommandArgument);
            Model.Position pos = new DAL.PositionDAO().getPositionByNum(GridView1.Rows[xy].Cells[1].Text);
            add.Visible    = false;
            search.Visible = false;

            Button      btn = sender as Button;
            GridViewRow row = GridView1.Rows[xy];
            SysUser     s   = new DAL.SysUserDAO().getUserByNum(row.Cells[2].Text);
        }
        else if (e.CommandName == "deletee")
        {
            int    x        = Convert.ToInt32(e.CommandArgument);
            string dataid   = GridView1.Rows[x].Cells[1].Text;
            string dataname = GridView1.Rows[x].Cells[2].Text;
            bool   yy       = new DAL.DataCopyDAO().deleteCopyById(dataid);
            if (yy)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除成功!');", true);
                try
                {
                    File.Delete(@"~/DataPackage/" + dataname + ".mdf");
                }
                catch
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败,未找到文件!');", true);
                }
                dc = new Warehouse.Controllor.DataRecovery_Controllor().getDataCopy();
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败!');", true);
            }
        }
        refresh();
    }
    protected void Button2_Click(object sender, EventArgs e)          //重置密码按钮点击事件
    {
        clea();
        Button      btn = sender as Button;
        GridViewRow row = (GridViewRow)btn.NamingContainer;

        //search.Visible = false;
        //update.Visible=true;
        num = row.Cells[1].Text;
        SysUser su = new DAL.SysUserDAO().getUserByNum(row.Cells[3].Text);

        su.Password = "******";
        bool updatesuccess = new DAL.SysUserDAO().updateUser(su);

        if (updatesuccess)
        {
            new Warehouse.Tools.AddSysLog().addlog("1", "用户管理", "修改");
            Response.Write("<script>alert('重置成功!')</script>");
        }
        else
        {
            Response.Write("<script>alert('重置失败!')</script>");
        }
    }
    protected void Button8_Click1(object sender, EventArgs e)
    {
        List <SysUser> sus = new List <SysUser> ();

        if (TextBox10.Text.Trim() != "")
        {
            SysUser su = new DAL.SysUserDAO().getUserByNum(TextBox10.Text.Trim());
            if (su != null)
            {
                sus.Add(su);
            }
        }
        else
        {
            sus = new DAL.SysUserDAO().getAllUsers();
        }
        new Warehouse.Tools.AddSysLog().addlog("1", "用户管理", "查询");
        GridView1.DataSource = sus;
        GridView1.DataBind();
        refreEmpty();
        update.Visible = false;
        add.Visible    = false;
        search.Visible = true;
    }
Beispiel #8
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     clea();
     if (TextBox2.Text.Trim() == "" || TextBox6.Text.Trim() == "" || TextBox3.Text.Trim() == "" || TextBox1.Text.Trim() == "")
     {
         Response.Write("<script>alert('所有信息不能为空!')</script>");
     }
     else
     {
         if (TextBox6.Text.Length > 16 || TextBox6.Text.Length < 6)
         {
             Label6.Text = "密码长度为6-16位";
         }
         else
         {
             if (TextBox6.Text.Trim() != TextBox3.Text.Trim())
             {
                 Label8.Text = "两次输入的密码不一致";
             }
             else
             {
                 SysUser s = new DAL.SysUserDAO().getUserByNum(TextBox2.Text.Trim());
                 if (s != null)
                 {
                     Label1.Text = "此人已注册,请更换注册员工";
                 }
                 else
                 {
                     staff sta = new DAL.StaffDAO().getStaffByNum(TextBox2.Text.Trim());
                     if (sta == null)
                     {
                         Label1.Text = "查无此人,请确定无误再输入";
                     }
                     else
                     {
                         if (sta.IdCard != TextBox1.Text.Trim())
                         {
                             Label12.Text = "您输入的身份证号和本人不符,请重新输入";
                         }
                         else
                         {
                             SysUser su = new SysUser();
                             su.Job      = DropDownList1.SelectedValue.ToString();
                             su.Password = TextBox3.Text.Trim();
                             su.StaffNum = TextBox2.Text.Trim();
                             bool addsuccess = new DAL.SysUserDAO().addUser(su);
                             if (addsuccess)
                             {
                                 ClientScript.RegisterStartupScript(GetType(), "Message", "<script>alert('注册成功');window.location='登录.aspx';</script>");
                                 //RegisterStartupScript("false", "<script>alert('注册成功');window.location.href='登录.aspx'</script>");
                             }
                             else
                             {
                                 Response.Write("<script>alert('注册失败!')</script>");
                             }
                         }
                     }
                 }
             }
         }
     }
 }
    /// <summary>
    /// 绑定下拉框的数据
    /// </summary>
    public void refredatabind()
    {
        ListItem lt1 = new ListItem();

        lt1.Value = "";
        /*        绑定供应商        */
        List <Provider> ps = new DAL.ProviderDAO().getAllProviders();

        ListBox6.DataSource     = ps;
        ListBox6.DataTextField  = "providerName";
        ListBox6.DataValueField = "providerNum";
        ListBox6.DataBind();

        ListBox6.Items.Add(lt1);
        ListBox6.SelectedValue = "";

        /*             绑定库柜        */
        List <Chest> cs = new DAL.ChestDAO().getAllChests();

        ListBox4.DataSource     = cs;
        ListBox4.DataTextField  = "chestName";
        ListBox4.DataValueField = "chestNum";
        ListBox4.DataBind();

        ListBox4.Items.Add(lt1);
        ListBox4.SelectedValue = "";

        /*                绑定经办人           */
        List <SysUser> sys = new DAL.SysUserDAO().getAllUsers();

        ListBox5.DataSource     = sys;
        ListBox5.DataTextField  = "userId";
        ListBox5.DataValueField = "staffnum";
        ListBox5.DataBind();

        ListBox5.Items.Add(lt1);
        ListBox5.SelectedValue = "";


        /*             绑定物品类别第一项        */
        List <GoodsType> gts = new DAL.GoodsTypeDAO().getParentGoodsTypes();

        ListBox1.DataSource     = gts;
        ListBox1.DataTextField  = "goodsTypeName";
        ListBox1.DataValueField = "goodsTypeNum";
        ListBox1.DataBind();

        ListBox1.Items.Add(lt1);
        ListBox1.SelectedValue = "";


        /*            绑定gridview数据源            */
        BoundField bf1 = new BoundField(); bf1.HeaderText = "序号";
        BoundField bf2 = new BoundField(); bf2.DataField = "inID"; bf2.HeaderText = "编号";
        BoundField bf3 = new BoundField(); bf3.DataField = "goods.goodsName"; bf3.HeaderText = "物品名称";
        BoundField bf4 = new BoundField(); bf4.DataField = "goods.goodsType.goodsTypeName"; bf4.HeaderText = "物品类别";
        BoundField bf5 = new BoundField(); bf5.DataField = "position.positionNum"; bf5.HeaderText = "库位编号";
        BoundField bf6 = new BoundField(); bf6.DataField = "date"; bf6.HeaderText = "入库时间";
        BoundField bf7 = new BoundField(); bf7.DataField = "inAmount"; bf7.HeaderText = "入库量";
        BoundField bf8 = new BoundField(); bf8.DataField = "batch.provider.providername"; bf8.HeaderText = "供应商";
        BoundField bf9 = new BoundField(); bf9.DataField = "sysuser.staff.staffname"; bf9.HeaderText = "经办人";

        GridView1.Columns.Add(bf1);
        GridView1.Columns.Add(bf2);
        GridView1.Columns.Add(bf3);
        GridView1.Columns.Add(bf4);
        GridView1.Columns.Add(bf5);
        GridView1.Columns.Add(bf6);
        GridView1.Columns.Add(bf7);
        GridView1.Columns.Add(bf8);
        GridView1.Columns.Add(bf9);

        BoundField bf11 = new BoundField(); bf11.HeaderText = "序号";
        BoundField bf12 = new BoundField(); bf12.DataField = "ouID"; bf12.HeaderText = "编号";
        BoundField bf13 = new BoundField(); bf13.DataField = "goods.goodsName"; bf13.HeaderText = "物品名称";
        BoundField bf14 = new BoundField(); bf14.DataField = "goods.goodsType.goodsTypeName"; bf14.HeaderText = "物品类别";
        BoundField bf15 = new BoundField(); bf15.DataField = "position.positionNum"; bf15.HeaderText = "库位编号";
        BoundField bf16 = new BoundField(); bf16.DataField = "date"; bf16.HeaderText = "出库时间";
        BoundField bf17 = new BoundField(); bf17.DataField = "outAmount"; bf17.HeaderText = "出库量";
        BoundField bf18 = new BoundField(); bf18.DataField = "batch.receiver.receivername"; bf18.HeaderText = "收货商";
        BoundField bf19 = new BoundField(); bf19.DataField = "sysuser.staff.staffname"; bf19.HeaderText = "经办人";

        GridView2.Columns.Add(bf11);
        GridView2.Columns.Add(bf12);
        GridView2.Columns.Add(bf13);
        GridView2.Columns.Add(bf14);
        GridView2.Columns.Add(bf15);
        GridView2.Columns.Add(bf16);
        GridView2.Columns.Add(bf17);
        GridView2.Columns.Add(bf18);
        GridView2.Columns.Add(bf19);
    }
 protected void Button7_Click(object sender, EventArgs e)          //确认添加
 {
     cleartip();
     if (TextBox1.Text.Trim() == "" || TextBox7.Text.Trim() == "" || TextBox8.Text.Trim() == "" || TextBox9.Text.Trim() == "")
     {
         Response.Write("<script>alert('所有信息不能为空!')</script>");
     }
     else
     {
         if (TextBox7.Text.Trim() != TextBox8.Text.Trim())
         {
             Label16.Text = "两次输入的密码不一致";
         }
         else
         {
             staff sta = new DAL.StaffDAO().getStaffByNum(TextBox1.Text.Trim());
             if (sta == null)
             {
                 Label12.Text = "查无此人,请确定无误再输入";
             }
             else
             {
                 if (TextBox9.Text.Length == 18)
                 {
                     SysUser s = new DAL.SysUserDAO().getUserByNum(TextBox1.Text.Trim());
                     if (s != null)
                     {
                         Label12.Text = "此人已注册,请更换注册员工";
                     }
                     else
                     {
                         if (sta.IdCard != TextBox9.Text.Trim())
                         {
                             Label19.Text = "您输入的身份证号和本人不符,请重新输入";
                         }
                         else
                         {
                             SysUser su = new SysUser();
                             su.Job      = DropDownList1.SelectedValue.ToString();
                             su.Password = TextBox7.Text.Trim();
                             su.StaffNum = TextBox1.Text.Trim();
                             bool addsuccess = new DAL.SysUserDAO().addUser(su);
                             if (addsuccess)
                             {
                                 new Warehouse.Tools.AddSysLog().addlog("1", "用户管理", "添加");
                                 Response.Write("<script>alert('注册成功')</script>");
                                 clea();
                                 refresh();
                                 update.Visible = false;
                                 add.Visible    = false;
                                 search.Visible = true;
                             }
                             else
                             {
                                 Response.Write("<script>alert('注册失败!')</script>");
                             }
                         }
                     }
                 }
                 else
                 {
                     Label19.Text = "身份证格式不正确";
                 }
             }
         }
     }
 }