示例#1
0
        /// <summary>
        /// process offset item
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool ProcessOffset(OffsetItem item)
        {
            OT_OFFSET offset = new OT_OFFSET();
            offset.OFFSET_ID = Guid.NewGuid().ToString();
            CheckEmployee(item.Worker_CnName, item.Worker_Number, item.Worker_Group, item.Worker_Dept);
            offset.EMP_ID = this.EmpId;
            offset.ORG_ID = this.GroupId;

            offset.OFFSET_NO = item.Offset_Number;
            if(offset.OFFSET_NO=="")offset.OFFSET_NO=SYS.getSeqNumByCode(SysSeqServiceImpl.SEQ_CODE_OFFSET);
            offset.OFFSET_REMARK = "从旧系统导入";
            if (item.Offset_Hours != "")
                offset.OFFSET_TIME = decimal.Parse(item.Offset_Hours);
            else
                offset.OFFSET_TIME = 0;
            if (item.Offset_StartEd != "")
            {
                if (item.Offset_EndTime != "")
                {
                    string strDate = item.Offset_StartEd.Substring(0, NOTIMEFORMAT.Length + 1).Trim() + " " + DateTime.FromOADate(double.Parse(item.Offset_StartTime)).ToString("h:mm tt");
                    offset.START_DATE = DateTime.ParseExact(strDate, DATEFORMAT, ZH);
                }
                else
                {
                    string strDate = item.Offset_StartEd.Substring(0, NOTIMEFORMAT.Length + 1).Trim();
                    offset.START_DATE = DateTime.ParseExact(strDate, NOTIMEFORMAT, ZH);

                }

            }
            if (item.Offset_EndEd != "")
            {
                if (item.Offset_EndTime != "")
                {
                    string strDate = item.Offset_EndEd.Substring(0, NOTIMEFORMAT.Length + 1).Trim() + " " + DateTime.FromOADate(double.Parse(item.Offset_EndTime)).ToString("h:mm tt");
                    offset.END_DATE = DateTime.ParseExact(strDate, DATEFORMAT, ZH);
                }
                else
                {
                    string strDate = item.Offset_EndEd.Substring(0, NOTIMEFORMAT.Length + 1).Trim();
                    offset.END_DATE = DateTime.ParseExact(strDate, NOTIMEFORMAT, ZH);
                }
            }
            offset.APP3_ID=CreateAPP3(item).APP3_ID;
            offset.CREATE_BY = "System";
            offset.CREATE_DATE = DateTime.ParseExact(item.OT_WorkEd.Substring(0,NOTIMEFORMAT.Length+1).Trim(), NOTIMEFORMAT, ZH);
            offset.EMP_ID = this.EmpId;
            offset.ORG_ID = this.GroupId;

            context.OT_OFFSET.Add(offset);
            context.SaveChanges();

             DateTime started = DateTime.ParseExact(item.OT_WorkEd, ONLYDATEFORMAT, ZH);

             var q = context.OT_WORK.Where(x => DateTime.Compare(x.START_DATE.Value, started) == 0).ToList()
                 .Where(x => x.EMP_ID == this.EmpId).ToList();

             OT_WORK ot_work=null;
            foreach(OT_WORK work_temp in q)
            {
                var q2=context.OT_WORK_OFFSET.Where(m=>m.WORK_ID==work_temp.WORK_ID).ToList();
                if (q2.FirstOrDefault() == null)
                    ot_work = work_temp;
            }
            ;
            if (ot_work != null)
            {
                OT_WORK_OFFSET existoffset = context.OT_WORK_OFFSET.Where(o => o.WORK_ID == ot_work.WORK_ID).FirstOrDefault();
                if(existoffset==null)
                {
                    OT_WORK_OFFSET workoffset = new OT_WORK_OFFSET();
                    workoffset.WORK_OFFSET = Guid.NewGuid().ToString();
                    workoffset.OFFSET_ID = offset.OFFSET_ID;
                    workoffset.OFFSET_HOURS = offset.OFFSET_TIME;
                    workoffset.WORK_HOURS = ot_work.HOURS;
                    workoffset.WORK_ID = ot_work.WORK_ID;
                    context.OT_WORK_OFFSET.Add(workoffset);
                    context.SaveChanges();
                }
                else
                {
                    existoffset.OFFSET_HOURS+=offset.OFFSET_TIME;
                    context.SaveChanges();
                    ExcelTool.WriteErrorOLEDB(item, "库存相同的记录,补休累加");

                }
            }
            else
            {
                OTItem ot = new OTItem();
                ot.Create_Ed = item.OT_WorkEd;
                ot.OT_StartEd = item.OT_WorkEd;
                ot.OT_StartTime = item.OT_Work_StartTime;
                ot.OT_EndEd = item.OT_WorkEd;
                ot.OT_EndTime = item.OT_Work_EndTime;

                ot.OT_Hours = item.OT_Hours;
                ot.Reason = item.OT_Work_Comment;
                ot.Compensate_Rate = item.OT_CompensateRate;

                ot.Worker_CnName = item.Worker_CnName;
                ot.Worker_Dept = item.Worker_Dept;
                ot.Worker_Group = item.Worker_Group;
                ot.Worker_Number = item.Worker_Number;

                //Comm.Logger.Info("提取加班记录入库");

               // ProcessOTItem(ot);

                Comm.Logger.Error("没有在库中找到相关的加班记录");
                ExcelTool.WriteErrorOLEDB(item, "没有相关的加班记录");

            }
            Comm.Logger.Info("Save to DB ot_offset table success.");
            return true;
        }
示例#2
0
 public bool CheckEmployeeExist(OffsetItem item)
 {
     if (!CheckEmployeeNumber(item.Worker_CnName, item.Worker_Number, item.Worker_Group, item.Worker_Dept))
         return false;
     return true;
 }
示例#3
0
        public static void WriteErrorOLEDB(OffsetItem item, string reason)
        {
            using (OleDbConnection connection = new OleDbConnection(ConnStr))
               {
               connection.Open();
               string mysql = "INSERT INTO [Sheet2$] VALUES (";

               StringBuilder sb = new StringBuilder(mysql);

               SetValueOnError(item.Worker_Group,sb);
               SetValueOnError(item.Worker_Number, sb);
               SetValueOnError(item.Worker_CnName, sb);
               SetValueOnError(item.Shift_Id, sb);

               SetValueOnError(item.OT_WorkEd, sb);
               SetValueOnError(item.OT_Work_StartTime, sb);
               SetValueOnError(item.OT_Work_EndTime, sb);

               SetValueOnError(item.OT_Work_Comment, sb);
               SetValueOnError(item.OT_Hours, sb);
               SetValueOnError(item.OT_CompensateRate, sb);

               SetValueOnError(item.Offset_Number, sb);
               SetValueOnError(item.Offset_Hours, sb);

               SetValueOnError(item.Offset_StartEd, sb);
               SetValueOnError(item.Offset_StartTime, sb);

               SetValueOnError(item.Offset_EndEd, sb);
               SetValueOnError(item.Offset_EndTime, sb);
               SetValueOnError(item.Status, sb);
               SetValueOnError(item.Offset_Hours, sb);
               SetValueOnError(item.Worker_Dept, sb);
               SetValueOnError(null, sb);
               SetValueOnError(null, sb);
               SetValueOnError(null, sb);
               sb.AppendFormat("'原{0},{1}')", item.OriginalRow,reason);

               OleDbCommand commande = new OleDbCommand(sb.ToString(), connection);

               commande.ExecuteNonQuery();

               connection.Close();
               connection.Dispose();
               }
        }
示例#4
0
 OT_APP3 CreateAPP3(OffsetItem item)
 {
     OT_APP3 app3 = new OT_APP3();
     app3.APP3_ID = Guid.NewGuid().ToString();
     app3.APP3_NO = SYS.getSeqNumByCode(ISysSeqService.SEQ_CODE_APP3);
     app3.STATUS = "0";
     if (item.Status.Equals("草稿"))
         app3.STATUS = "0";
     if (item.Status.Equals("待审"))
         app3.STATUS = "0";
     if (item.Status.Equals("已获批准"))
         app3.STATUS = "3";
     if (item.RemoveOffset_Hours != "")
         app3.OFFSET_TIME = decimal.Parse(item.RemoveOffset_Hours);
     else
         app3.OFFSET_TIME = 0;
     app3.ORG_ID = this.GroupId;
     app3.CREATE_BY = "System";
     app3.CREATE_DATE = DateTime.Now;
     app3.STATUS_FROM = "0";
     app3.APP_TYPE = "0";
     app3.CANCEL ="0";
     context.OT_APP3.Add(app3);
     context.SaveChanges();
     return app3;
 }
示例#5
0
        public static void WriteError(OffsetItem item,string reason)
        {
            ErrApp.Visible = false;

               ErrSheet = (Worksheet)ErrBook.Sheets[2];
               int lastRow = ErrSheet.Cells.SpecialCells(XlCellType.xlCellTypeLastCell).Row;
               int index = lastRow + 1;

               RowIndex = index;
               ColIndex = 1;

               SetValueOnError(item.Worker_Group);
               SetValueOnError(item.Worker_Number);
               SetValueOnError(item.Worker_CnName);
               SetValueOnError(item.Shift_Id);

               SetValueOnError(item.OT_WorkEd);
               SetValueOnError(item.OT_Work_StartTime);
               SetValueOnError(item.OT_Work_EndTime);

               SetValueOnError(item.OT_Work_Comment);
               SetValueOnError(item.OT_Hours);
               SetValueOnError(item.OT_CompensateRate);

               SetValueOnError(item.Offset_Number);
               SetValueOnError(item.Offset_Hours);

               SetValueOnError(item.Offset_StartEd);
               SetValueOnError(item.Offset_StartTime);

               SetValueOnError(item.Offset_EndEd);
               SetValueOnError(item.Offset_EndTime);
               SetValueOnError(item.Status);
               SetValueOnError(item.Offset_Hours);
               SetValueOnError(item.Worker_Dept);
               SetValueOnError(null);
               SetValueOnError(null);
               SetValueOnError(null);
               SetValueOnError(string.Format("原{0},", item.OriginalRow)+reason);
               ErrBook.Save();
        }