예제 #1
0
        private void listBoxPro_SelectedIndexChanged(object sender, EventArgs e)
        {
            EPRelationBll eprBll = new EPRelationBll();
            EmployeeBll   empBll = new EmployeeBll();

            lblProName.Text = listBoxPro.SelectedItem.ToString();
            listBoxEmp.Items.Clear();
            listBoxOtherEmp.Items.Clear();

            //显示PL,PM
            var pro = eprBll.QueryProByName(listBoxPro.SelectedItem.ToString());

            lblPL.Text = pro.PLId + "   " + empBll.QueryById(pro.PLId).Name;
            lblPM.Text = pro.PMId + "   " + empBll.QueryById(pro.PMId).Name;

            var proEmp   = eprBll.QueryProEmp(listBoxPro.SelectedItem.ToString());
            var otherEmp = eprBll.QueryOtherEmp(listBoxPro.SelectedItem.ToString());


            if (proEmp.Count != 0)
            {
                foreach (var item in proEmp)
                {
                    listBoxEmp.Items.Add(item.Id + "   " + item.Name);//项目员工
                }
            }

            if (otherEmp.Count != 0)
            {
                foreach (var item in otherEmp)
                {
                    listBoxOtherEmp.Items.Add(item.Id + "   " + item.Name);//其他员工
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 更新关系表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            EPRelationBll     eprBll  = new EPRelationBll();
            List <EPRelation> eprList = new List <EPRelation>();

            eprList.Clear();
            int count = listBoxEmp.Items.Count;

            if (count != 0)
            {
                for (int i = 0; i < count; i++)
                {
                    EPRelation epr = new EPRelation();
                    epr.ProjectName = listBoxPro.SelectedItem.ToString();
                    epr.EmployeeId  = listBoxEmp.Items[i].ToString().Split(' ')[0];
                    epr.CreateDate  = DateTime.Now.ToString();
                    eprList.Add(epr);
                }
                bool b = eprBll.AddAfterDeleteInfo(eprList);
                if (b)
                {
                    MessageBox.Show("成功");
                }
                else
                {
                    MessageBox.Show("失败");
                }
            }
        }
예제 #3
0
        private void FrmOvertimeAddOrUpdate_Load(object sender, EventArgs e)
        {
            EmployeeBll empBll = new EmployeeBll();
            ProjectBll  proBll = new ProjectBll();

            myTxtEmpId.SetText(this.Tag.ToString());//加载员工Id
            string name = empBll.QueryById(this.Tag.ToString()).Name;

            myTxtEmpName.SetText(name);                     //加载员工姓名
            myTxtReason.SetText("工作需要");                    //默认原因
            TimePickerFrom.Value = DateTime.Parse("19:00"); //默认开始时间
            TimePickerTo.Value   = DateTime.Parse("21:00"); //默认结束时间

            if (this.Text == "添加信息")
            {
                #region  加载该员工项目.显示到listbox中
                string empId = myTxtEmpId.GetText().ToUpper().Trim();
                if (empId == string.Empty)
                {
                    return;
                }
                listBoxShow.Items.Clear();

                ProjectBll    pBll = new ProjectBll();
                EPRelationBll eBll = new EPRelationBll();
                List <string> need = new List <string>();
                List <string> have = new List <string>();
                need.Clear();

                //一个员工id,他可能的项目 包括他负责的项目和他从属的项目

                //从项目表中查询.负责的项目.因为关系表中每个项目没有包涵PM pl
                var pros = pBll.QueryWhenEmpIdLike(empId);
                if (pros.Count != 0)
                {
                    foreach (var item in pros)
                    {
                        need.Add(item);
                    }
                }

                //从关系表中查询.从属的项目
                var epr = eBll.QueryLikeThis(empId);
                if (epr.Count != 0)
                {
                    foreach (var item in epr)
                    {
                        have.Add(item);
                    }
                }
                need = need.Union(have).ToList();
                if (need.Count != 0)
                {
                    if (need.Count == 1)
                    {
                        myTxtProName.SetText(need[0]);
                        myTxtProName.Enabled = false;
                        EmployeeBll emBll  = new EmployeeBll();
                        ProjectBll  prBll  = new ProjectBll();
                        string      pl     = prBll.QueryByName(myTxtProName.GetText())[0].PLId;
                        string      plName = emBll.QueryById(pl).Name;
                        myTxtProPLName.SetText(plName);//加载项目Pl

                        return;
                    }
                    listBoxShow.Visible = true;
                    foreach (var item in need)
                    {
                        listBoxShow.Items.Add(item);
                    }
                }

                #endregion
            }
            else if (this.Text == "更新信息")
            {
                myTxtProName.SetText(thisProName);
                ProjectBll  pb     = new ProjectBll();
                EmployeeBll eb     = new EmployeeBll();
                string      plid   = pb.QueryByName(thisProName)[0].PLId;
                string      plname = eb.QueryById(plid).Name;
                myTxtProPLName.SetText(plname);
                dateTime.Value = DateTime.Parse(thisDate);
            }

            //使时间选择器值显示时间不显示日期
            TimePickerFrom.Format       = DateTimePickerFormat.Custom;
            TimePickerFrom.CustomFormat = "HH':'mm";


            TimePickerTo.Format       = DateTimePickerFormat.Custom;
            TimePickerTo.CustomFormat = "HH':'mm";
        }
예제 #4
0
        //点击用户控件文本框时发生,文本框显示项目名
        private void myTxtProName_Enter(object sender, EventArgs e)
        {
            myTxtProPLName.Clear();

            #region  加载该员工项目.显示到listbox中
            string empId = myTxtEmpId.GetText().ToUpper().Trim();
            if (empId == string.Empty)
            {
                return;
            }
            listBoxShow.Items.Clear();

            ProjectBll    pBll = new ProjectBll();
            EPRelationBll eBll = new EPRelationBll();
            List <string> need = new List <string>();
            List <string> have = new List <string>();
            need.Clear();

            //一个员工id,他可能的项目 包括他负责的项目和他从属的项目

            //从项目表中查询.负责的项目.因为关系表中每个项目没有包涵PM pl
            var pros = pBll.QueryWhenEmpIdLike(empId);
            if (pros != null)
            {
                foreach (var item in pros)
                {
                    need.Add(item);
                }
            }

            //从关系表中查询.从属的项目
            var epr = eBll.QueryLikeThis(empId);
            if (epr != null)
            {
                foreach (var item in epr)
                {
                    have.Add(item);
                }
            }
            need = need.Union(have).ToList();
            if (need != null)
            {
                if (need.Count == 1)//如果只有一个项目
                {
                    myTxtProName.SetText(need[0]);
                    myTxtProName.Enabled = false;
                    EmployeeBll emBll  = new EmployeeBll();
                    ProjectBll  prBll  = new ProjectBll();
                    string      pl     = prBll.QueryByName(myTxtProName.GetText())[0].PLId;
                    string      plName = emBll.QueryById(pl).Name;
                    myTxtProPLName.SetText(plName);//加载项目Pl

                    return;
                }
                listBoxShow.Visible = true;
                foreach (var item in need)
                {
                    listBoxShow.Items.Add(item);
                }
            }
            else
            {
                MessageBox.Show("您未参与任何项目");
                return;
            }
            #endregion
        }