Esempio n. 1
0
        /// <summary>
        /// 提交请假信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            //提交请假信息
            LeaveManage lev = new LeaveManage();
            KjqbService.LeaveInService levinser = new KjqbService.LeaveInService();
            KjqbService.Service1Client ser = new KjqbService.Service1Client();
            levinser.SendUserId = leaveman.Id;
            levinser.ExamineOrExamineresult = 0;

            //对请假信息的填写状况进行判断
            if (dateTimePicker1.Value.Date.Ticks > dateTimePicker2.Value.Date.Ticks)
            {
                MessageBox.Show("请假开始时间必须早于或等于结束时间!");
                return;
            }
            if (comboBox2.Text == null || comboBox2.Text == "")
            {
                MessageBox.Show("请选择请假类型!");
                return;
            }

            if (textBox7.Text == null || textBox7.Text == "")
            {
                MessageBox.Show("请填写请假原因!");
                return;
            }

            lev.StartTime = dateTimePicker1.Value.Date.Ticks;
            lev.EndTime = dateTimePicker2.Value.Date.Ticks;

            string query = "from LeaveManage leave where leave.Ku_Id="+this.Leaveman.Id+" and ((leave.StartTime>=" + lev.StartTime + " and leave.StartTime<=" + lev.EndTime + ") or (leave.EndTime>=" + lev.StartTime + " and leave.EndTime<=" + lev.EndTime + ")) and leave.State=" + (int)LeaveManage.stateEnum.Normal;
            IList levList=baseService.loadEntityList(query);
            if(levList!=null&&levList.Count!=0)
            {
                MessageBox.Show("此时间段已有请假记录");
                return;
            }

            lev.LeaveType = comboBox2.Text.Trim();//请假类型
            lev.LeaveReason = textBox7.Text.Trim();//请假原因
               // role.KrOrder含义,0:院长,1:副院长,2:负责人,3:员工
            if (role.KrOrder == 3)//员工提交请假信息
            {
                lev.LeaveResult = "3";//审核结果,3表示未审核的
                lev.LeaveStage = "0";//审批阶段,属于未审批
                string ssql1 = "select u from WkTUser u  left join u.UserRole role where role.KrDESC='工作小秘书角色' and role.KrOrder = 2  and u.Kdid.Id = "+leaveman.Kdid.Id;
                IList list =  baseService.loadEntityList(ssql1);
                if (list != null && list.Count > 0)
                {
                    WkTUser theuser = (WkTUser)list[0];
                    levinser.UserId = theuser.Id;
                }
                else
                {
                    levinser.UserId = 0;
                }

            }
            else if (role.KrOrder == 2)//负责人提交请假
            {

                if (comboBox2.Text.Trim() == "病假" || comboBox2.Text.Trim() == "事假")
                {
                    lev.LeaveResult = "1";
                    lev.LeaveStage = "1";
                    Wktuser_M_Dept wmd = new Wktuser_M_Dept();
                    //wmd.DeptId.Id
                    string ssql1 = "select u from Wktuser_M_Dept u where u.DeptId.Id = "+leaveman.Kdid.Id;
                    IList ll = baseService.loadEntityList(ssql1);
                    if (ll != null && ll.Count > 0)
                    {
                        wmd = (Wktuser_M_Dept)ll[0];
                        levinser.UserId = wmd.WktuserId.Id;
                    }
                    else
                    {
                        levinser.UserId = 0;
                    }

                }
                else
                {   //婚假、产假、年休假、探亲假;负责人请假后,由院长直接审批就可以
                    lev.LeaveResult = "1";
                    lev.LeaveStage = "2";

                    string ssql1 = "select u from WkTUser u  left join u.UserRole role where role.KrDESC='工作小秘书角色' and role.KrOrder = 0";
                    IList list = baseService.loadEntityList(ssql1);
                    if (list != null && list.Count > 0)
                    {
                        WkTUser theuser = (WkTUser)list[0];
                        levinser.UserId = theuser.Id;
                    }
                    else
                    {
                        levinser.UserId = 0;
                    }

                }
            }
            else if (role.KrOrder == 1 || role.KrOrder == 0)//副院长和院长提交请假,都由院长审批
            {
                //默认负责人审批通过,待副院长审批
                lev.LeaveResult = "1";
                lev.LeaveStage = "2";
                string ssql1 = "select u from WkTUser u  left join u.UserRole role where role.KrDESC='工作小秘书角色' and role.KrOrder = 0";
                IList list = baseService.loadEntityList(ssql1);
                if (list != null && list.Count > 0)
                {
                    WkTUser theuser = (WkTUser)list[0];
                    levinser.UserId = theuser.Id;
                }
                else
                {
                    levinser.UserId = 0;
                }
            }

            lev.Ku_Id = leaveman;//请假人信息
            lev.LeaveChargeId = chargeman;//指定的负责人列表
            lev.State = (int)IEntity.stateEnum.Normal;
            lev.TimeStamp = DateTime.Now.Ticks;

            try
            {
                object be = baseService.saveEntity(lev);

                #region 向服务器推送消息
                levinser.LeaveId = int.Parse(be.ToString());
                ser.SaveInLeaveInfoInService(levinser);

                #endregion

            }
            catch
            {
                MessageBox.Show("保存失败!");
                return;
            }

            MessageBox.Show("保存成功!");

            comboBox2.Text = "";
            textBox7.Clear();
            chargeman.Clear();//每次用完之后清空全局变量chargeman中的数据
        }
Esempio n. 2
0
        /// <summary>
        ///  确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定修改?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                //删除原来的
                string sql = "select u from Wktuser_M_Dept u where u.WktuserId = " + userNow.Id + " and u.State = " + (int)IEntity.stateEnum.Normal;
                IList theone = baseService.loadEntityList(sql);
                if (theone != null && theone.Count > 0)
                {
                    foreach (Wktuser_M_Dept o in theone)
                    {
                        Wktuser_M_Dept oldone = o;
                        oldone.State = (int)IEntity.stateEnum.Deleted;
                        baseService.SaveOrUpdateEntity(o);
                    }
                }

                int number = this.dataGridView3.Rows.Count;
                for (int i = 0; i < number; i++)
                {
                    if ((bool)dataGridView3.Rows[i].Cells[0].EditedFormattedValue == true)
                    {
                        Wktuser_M_Dept thenew = new Wktuser_M_Dept();
                        thenew.WktuserId = userNow;
                        thenew.DeptId = (WkTDept)dataGridView3.Rows[i].Tag;
                        thenew.State = (int)IEntity.stateEnum.Normal;
                        thenew.TimeStamp = DateTime.Now.Ticks;
                        baseService.SaveOrUpdateEntity(thenew);
                    }

                }
                MessageBox.Show("设置成功!");
                string sql1 = "select u.DeptId from Wktuser_M_Dept u where u.WktuserId = " + userNow.Id + " and u.State = " + (int)IEntity.stateEnum.Normal;
                IList theone1 = baseService.loadEntityList(sql1);

                //加载数据到表2
                this.dataGridView2.Rows.Clear();
                if (theone1 != null && theone1.Count > 0)
                {
                    foreach (WkTDept o in theone1)
                    {
                        this.dataGridView2.Rows.Add(o.KdName.ToString().Trim());
                    }
                }
                this.panel3.Visible = false;
            }
        }