Ejemplo n.º 1
0
        public IHttpActionResult PutShift(ShiftMaster shift)
        {
            using (var ctx = new sdirecttestdbEntities1())
            {
                var existingShift = ctx.ShiftMasters.Where(s => s.ShiftId == shift.ShiftId)
                                    .FirstOrDefault <ShiftMaster>();

                if (existingShift != null)
                {
                    existingShift.ShiftName = shift.ShiftName;
                    existingShift.StartTime = shift.StartTime;
                    existingShift.EndTime   = shift.EndTime;



                    ctx.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }

            return(Ok());
        }
Ejemplo n.º 2
0
        public ShiftMaster GetShiftMasterRecord(string recordID, string UserID)
        {
            ShiftMaster   shiftMaster = new ShiftMaster();
            SqlDataReader dr          = null;

            try
            {
                SqlParameter[] Parameters = { new SqlParameter("@SNo", recordID), new SqlParameter("@UserID", Convert.ToInt32(UserID)) };
                dr = SqlHelper.ExecuteReader(DMLConnectionString.WebConfigConnectionString, CommandType.StoredProcedure, "GetRecordShiftMaster", Parameters);
                if (dr.Read())
                {
                    shiftMaster.SNo       = Convert.ToInt32(dr["SNo"]);
                    shiftMaster.ShiftName = Convert.ToString(dr["ShiftName"]);
                    shiftMaster.TimeIn    = Convert.ToString(dr["TimeIn"]);
                    shiftMaster.TimeOut   = Convert.ToString(dr["TimeOut"]);
                    shiftMaster.NextDay   = Convert.ToBoolean(dr["NextDay"]);
                    shiftMaster.IsActive  = Convert.ToBoolean(dr["IsActive"]);
                    //shiftMaster.CreatedOn = Convert.ToString(dr["CreatedOn"]);
                    shiftMaster.CreatedBy = Convert.ToString(dr["CreatedBy"]);
                    shiftMaster.UpdatedBy = Convert.ToString(dr["UpdatedBy"]);
                    //shiftMaster.UpdatedOn = Convert.ToString(dr["UpdatedOn"]);

                    shiftMaster.Active  = Convert.ToString(dr["Active"]);
                    shiftMaster.DayNext = Convert.ToString(dr["DayNext"]);
                }
            }
            catch (Exception ex)// (Exception ex)
            {
                dr.Close();
            }
            return(shiftMaster);
        }
Ejemplo n.º 3
0
 public ActionResult AddShiftDetails(ShiftMaster SM)
 {
     if (ModelState.IsValid)
     {
         SM.Created_By = Session["LogedUserID"] as string;
         SM.Created_On = DateTime.Now;
         db.ShiftMasters.Add(SM);
         db.SaveChanges();
         return(RedirectToAction("ShiftDetails"));
     }
     return(RedirectToAction("AddShiftDetails"));
 }
Ejemplo n.º 4
0
        public string SaveShiftMaster(int shiftId, string shiftName, TimeSpan fromTime, TimeSpan toTime, Int64 mgrId)
        {
            try
            {
                int isSaved = 0;

                using (var context = new NLTDDbContext())
                {
                    var exists = context.ShiftMaster.Where(c => c.FromTime == fromTime && c.ToTime == toTime && c.ShiftID != shiftId).ToList();
                    if (exists != null && exists.Count > 0)
                    {
                        return("Shift Already Available.");
                    }
                    else
                    {
                        var objShiftMaster = context.ShiftMaster.Where(c => c.ShiftID == shiftId).SingleOrDefault();
                        if (objShiftMaster != null)
                        {
                            objShiftMaster                  = context.ShiftMaster.Where(c => c.ShiftID == shiftId).Single();
                            objShiftMaster.ShiftID          = shiftId;
                            objShiftMaster.ShiftDescription = shiftName;
                            objShiftMaster.FromTime         = fromTime;
                            objShiftMaster.ToTime           = toTime;
                        }
                        else
                        {
                            objShiftMaster = new ShiftMaster
                            {
                                ShiftDescription = shiftName,
                                FromTime         = fromTime,
                                ToTime           = toTime,
                                CreatedBy        = mgrId,
                                CreatedDate      = DateTime.Now
                            };
                        }
                        context.ShiftMaster.AddOrUpdate(objShiftMaster);
                        isSaved = context.SaveChanges();
                    }
                }

                return(isSaved > 0 ? "Saved" : "Failed");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Ejemplo n.º 5
0
        public IHttpActionResult PostShift(ShiftMaster shiftMaster)
        {
            using (var ctx = new sdirecttestdbEntities1())
            {
                ctx.ShiftMasters.Add(new ShiftMaster()
                {
                    ShiftId   = shiftMaster.ShiftId,
                    ShiftName = shiftMaster.ShiftName,
                    StartTime = shiftMaster.StartTime,
                    EndTime   = shiftMaster.EndTime
                });

                ctx.SaveChanges();
            }

            return(Ok());
        }
        public int AddShift(ShiftMaster _master, string Otype)
        {
            DALCommon dal = new DALCommon(ConStr);

            return(dal.AddShift(_master, Otype));
        }
        public ShiftMasterVM SaveShift(ShiftMasterVM Sft)
        {
            int      n;
            int      k = 0;
            string   Dst1, Dst2 = null;
            DateTime dt1, dt2;
            string   Approved;

            if (!Sft.EditFlag)
            {
                ShiftMaster pt  = new ShiftMaster();
                int         pno = _EzBusinessHelper.ExecuteScalar("Select Nos from PARTTBL001 where CmpyCode='" + Sft.CmpyCode + "' and Code='PRSFT' ");

                //pt.PRBM001_code = string.Concat("PRBM", "-", (pno + 1).ToString().PadLeft(4, '0')).ToString();
                List <ShiftAllocationH> ObjList = new List <ShiftAllocationH>();
                ObjList.AddRange(Sft.Shift.Select(m => new ShiftAllocationH
                {
                    CmpyCode      = m.CmpyCode,
                    PRSFT002_code = m.PRSFT002_code,
                    PRSFT001_code = m.PRSFT001_code,
                    Enttry_Date   = m.Enttry_Date,
                    Effect_Date   = m.Effect_Date,
                    division      = m.division,
                    ApprovalYN    = m.ApprovalYN,
                }).ToList());

                k = _EzBusinessHelper.ExecuteScalar("Select count(*) from PRSFT001 where CmpyCode='" + Sft.CmpyCode + "' and PRSFT001_code='" + Sft.PRSFT001_code + "' ");

                n = ObjList.Count;
                if (n != 0 && k == 0)
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        _EzBusinessHelper.ExecuteNonQuery("insert into PRSFT001(PRSFT001_code,CmpyCode,country,division,ShiftName,StTime,EdTime) values('" + Sft.PRSFT001_code + "','" + Sft.CmpyCode + "','" + Sft.country + "','" + Sft.division + "','" + Sft.ShiftName + "','" + Sft.StTime + "','" + Sft.EdTime + "')");

                        while (n > 0)
                        {
                            dt1  = Convert.ToDateTime(ObjList[n - 1].Enttry_Date.ToString());
                            Dst1 = dt1.ToString("yyyy-MM-dd hh:mm:ss tt");
                            dt2  = Convert.ToDateTime(ObjList[n - 1].Effect_Date.ToString());
                            Dst2 = dt2.ToString("yyyy-MM-dd hh:mm:ss tt");
                            //if (ObjList[n - 1].ApprovalYN ="YES")
                            //    Approved = "Y";
                            //else
                            //    Approved = "N";


                            _EzBusinessHelper.ExecuteNonQuery("insert into PRSFT002(PRSFT001_code,PRSFT002_code,CmpyCode,division,Enttry_Date,Effect_Date,ApprovalYN) values('" + Sft.PRSFT001_code + "','" + ObjList[n - 1].PRSFT002_code + "','" + Sft.CmpyCode + "', '" + ObjList[n - 1].division + "', '" + Dst1 + "', '" + Dst2 + "', '" + ObjList[n - 1].ApprovalYN + "')");



                            n = n - 1;
                        }
                        _EzBusinessHelper.ActivityLog(Sft.CmpyCode, Sft.UserName, "Add Shift  Master", Sft.PRSFT001_code, Environment.MachineName);
                        _EzBusinessHelper.ExecuteNonQuery("UPDATE PARTTBL001 SET Nos =" + (pno + 1) + " where CmpyCode='" + Sft.CmpyCode + "' and Code='PRSFT'");
                        Sft.SaveFlag     = true;
                        Sft.ErrorMessage = string.Empty;
                        scope.Complete();
                    }
                }
                else
                {
                    Sft.SaveFlag     = true;
                    Sft.ErrorMessage = "Duplicate Record";
                }
            }
            else
            {
                k = 0;//_EzBusinessHelper.ExecuteScalar("Select count(*) from PRSFT003 where CmpyCode='" + Sft.CmpyCode + "' and PRSFT001_code='" + Sft.PRSFT001_code + "'");
                n = _EzBusinessHelper.ExecuteScalar("Select count(*) from PRSFT001 where CmpyCode='" + Sft.CmpyCode + "' and PRSFT001_code='" + Sft.PRSFT001_code + "' ");

                if (n != 0 && k == 0)
                {
                    string DT1, DT2;

                    using (TransactionScope scope1 = new TransactionScope())
                    {
                        _EzBusinessHelper.ExecuteNonQuery("delete from PRSFT001 where CmpyCode='" + Sft.CmpyCode + "' and PRSFT001_code='" + Sft.PRSFT001_code + "'");
                        _EzBusinessHelper.ExecuteNonQuery("delete from PRSFT002 where CmpyCode='" + Sft.CmpyCode + "' and PRSFT001_code='" + Sft.PRSFT001_code + "'");

                        ShiftMaster             pt      = new ShiftMaster();
                        List <ShiftAllocationH> ObjList = new List <ShiftAllocationH>();
                        ObjList.AddRange(Sft.Shift.Select(m => new ShiftAllocationH
                        {
                            PRSFT001_code = m.PRSFT001_code,
                            PRSFT002_code = m.PRSFT002_code,
                            CmpyCode      = m.CmpyCode,
                            ApprovalYN    = m.ApprovalYN,
                            division      = m.division,
                            Effect_Date   = m.Effect_Date,
                            Enttry_Date   = m.Enttry_Date
                        }).ToList());

                        _EzBusinessHelper.ExecuteNonQuery("insert into PRSFT001(PRSFT001_code,CmpyCode,country,division,ShiftName,StTime,EdTime) values('" + Sft.PRSFT001_code + "','" + Sft.CmpyCode + "','" + Sft.country + "','" + Sft.division + "','" + Sft.ShiftName + "','" + Sft.StTime + "','" + Sft.EdTime + "')");
                        n = ObjList.Count;


                        while (n > 0)
                        {
                            dt1  = Convert.ToDateTime(ObjList[n - 1].Enttry_Date.ToString());
                            Dst1 = dt1.ToString("yyyy-MM-dd hh:mm:ss tt");
                            dt2  = Convert.ToDateTime(ObjList[n - 1].Effect_Date.ToString());
                            Dst2 = dt2.ToString("yyyy-MM-dd hh:mm:ss tt");

                            _EzBusinessHelper.ExecuteNonQuery("insert into PRSFT002(PRSFT001_code,PRSFT002_code,CmpyCode,division,Enttry_Date,Effect_Date,ApprovalYN) values('" + Sft.PRSFT001_code + "','" + ObjList[n - 1].PRSFT002_code + "','" + Sft.CmpyCode + "', '" + ObjList[n - 1].division + "', '" + Dst1 + "', '" + Dst2 + "', '" + ObjList[n - 1].ApprovalYN + "')");
                            n = n - 1;
                        }

                        _EzBusinessHelper.ActivityLog(Sft.CmpyCode, Sft.UserName, "Update Shift  Master", Sft.PRSFT001_code, Environment.MachineName);
                        Sft.SaveFlag     = true;
                        Sft.ErrorMessage = string.Empty;

                        scope1.Complete();
                    }
                }
                else
                {
                    Sft.SaveFlag     = true;
                    Sft.ErrorMessage = "Error occur";
                }
            }

            return(Sft);
        }
        /// <summary>
        /// Add and Edit Document
        /// </summary>
        /// <param name="data"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public CommonResponse AddAndEditShift(ShiftCustom data, long userId = 0)
        {
            CommonResponse obj = new CommonResponse();

            try
            {
                var res = db.ShiftMaster.Where(m => m.ShiftId == data.shiftId).FirstOrDefault();
                if (res == null)
                {
                    try
                    {
                        ShiftMaster item = new ShiftMaster();
                        item.ShiftName         = data.shiftName;
                        item.ShiftDescription  = data.shiftDescription;
                        item.ShiftStartTimings = data.shiftStartTimings;
                        item.ShiftEndTimings   = data.shiftEndTimings;
                        item.IsActive          = true;
                        item.IsDeleted         = false;
                        item.CreatedBy         = userId;
                        item.CreatedOn         = DateTime.Now;
                        db.ShiftMaster.Add(item);
                        db.SaveChanges();
                        obj.response = ResourceResponse.AddedSucessfully;
                        obj.isStatus = true;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex); if (ex.InnerException != null)
                        {
                            log.Error(ex.InnerException.ToString());
                        }
                        obj.response = ResourceResponse.ExceptionMessage;
                        obj.isStatus = false;
                    }
                }
                else
                {
                    try
                    {
                        res.ShiftName         = data.shiftName;
                        res.ShiftDescription  = data.shiftDescription;
                        res.ShiftStartTimings = data.shiftStartTimings;
                        res.ShiftEndTimings   = data.shiftEndTimings;
                        res.ModifiedBy        = userId;
                        res.ModifiedOn        = DateTime.Now;
                        db.SaveChanges();
                        obj.response = ResourceResponse.UpdatedSucessfully;
                        obj.isStatus = true;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex); if (ex.InnerException != null)
                        {
                            log.Error(ex.InnerException.ToString());
                        }
                        obj.response = ResourceResponse.ExceptionMessage;
                        obj.isStatus = false;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex); if (ex.InnerException != null)
                {
                    log.Error(ex.InnerException.ToString());
                }
                obj.response = ResourceResponse.ExceptionMessage;
                obj.isStatus = false;
            }
            return(obj);
        }