Exemplo n.º 1
0
        protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e)
        {
            if (check())
            {

                StaffBLL staffBLL = new StaffBLL();
                UserBLL userBLL = new UserBLL();

                string username = TextBox_username.Text.Trim();
                string name = TextBox_name.Text.Trim();
                string gender = RadioButton_male.Checked ? "男" : "女";
                string birth = DropDownList_yearPart1.SelectedValue + DropDownList_yearPart2.SelectedValue + DropDownList_yearPart3.SelectedValue + DropDownList_yearPart4.SelectedValue;
                birth += DropDownList_month.SelectedValue;
                string phone = TextBox_phone.Text.Trim();
                string type = DropDownList_type.SelectedValue;

                if (userBLL.getByUsername(username) == null)
                {
                    #region 在用户表中创建新用户
                    User user = new User();
                    user.UserName = username;
                    user.Password = EncryptUtil.MD5Encrypt("12345678");
                    user.Type = type.Equals("考勤维护员") ? "6" : "5";
                    userBLL.save(user);
                    #endregion

                    Staff staff = new Staff();
                    staff.Name = name;
                    staff.Gender = gender;
                    staff.Birth = birth;
                    staff.Phone = phone;
                    staff.Type = type;
                    staff.UserId = userBLL.getByUsername(username).Id;

                    staffBLL.save(staff);
                    Response.Write("<script>alert('添加成功!');location.href='addStaff.aspx';</script>");
                }
                else
                    Response.Write("<script>alert('添加失败,用户名已存在!');location.href='addStaff.aspx';</script>");
            }
        }
Exemplo n.º 2
0
        private void bind()
        {
            string id = Request.QueryString["id"].ToString();

            StaffBLL staffBLL = new StaffBLL();
            staff = staffBLL.get(id);

            UserBLL userBLL = new UserBLL();
            User user = userBLL.get(staff.UserId);

            TextBox_username.Text = user.UserName;
            TextBox_name.Text = staff.Name;
            if (staff.Gender.Equals("女")) RadioButton_female.Checked = true;
            PageUtil.bindDropDownList(DropDownList_yearPart1, staff.Birth[0].ToString());
            PageUtil.bindDropDownList(DropDownList_yearPart2, staff.Birth[1].ToString());
            PageUtil.bindDropDownList(DropDownList_yearPart3, staff.Birth[2].ToString());
            PageUtil.bindDropDownList(DropDownList_yearPart4, staff.Birth[3].ToString());
            PageUtil.bindDropDownList(DropDownList_month, staff.Birth.Substring(4, 2));
            TextBox_phone.Text = staff.Phone;
            PageUtil.bindDropDownList(DropDownList_type, staff.Type);
        }
Exemplo n.º 3
0
        public object getByUserId(string userId)
        {
            Staff staff = null;

            string selectSql = "SELECT * FROM t_staff WHERE userID=@userID";

            SqlParameter[] sqlParas = new SqlParameter[] { new SqlParameter("@userID", userId) };

            DataSet ds = SQLServerDBUtil.query(selectSql, sqlParas);

            if (ds.Tables[0].Rows.Count != 0)
            {
                staff = new Staff();
                staff.Id = ds.Tables[0].Rows[0][0].ToString();
                staff.Name = ds.Tables[0].Rows[0][1].ToString();
                staff.Gender = ds.Tables[0].Rows[0][2].ToString();
                staff.Birth = ds.Tables[0].Rows[0][3].ToString();
                staff.Phone = ds.Tables[0].Rows[0][4].ToString();
                staff.Type = ds.Tables[0].Rows[0][5].ToString();
                staff.UserId = ds.Tables[0].Rows[0][6].ToString();
            }

            return staff;
        }
Exemplo n.º 4
0
 /// <summary>
 /// 删除工作人员信息
 /// </summary>
 /// <param name="staff"></param>
 public void delete(Staff staff)
 {
     dal.delete(staff);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 更新工作人员信息
 /// </summary>
 /// <param name="staff"></param>
 public void update(Staff staff)
 {
     dal.update(staff);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 保存工作人员信息
 /// </summary>
 /// <param name="staff"></param>
 public void save(Staff staff)
 {
     dal.save(staff);
 }