コード例 #1
0
 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         objdept.ID = Convert.ToInt32(this.GridView1.DataKeys[e.RowIndex].Value);
         DataTable dtDept = dept.SelectDepartmentByID(objdept);
         employee emp = new employee();
         MEmployee objemp = new MEmployee();
         objemp.Dept = dtDept.Rows[0]["name"].ToString();
         DataTable dtEmp = emp.SelectEmployeeByDept(objemp);
         if (dtEmp.Rows.Count > 0)
         {
             string myscript = @"alert('此部门内尚有员工,不能删除!');";
             Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
         }
         else
         {
             dept.DeleteDepartmentByID(objdept);
         }
         GridView1.DataSource = dept.SelectAllDepartment();
         GridView1.DataBind();
     }
     catch (Exception ex)
     {
         this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message + "');</script>");
     }
 }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["loginName"] == null)
     {
         //Response.Write("<script>this.parent.location.href='../Default.aspx'</script>");
         Response.Redirect("~/Default.aspx");
         return;
     }
     employee emp = new employee();
     GridView1.DataSource = emp.SelectAllEmployee();
     GridView1.DataKeyNames = new String[] { "id" };
     GridView1.DataBind();
 }
コード例 #3
0
        protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
        {
            string area = Hidden1.Value;
            employee emp = new employee();
            MEmployee objemp = new MEmployee();
            objemp.Name = txtName.Text.Trim().ToString();
            objemp.Sex = dlSex.Text.ToString();
            objemp.Birthday = Convert.ToDateTime(txtBirthday.Text.Trim());
            objemp.LearnDegree = txtLearn.Text.Trim().ToString();
            objemp.Post = txtPost.Text.Trim().ToString();
            objemp.Dept = dlDepartment.Text.ToString();
            objemp.Job = dlJob.Text.ToString();
            objemp.Tel = txtTel.Text.Trim().ToString();
            objemp.Address = area + " " + txtAddress.Text.Trim().ToString();
            objemp.Email = txtEmail.Text.Trim().ToString();
            objemp.State = dlState.Text.ToString();
            objemp.PhotoPath = path;

            bool bl = emp.InsertIntoEmployee(objemp);
            if (bl)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('员工基础信息添加成功!');</script>");
            }
            else
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('员工基础信息添加失败!');</script>");
                if (IsUploadPhoto)
                {
                    try
                    {
                        FileInfo file = new FileInfo(Server.MapPath(path));
                        file.Delete();
                    }
                    catch { }
                    finally { }
                }
            }
        }
コード例 #4
0
ファイル: InfoSend.aspx.cs プロジェクト: wangchuncheng211/OAS
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         employee emp = new employee();
         chkblEmployee.DataSource = emp.SelectAllEmployee();;
         chkblEmployee.DataTextField = "name";
         chkblEmployee.DataValueField = "tel";
         chkblEmployee.DataBind();
     }
 }
コード例 #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     employee emp = new employee();
     DataList1.DataSource = emp.SelectGoodEmployee();
     DataList1.DataBind();
 }