示例#1
0
        public ActionResult NewGroupShift(int BranchID = 0)
        {
            HttpCookie myCookie = new HttpCookie("UInfo");

            myCookie = Request.Cookies["UInfo"];
            if (myCookie != null)
            {
                try {
                    objTools = new Utility();
                    DataModel.DMUsersLoginDetails DL = objTools.GetClientLoginDetails(myCookie.Value.ToString());
                    List <DMGroupShiftDetails>    ChaceGroupShift = HttpContext.Cache["ChaceGroupShift"] as List <DMGroupShiftDetails>;


                    DMGroupShiftInsert         AddNew            = new DMGroupShiftInsert();
                    List <DMNewWorkingHour>    TimeGroup         = new List <DMNewWorkingHour>();
                    List <DMGroupShiftDetails> GroupShiftDetails = new List <DMGroupShiftDetails>();
                    DMGroupShiftHeader         GroupShiftHeader  = new DMGroupShiftHeader();
                    DataTable Dt  = new DataTable();
                    Hashtable hst = new Hashtable();
                    DBA = new DBClass();

                    hst.Add("@ClientID", Convert.ToInt16(DL.ClientID));
                    hst.Add("@BranchID", Convert.ToInt16(DL.BranchID));
                    Dt        = DBA.GetDataTables("[SP_AttendanceTimeGroupToCombo]", hst);
                    TimeGroup = Dt.DataTableToList <DMNewWorkingHour>();
                    HttpContext.Cache.Insert("ChaceGroupShift", GroupShiftDetails, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 30, 0));
                    GroupShiftDetails.Add(new DMGroupShiftDetails {
                        OffDay = 0, WorkingDay = 0, WorkingHourID = 0, ID = 1
                    });
                    HttpContext.Cache.Insert("ChaceGroupShift", GroupShiftDetails, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 30, 0));
                    AddNew.TimeGroup         = TimeGroup;
                    AddNew.GroupShiftDetails = GroupShiftDetails;

                    if (BranchID == 0)
                    {
                        GroupShiftHeader.BranchName = "All Branch";
                    }
                    GroupShiftHeader.BranchID = BranchID;
                    AddNew.GroupShiftHeader   = GroupShiftHeader;
                    return(PartialView("_GroupShiftNew", AddNew));
                } catch {
                    return(PartialView("_GroupShiftNew"));
                }
            }
            else
            {
                return(RedirectPermanent("/"));
            }
        }
示例#2
0
        public ActionResult AddGroupShiftRow(DMGroupShiftInsert data, string submitButton)
        {
            HttpCookie myCookie = new HttpCookie("UInfo");

            myCookie = Request.Cookies["UInfo"];
            List <DMGroupShiftDetails> ChaceGroupShift  = HttpContext.Cache["ChaceGroupShift"] as List <DMGroupShiftDetails>;
            DMGroupShiftDetails        GroupShift       = new DMGroupShiftDetails();
            DMGroupShiftHeader         GroupShiftHeader = new DMGroupShiftHeader();
            DMGroupShiftInsert         GroupShiftInsert = new DMGroupShiftInsert();
            List <DMNewWorkingHour>    TimeGroup        = new List <DMNewWorkingHour>();

            DBA = new DBClass();

            DataTable Dt  = new DataTable();
            Hashtable hst = new Hashtable();

            if (myCookie != null)
            {
                switch (submitButton)
                {
                case "AddRow":

                    bool Addrow = false;
                    objTools = new Utility();
                    DMUsersLoginDetails DL = objTools.GetClientLoginDetails(myCookie.Value.ToString());

                    ViewBag.BranchID   = data.GroupShiftHeader.BranchID;
                    ViewBag.BranchName = data.GroupShiftHeader.BranchName;
                    hst.Add("@ClientID", Convert.ToInt16(DL.ClientID));
                    hst.Add("@BranchID", Convert.ToInt16(DL.BranchID));
                    Dt        = DBA.GetDataTables("[SP_AttendanceTimeGroupToCombo]", hst);
                    TimeGroup = Dt.DataTableToList <DMNewWorkingHour>();

                    GroupShiftInsert.TimeGroup = TimeGroup;

                    GroupShiftHeader.BranchName    = data.GroupShiftHeader.BranchName;
                    GroupShiftHeader.BranchID      = data.GroupShiftHeader.BranchID;
                    GroupShiftHeader.ClientID      = data.GroupShiftHeader.ClientID;
                    GroupShiftHeader.EffectiveDate = data.GroupShiftHeader.EffectiveDate;
                    GroupShiftHeader.ID            = data.GroupShiftHeader.ID;
                    GroupShiftHeader.ShiftName     = data.GroupShiftHeader.ShiftName;

                    foreach (DMGroupShiftDetails DI in data.GroupShiftDetails)
                    {
                        Addrow = false;
                        if (DI.ID != 0 && DI.WorkingHourID != 0)
                        {
                            Addrow = true;
                            var CI = ChaceGroupShift.FirstOrDefault(x => x.ID == DI.ID);
                            CI.WorkingHourID = DI.WorkingHourID;
                            CI.WorkingDay    = DI.WorkingDay;
                            CI.OffDay        = DI.OffDay;
                        }
                    }

                    if (Addrow == true)
                    {
                        DMGroupShiftDetails ShiftDetails = new DMGroupShiftDetails();
                        ShiftDetails.ID            = ChaceGroupShift.Count() + 1;
                        ShiftDetails.WorkingHourID = 0;
                        ShiftDetails.WorkingDay    = 0;
                        ShiftDetails.OffDay        = 0;
                        ChaceGroupShift.Add(ShiftDetails);
                    }

                    GroupShiftInsert.GroupShiftDetails = ChaceGroupShift;
                    GroupShiftInsert.GroupShiftHeader  = GroupShiftHeader;
                    HttpContext.Cache.Insert("ChaceGroupShift", ChaceGroupShift, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 30, 0));
                    return(PartialView("_GroupShiftNew", GroupShiftInsert));

                case "Save":
                    objTools = new Utility();
                    DBA      = new DBClass();
                    DMUsersLoginDetails DLD = objTools.GetClientLoginDetails(myCookie.Value.ToString());
                    hst.Clear();
                    hst.Add("@ClientID", Convert.ToInt16(DLD.ClientID));
                    hst.Add("@BranchID", Convert.ToInt16(DLD.BranchID));
                    hst.Add("@ShiftName", data.GroupShiftHeader.ShiftName);
                    hst.Add("@EfectiveDate", data.GroupShiftHeader.EffectiveDate);
                    hst.Add("@UserName", DLD.FullName);
                    string NewID = "0";
                    NewID = DBA.GetVals("[SP_AttendanceShiftGroup_Insert]", hst);
                    foreach (DMGroupShiftDetails DD in data.GroupShiftDetails)
                    {
                        hst.Clear();
                        hst.Add("@ShiftID", Convert.ToInt64(NewID));
                        hst.Add("@WorkingTimeID", DD.WorkingHourID);
                        hst.Add("@WorkingDays", DD.WorkingDay);
                        hst.Add("@OffDays", DD.OffDay);
                        DBA.ExecSP("[SP_AttendanceShiftGroupDetails_Insert]", hst);
                    }
                    return(RedirectPermanent("/Users/HR/GroupShift"));
                }
                return(View());
            }
            else
            {
                return(RedirectPermanent("/"));
            }
        }