protected void btnAdd_Click(object sender, EventArgs e)
    {
        HOrgnizationData model = new HOrgnizationData();
        HOrgnizationBB orgnizationBB = new HOrgnizationBB();
        try
        {
            if (this.State == "1")
            {
                this.SetModel(ref model);
                model.departNo = "";
                model.isrtDt = DateTime.Now.ToString();
                model.isrtEmpId = this.currentUser.empId;
                model.isDel = false;
                this.IdValue = orgnizationBB.AddRecord(model);
            }
            else if (this.State == "2")
            {
                model = orgnizationBB.GetModel(this.IdValue);
                this.SetModel(ref model);
                model.updtDt = DateTime.Now.ToString();
                model.updtEmpId = this.currentUser.empId;
                orgnizationBB.ModifyRecord(model);
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            orgnizationBB.Dispose();
        }

        Response.Redirect("HOrgnizationList.aspx?itemNo=" + this.itemNo + "&pTypeNo=main", false);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                this.IdValue = Convert.ToInt32(Request.Params["id"]);
            }
            if (Request.Params["state"] != null && Request.Params["state"].Trim() != string.Empty)
            {
                this.State = Request.Params["state"].ToString();
                switch (this.State)
                {
                    case "1":   //add
                        break;
                    case "2":   //update
                        //���ؿؼ�
                        HOrgnizationBB orgnizationBB = new HOrgnizationBB();
                        HOrgnizationData orgnizationData = new HOrgnizationData();
                        try
                        {
                            orgnizationData = orgnizationBB.GetModel(this.IdValue);

                            this.ShowInfo(this.IdValue);
                        }
                        finally
                        {
                            orgnizationBB.Dispose();
                        }
                        break;
                    default:
                        break;
                }
            }
        }
    }
Beispiel #3
0
 /// <summary>
 /// 获得当前部门
 /// </summary>
 /// <returns></returns>
 public HOrgnizationData GetCurrentDept()
 {
     HOrgnizationData departData = null;
     if (this.currentUser.nowDepartId != 0)
     {
         int departId = this.currentUser.nowDepartId;
         HOrgnizationBB departBB = new HOrgnizationBB();
         try
         {
             departData = departBB.GetModel(departId);
         }
         finally
         {
             departBB.Dispose();
         }
     }
     if (null == departData)
     {
         departData = new HOrgnizationData();
     }
     return departData;
 }
    /// <summary>
    /// ɾ��
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        HOrgnizationBB orgnizationBB = new HOrgnizationBB();
        try
        {
            //��ȡѡ�е�����Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    retChecked = true;
                    int id = int.Parse(chkId.ValidationGroup);
                    HOrgnizationData orgnizationData = new HOrgnizationData();
                    orgnizationData = orgnizationBB.GetModel(id);

                    orgnizationData.isDel = true;
                    orgnizationBB.ModifyRecord(orgnizationData);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            orgnizationBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }