private void ShowInfo(int id)
 {
     HOrgnizationBB orgnizationBB = new HOrgnizationBB();
     vHOrgnizationData model = new vHOrgnizationData();
     try
     {
         model = orgnizationBB.GetVModel(id);
         this.departNo.Text = model.departNo;
         this.departNm.Text = model.departNm;
         this.uppDepartId.Text = model.uppDepartNm;
         this.departLeader.Text = model.leaderEmpNm;
         this.isEffect.Text = model.isEffectDesc;
         this.mark.Text = model.mark;
     }
     finally
     {
         orgnizationBB.Dispose();
     }
 }
    /// <summary>
    /// ��Grid
    /// </summary>
    protected void BindGrid()
    {
        HOrgnizationBB orgnizationBB = new HOrgnizationBB();
        DataSet ds = new DataSet();

        try
        {
            ds = orgnizationBB.GetVList(this.StrWhere);
            this.grid.DataSource = ds.Tables[0];
            this.grid.DataBind();
            //��ֵ��¼������ҳ������
            this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
            this.Label2.Text = this.grid.PageCount.ToString();
            this.currPage.Text = (this.grid.PageIndex + 1).ToString();
        }
        finally
        {
            orgnizationBB.Dispose();
        }
    }
    /// <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();
        }
    }
    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;
                }
            }
        }
    }
    /// <summary>
    /// 绑定数据源
    /// </summary>
    private void BindGrid()
    {
        HOrgnizationBB deptBB = new HOrgnizationBB();
        DataSet ds = new DataSet();

        try
        {
            string strWhere = this.StrWhere;
            if (this.txtDepartNo.Text != "")
            {
                strWhere += " and departNo = '" + this.txtDepartNo.Text + "'";
            }
            if (this.txtDepartNm.Text != "")
            {
                strWhere += " and departNm like '%" + this.txtDepartNm.Text + "%'";
            }
            if (this.txtUppDepartNm.Text != "")
            {
                strWhere += " and uppDepartNm like '%" + this.txtUppDepartNm.Text + "%'";
            }
            if (this.txtDepartLeaderNm.Text != "")
            {
                strWhere += " and leaderEmpNm like '%" + this.txtDepartLeaderNm.Text + "%'";
            }
            ds = deptBB.GetVList(strWhere);

            this.grid.DataSource = ds.Tables[0];
            this.grid.DataBind();
            //赋值记录条数、页面总数
            this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
            this.Label2.Text = this.grid.PageCount.ToString();
            this.currPage.Text = (this.grid.PageIndex + 1).ToString();
        }
        finally
        {
            deptBB.Dispose();
        }
    }
示例#7
0
    /// <summary>
    /// 获取部门数据源,不走数据权限控制
    /// </summary>
    public DataSet GetDeptDs_NoPermissions()
    {
        HOrgnizationBB orgnizationBB = new HOrgnizationBB();
        DataSet ds = new DataSet();
        try
        {
            string strWhere = "isDel=0";

            ds = orgnizationBB.GetList(strWhere);
        }
        finally
        {
            orgnizationBB.Dispose();
        }
        return ds;
    }
示例#8
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>
    private void BindParentDepart()
    {
        HOrgnizationBB orgnizationBB = new HOrgnizationBB();
        DataSet ds = new DataSet();

        try
        {
            ds = orgnizationBB.GetList("isEffect=1 and isDel=0");
            DataTable dt = ds.Tables[0];

            //加载树
            this.drDepart.Items.Clear();
            this.drDepart.Items.Add(new ListItem("-请选择-", ""));
            DataRow[] drs = dt.Select("uppDepartId=0", "departNo");
            foreach (DataRow row in drs)
            {
                string departId = row["departId"].ToString();
                string text = row["departNm"].ToString();
                text = "╋" + text;
                this.drDepart.Items.Add(new ListItem(text, departId));
                int parentId = int.Parse(departId);
                string blank = "├";

                this.BindNode(parentId, dt, blank);
            }
            this.drDepart.DataBind();
        }
        finally
        {
            orgnizationBB.Dispose();
        }
    }