示例#1
0
文件: DALShift.cs 项目: khwwas/SCMS
        public int SaveShift(SETUP_Shift newSetupShift)
        {
            try
            {
                SCMSDataContext dbSCMS = Connection.Create();
                SETUP_Shift existingSetupShift = dbSCMS.SETUP_Shifts.Where(c => c.Shft_Id.Equals(newSetupShift.Shft_Id)).SingleOrDefault();
                if (existingSetupShift != null)
                {
                    existingSetupShift.Shft_Title = newSetupShift.Shft_Title;
                    existingSetupShift.Shft_Abbreviation = newSetupShift.Shft_Abbreviation;
                    existingSetupShift.Shft_Active = newSetupShift.Shft_Active;
                    existingSetupShift.Shft_SortOrder = newSetupShift.Shft_SortOrder;
                    existingSetupShift.Shft_StartTime = newSetupShift.Shft_StartTime;
                    existingSetupShift.Shft_EndTime = newSetupShift.Shft_EndTime;
                    existingSetupShift.Shift_BreakStartTime = newSetupShift.Shift_BreakStartTime;
                    existingSetupShift.Shift_BreakEndTime = newSetupShift.Shift_BreakEndTime;
                    existingSetupShift.Shift_BreakDuration = newSetupShift.Shift_BreakDuration;
                    existingSetupShift.Shift_GraceIn = newSetupShift.Shift_GraceIn;
                    existingSetupShift.Shift_GraceEarly = newSetupShift.Shift_GraceEarly;

                }
                else
                {
                    dbSCMS.SETUP_Shifts.InsertOnSubmit(newSetupShift);
                }
                dbSCMS.SubmitChanges();
                return Convert.ToInt32(newSetupShift.Shft_Id);
            }
            catch
            {
                return 0;
            }
        }
示例#2
0
        public ActionResult SaveRecord(String Code, String Title, String Abbreviation, DateTime StartTime, DateTime EndTime,DateTime BreakStartTime,DateTime BreakEndTime,DateTime BreakDuration,String GraceIn,String GraceEarly)
        {
            Int32 li_ReturnValue = 0;

            try
            {
                SETUP_Shift row_Shift = new SETUP_Shift();

                if (String.IsNullOrEmpty(Code))
                {
                    if (DALCommon.AutoCodeGeneration("SETUP_Shift") == 1)
                    {
                        Code = DALCommon.GetMaximumCode("SETUP_Shift");
                    }
                }

                if (!String.IsNullOrEmpty(Code))
                {
                    row_Shift.Shft_Id = Code;
                    row_Shift.Shft_Code = Code;
                    row_Shift.Shft_Title = Title;
                    row_Shift.Shft_Abbreviation = Abbreviation;
                    row_Shift.Shft_Active=1;
                    row_Shift.Shft_SortOrder=1;
                    row_Shift.Shft_StartTime = StartTime;
                    row_Shift.Shft_EndTime = EndTime;
                    row_Shift.Shift_BreakStartTime = BreakStartTime;
                    row_Shift.Shift_BreakEndTime = BreakEndTime;
                    row_Shift.Shift_BreakDuration = BreakDuration;
                    row_Shift.Shift_GraceIn = GraceIn;
                    row_Shift.Shift_GraceEarly = GraceEarly;
                    li_ReturnValue = objDalShift.SaveShift(row_Shift);
                    ViewData["SaveResult"] = li_ReturnValue;
                }

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }