AddEmployee.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:9k
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using com.etong.DAL.FC;
- public partial class AddEmployee : System.Web.UI.Page
- {
- protected int iEmpID;
- protected string sEmpID,sModify;
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- Response.Buffer = true;
- Response.ExpiresAbsolute = System.DateTime.Now;
- Response.Expires = 0;
- Response.CacheControl = "no-cache";
- ImageButton2.Attributes.Add("onclick", "javascript:if(confirm('确定要退出吗?')) {window.close();return;} else {return;}");
- EtongFlyChou EFly = new EtongFlyChou();
- sEmpID = Request.QueryString["StrValue"].ToString();
- sModify = Request.QueryString["StrM"].ToString();
- //sEmpID = sEmpID.Substring(2, sEmpID.Length - 2);
- iEmpID = Convert.ToInt32(sEmpID);
- string sParent="";
- if (sModify == "M")
- {
- sParent = EFly.GetEmpParentOrgID(sEmpID);
- }
- else
- {
- sParent = sEmpID;
- }
- string StrOrgPath = "";
- if (sParent.Trim() != "" && sParent != null)
- {
- StrOrgPath = EFly.GetAddressName(sParent);
- }
- TxtOrgName.Text = StrOrgPath;
- Page.Title = "新增职工信息";
- LabTitle.Text = "新增职工信息";
- EtongFlyChouWFPrj EFlyPrj = new EtongFlyChouWFPrj();
- DataView dv1 = new DataView();
- try
- {
- dv1 = EFlyPrj.GetAllOpRole();
- ChList.DataTextField = "OpName";
- ChList.DataValueField = "OpID";
- ChList.DataSource = dv1;
- ChList.DataBind();
- dv1 = EFly.GetAllEmp();
- DLstParent.DataTextField = "EmpName";
- DLstParent.DataValueField = "EmpID";
- DLstParent.DataSource = dv1;
- DLstParent.DataBind();
- this.DLstParent.Items.Insert(0, new ListItem("----请选择----", "-1"));
- dv1 = EFly.GetEmpType();
- DListType.DataTextField = "name";
- DListType.DataValueField = "id";
- DListType.DataSource = dv1;
- DListType.DataBind();
- }
- catch (Exception ex)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
- return;
- }
-
-
- //项目修改
- if (sModify == "M")
- {
- Page.Title = "职工信息修改";
- LabTitle.Text = "职工信息修改";
- DataView dv = new DataView();
- dv = EFly.GetEmp(sEmpID);
- TxtName.Text = dv.Table.Rows[0][1].ToString();
- DListType.Items.FindByValue(DListType.SelectedValue).Selected = false;
- string DLValue;
- //if (Convert.ToInt32(dv.Table.Rows[0][3].ToString()) > 4 || Convert.ToInt32(dv.Table.Rows[0][3].ToString()) < 1)
- // DLValue = "4";
- //else
- DLValue = dv.Table.Rows[0][3].ToString();
- try
- {
- DListType.Items.FindByValue(DLValue).Selected = true;
- }
- catch
- {
- }
- TxtEmail.Text = dv.Table.Rows[0][4].ToString();
- TxtPNum.Text = dv.Table.Rows[0][5].ToString();
- if (dv.Table.Rows[0][7].ToString().Trim() == "1")
- {
- CheckEmp.Checked = true;
- }
- else
- {
- CheckEmp.Checked = false;
- }
- DLstParent.Items.FindByValue(DLstParent.SelectedValue).Selected=false;
- try
- {
- DLstParent.Items.FindByValue(dv.Table.Rows[0]["ParentEmp"].ToString()).Selected = true;
- }
- catch
- {
- }
- EFlyPrj.EmpID = iEmpID;
- try
- {
- dv = EFlyPrj.GetAssignOpRole();
- for (int i = 0; i < dv.Table.Rows.Count; i++)
- {
- for (int j = 0; j < ChList.Items.Count; j++)
- {
- if (ChList.Items[j].Value.ToString().Trim() == dv.Table.Rows[i]["OpID"].ToString().Trim())
- {
- ChList.Items[j].Selected = true;
- break;
- }
- }
- }
- }
- catch (Exception ex)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
- return;
- }
- }
- //bool bFlag = true;
- //bFlag = EFly.HomonymyCheck(TxtName.Text);
- //if (bFlag == false)
- //{
- // ImageButton1.Attributes.Add("onclick", "javascript:return confirm('确定要删除此记录吗?');");
- //}
- }
- }
- protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
- {
- string StrName, StrEmail, StrOrgID, PhoneNum;
- int iTmpFlag =0,iType=4;
- //bool bFlag= true;
- EtongFlyChou EFly = new EtongFlyChou();
- StrOrgID = Request.QueryString["StrValue"];
- sModify = Request.QueryString["StrM"].ToString();
- sEmpID = Request.QueryString["StrValue"].ToString();
- iEmpID = Convert.ToInt32(sEmpID);
- StrName = TxtName.Text;
- StrEmail = TxtEmail.Text;
- PhoneNum = TxtPNum.Text;
- try
- {
- iType = Convert.ToInt32(DListType.SelectedValue.ToString());
- }
- catch
- {
- iType = 4;
- }
- //bFlag = EFly.HomonymyCheck(StrName);
- //if (bFlag == false)
- //{
- //// ImageButton1.Attributes.Add("onclick","javascript:return confirm('确定要删除此记录吗?');");
- //// //string strjavascript = "function ShowMessage() { if(confirm('您确定删除吗?')) return false;}";
- //// ////Page.ClientScript.RegisterStartupScript(this.GetType(), "onclick", strjavascript);
- //// //ClientScript.RegisterStartupScript(this.GetType(), "onclick", strjavascript, true);
- //// //if(confirm('您确定删除吗?')){}else {return false;}
- //// //javascript:return confirm('确定要删除此记录吗?');
- //}
-
- if (CheckEmp.Checked)
- {
- iTmpFlag = 1;
- }
- else
- {
- iTmpFlag = 0;
- }
- int iPEmpID = -1;
- try
- {
- iPEmpID = Convert.ToInt32(DLstParent.SelectedValue);
- }
- catch
- {
- iPEmpID = -1;
- }
- ArrayList al = new ArrayList();
- foreach (ListItem Lst in this.ChList.Items)
- {
- if (Lst.Selected == true) al.Add(Lst.Value);
- }
- if (sModify == "M")
- {
- if (EFly.UpEmp(iEmpID, StrName, PhoneNum, StrEmail, iTmpFlag,iType,al,iPEmpID) == true)
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:保存成功!');", true);
- }
- else
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:保存失败!');", true);
- }
-
- }
- else
- {
- if (EFly.AddEmpData(StrName, sEmpID, StrEmail, PhoneNum, iTmpFlag,iType,al,iPEmpID) == true)
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:保存成功!');", true);
- }
- else
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:保存失败!');", true);
- }
-
- }
- }
- }