Пример #1
0
        public void OperationInfo(CE_OperatorMode mode, Business_Project_Timesheets timesheets)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            switch (mode)
            {
            case CE_OperatorMode.添加:

                timesheets.RecordDate      = ServerTime.Time;
                timesheets.RecordPersonnel = BasicInfo.LoginID;

                ctx.Business_Project_Timesheets.InsertOnSubmit(timesheets);
                break;

            case CE_OperatorMode.除:

                var varData = from a in ctx.Business_Project_Timesheets
                              where a.ID == timesheets.ID
                              select a;

                ctx.Business_Project_Timesheets.DeleteAllOnSubmit(varData);
                break;

            default:
                break;
            }

            ctx.SubmitChanges();
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (customDataGridView1.CurrentRow == null)
                {
                    return;
                }

                if (!GlobalObject.GeneralFunction.IsInSameWeek(Convert.ToDateTime(customDataGridView1.CurrentRow.Cells["项目工作日期"].Value), ServerTime.Time))
                {
                    MessageDialog.ShowPromptMessage("不能【删除】,【项目工作日期】与当前日期不在同一周的记录");
                    return;
                }

                Business_Project_Timesheets timesheets = new Business_Project_Timesheets();

                timesheets.ID = Convert.ToInt32(customDataGridView1.CurrentRow.Cells["序号"].Value);
                if (MessageDialog.ShowEnquiryMessage("是否要【删除】您当前选中的记录?") == DialogResult.Yes)
                {
                    _ServiceTimesheets.OperationInfo(CE_OperatorMode.除, timesheets);
                    MessageDialog.ShowPromptMessage("删除成功");
                    ClearInfo();
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
            }

            customDataGridView1.DataSource = _ServiceTimesheets.GetInfo(BasicInfo.LoginID);
        }
        Business_Project_Timesheets GetInfo()
        {
            Business_Project_Timesheets result = new Business_Project_Timesheets();

            result.ElapsedTime     = numElapsedTime.Value;
            result.ItemDescription = txtDescription.Text;
            result.ItemName        = cmbItemName.Text;
            result.ItemDate        = dtpItemDate.Value.Date;
            result.RecordPersonnel = BasicInfo.LoginID;
            result.RecordDate      = ServerTime.Time;
            result.ExecUser        = txtExecUser.Tag.ToString();

            return(result);
        }
Пример #4
0
        public bool IsOverTime(Business_Project_Timesheets timesheets)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            var varData = from a in ctx.Business_Project_Timesheets
                          where a.ExecUser == timesheets.ExecUser &&
                          a.ItemDate == timesheets.ItemDate
                          select a;

            if (varData.Count() > 0 && varData.Sum(k => k.ElapsedTime) + timesheets.ElapsedTime > 24)
            {
                return(true);
            }

            return(false);
        }
Пример #5
0
        public bool IsRepeat(Business_Project_Timesheets timesheets)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            var varData = from a in ctx.Business_Project_Timesheets
                          where a.ExecUser == timesheets.ExecUser &&
                          a.ItemName == timesheets.ItemName &&
                          a.ItemDate == timesheets.ItemDate
                          select a;

            if (varData.Count() > 0)
            {
                return(true);
            }

            return(false);
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckInfo())
                {
                    return;
                }

                Business_Project_Timesheets timesheets = GetInfo();

                if (_ServiceTimesheets.IsOverTime(timesheets))
                {
                    MessageDialog.ShowPromptMessage("【项目工作日期】累计【项目工时】超过24小时");
                    return;
                }

                if (_ServiceTimesheets.IsRepeat(timesheets))
                {
                    MessageDialog.ShowPromptMessage("【项目工作日期】已存在一条【" + timesheets.ItemName + "】记录");
                    return;
                }

                if (MessageDialog.ShowEnquiryMessage("请确认您填写的信息是否【提交】?") == DialogResult.Yes)
                {
                    _ServiceTimesheets.OperationInfo(CE_OperatorMode.添加, timesheets);
                    MessageDialog.ShowPromptMessage("提交成功");
                    ClearInfo();
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
            }

            customDataGridView1.DataSource = _ServiceTimesheets.GetInfo(BasicInfo.LoginID);
        }