예제 #1
0
        public void GetDofaPeerData(int _dataCaptYM)
        {
            DataCaptYM = SessionManager.DataCaptYR > 0 ? SessionManager.DataCaptYR : (_dataCaptYM > 0 ? _dataCaptYM : 0);
            DataCollectionModelDataContext db = new DataCollectionModelDataContext();

            if (DataCaptYM > 0)
            {
                DofaPeerData = db.DofaPeers.Where(a => a.DataCaptYM == DataCaptYM && a.DeptID == SessionManager.DeptID && a.MenuID == DataAccess.Enum.Menu.DOFAPEER.ToString()).ToList();
            }

            if (DofaPeerData == null || DofaPeerData.Count == 0)
            {
                DofaPeerData = new List <DofaPeer>();
                DofaPeer dofaPeer = new DofaPeer();
                dofaPeer.PeerNo = 1;
                DofaPeerData.Add(dofaPeer);
                DataStatus     = (int)DataAccess.Enum.DataStatus.DataEntryStartedbyOperator;
                DataStatusName = (DataAccess.Enum.DataStatus.DataEntryStartedbyOperator).GetStringValue();
            }
            else
            {
                DataStatus     = (int)DofaPeerData.First().DataStatus;
                DataStatusName = ((DataAccess.Enum.DataStatus)DataStatus).GetStringValue();
            }
        }
예제 #2
0
        public List <SelectListItem> GetDOFADeptDropdownData()
        {
            DataCollectionModelDataContext db          = new DataCollectionModelDataContext();
            List <SelectListItem>          DeptDDLList = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = "-- Select --", Value = ""
                }
            };

            DeptDDLList.AddRange(db.Depts.Where(w => w.DeptType == 'A').Select(i => new SelectListItem {
                Text = i.DeptName, Value = i.DeptID
            }));

            return(DeptDDLList);
        }
예제 #3
0
        public bool SaveDofaPeerData(string action, out string msg, out int empNo, out string empName)
        {
            msg = string.Empty; empNo = 0; empName = string.Empty;
            bool success = false;

            if (DofaPeerData == null || DofaPeerData.Count == 0)
            {
                return(success);
            }

            if (DofaPeerData.Any(n => n.empNo <= 0))
            {
                msg = "Employee Required";
                return(success);
            }

            DataCollectionModelDataContext db = new DataCollectionModelDataContext();
            string empNotExist = string.Empty;

            foreach (var item in DofaPeerData)
            {
                var emp = db.dofaInfos.Where(a => a.empNo == item.empNo).FirstOrDefault();
                if (emp != null)
                {
                    item.empNo         = item.empNo;
                    item.MenuID        = DataAccess.Enum.Menu.DOFAPEER.ToString();
                    item.DeptID        = SessionManager.DeptID;
                    item.DataUser      = SessionManager.UserName;
                    item.DataUpdatedOn = DateTime.Now;
                    item.DataCaptYM    = SessionManager.DataCaptYR;
                    item.DataStatus    = (short)FormCommonMethods.GetStatusByAction(action);
                    item.DataValid     = Convert.ToChar("Y");
                    item.DataLocked    = Convert.ToChar("N");
                    item.DataStatusLog = SessionManager.UserName + " " + DateTime.Now.ToString("ddd, dd MMM yyyy HH:mm:ss");
                    item.PeerRemarks   = SessionManager.UserName + " on " + DateTime.Now.ToString("ddd, dd MMM yyyy HH:mm:ss");
                    empNo   = emp.empNo;
                    empName = emp.empName;
                }
                else
                {
                    if (string.IsNullOrEmpty(empNotExist))
                    {
                        empNotExist = Convert.ToString(emp.empNo);
                    }
                    else
                    {
                        empNotExist = empNotExist + " ," + emp.empNo;
                    }
                }
            }

            if (!string.IsNullOrEmpty(empNotExist))
            {
                msg = empNotExist + "Employee Not Exist.";
                return(success);
            }

            try
            {
                FormsRepository formsRepository = new FormsRepository();
                DataTable       dt = ToDataTable(DofaPeerData);
                success = formsRepository.UpdateBulkDofaPeerFormData(dt, SessionManager.DataCaptYR, SessionManager.DeptID);
            }
            catch (Exception ex)
            {
            }
            return(success);
        }
        public bool SaveUpdateFormData(object objectData, string action, string menu)
        {
            FormsViewModel formsViewModel = new FormsViewModel();

            if (menu == DataAccess.Enum.Menu.DOSW.ToString() || menu == DataAccess.Enum.Menu.ADIR.ToString())
            {
                stInfo2 info2 = new stInfo2();
                info2 = JsonConvert.DeserializeObject <stInfo2>(objectData.ToString());

                info2.DataUpdatedOn = DateTime.Now;
                info2.DataStatus    = (int)DataAccess.Enum.DataStatus.DataEntryStartedbyOperator;
                if (action == "Finalize")
                {
                    info2.DataStatus = (int)DataAccess.Enum.DataStatus.DataEntryCompletedbyOperator;
                }
                else if (action == "FinalizedByHod")
                {
                    info2.DataStatus = (int)DataAccess.Enum.DataStatus.DataCheckingCompletedbyHOD;
                }

                info2.DataUser      = SessionManager.UserName;
                info2.DeptID        = SessionManager.DeptID;
                info2.DataValid     = "Y";
                info2.DataLocked    = "N";
                info2.DataStatusLog = SessionManager.UserName + " " + DateTime.Now.ToString("ddd, dd MMM yyyy HH:mm:ss"); //DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss tt");
                if (menu == DataAccess.Enum.Menu.ADIR.ToString())
                {
                    info2.MenuID = DataAccess.Enum.Menu.ADIR.ToString();
                }
                else
                {
                    info2.MenuID = DataAccess.Enum.Menu.DOSW.ToString();
                }

                formsViewModel.info2 = info2;

                if (formsViewModel.info2.IDNo > 0)
                {
                    formsViewModel.isSaveSuccessfully = formsViewModel.UdpateADIRAndDOSWForm(formsViewModel);
                }
                else
                {
                    formsViewModel.isSaveSuccessfully = formsViewModel.SaveADIRAndDOSWForm(formsViewModel);
                }
            }
            else if (menu == DataAccess.Enum.Menu.DOAA.ToString())
            {
                stInfo info = new stInfo();
                info = JsonConvert.DeserializeObject <stInfo>(objectData.ToString());

                info.DataUpdatedOn = DateTime.Now;
                info.DataStatus    = (int)DataAccess.Enum.DataStatus.DataEntryStartedbyOperator;
                if (action == "Finalize")
                {
                    info.DataStatus = (int)DataAccess.Enum.DataStatus.DataEntryCompletedbyOperator;
                }
                else if (action == "FinalizedByHod")
                {
                    info.DataStatus = (int)DataAccess.Enum.DataStatus.DataCheckingCompletedbyHOD;
                }

                info.DataUser      = SessionManager.UserName;
                info.DeptID        = SessionManager.DeptID;
                info.DataValid     = "Y";
                info.DataLocked    = "N";
                info.DataStatusLog = SessionManager.UserName + " " + DateTime.Now.ToString("ddd, dd MMM yyyy HH:mm:ss");
                info.MenuID        = DataAccess.Enum.Menu.DOAA.ToString();


                formsViewModel.info = info;

                if (formsViewModel.info.IDNo > 0)
                {
                    formsViewModel.isSaveSuccessfully = formsViewModel.UdpateDOAA1Form(formsViewModel);
                }
                else
                {
                    formsViewModel.isSaveSuccessfully = formsViewModel.SaveDOAA1Form(formsViewModel);
                }
            }
            else if (menu == DataAccess.Enum.Menu.LIBFORM.ToString())
            {
                LibInfo libInfo = new LibInfo();
                libInfo = JsonConvert.DeserializeObject <LibInfo>(objectData.ToString());

                libInfo.DataUpdatedOn = DateTime.Now;
                libInfo.DataStatus    = (int)DataAccess.Enum.DataStatus.DataEntryStartedbyOperator;
                if (action == "Finalize")
                {
                    libInfo.DataStatus = (int)DataAccess.Enum.DataStatus.DataEntryCompletedbyOperator;
                }
                else if (action == "FinalizedByHod")
                {
                    libInfo.DataStatus = (int)DataAccess.Enum.DataStatus.DataCheckingCompletedbyHOD;
                }

                libInfo.DataUser      = SessionManager.UserName;
                libInfo.DeptID        = SessionManager.DeptID;
                libInfo.DataValid     = "Y";
                libInfo.DataLocked    = "N";
                libInfo.DataStatusLog = SessionManager.UserName + " " + DateTime.Now.ToString("ddd, dd MMM yyyy HH:mm:ss");
                libInfo.MenuID        = DataAccess.Enum.Menu.LIBFORM.ToString();

                formsViewModel.libInfo = libInfo;

                if (formsViewModel.libInfo.IDNo > 0)
                {
                    formsViewModel.isSaveSuccessfully = formsViewModel.UdpateLIBForm(formsViewModel);
                }
                else
                {
                    formsViewModel.isSaveSuccessfully = formsViewModel.SaveLIBForm(formsViewModel);
                }
            }

            if (formsViewModel.isSaveSuccessfully && action == "Finalize")
            {
                try
                {
                    string body = "The User: "******", Dept: " + SessionManager.DeptID + " , DataCapt: " + info.DataCaptYM + ", IRD Data has been finalised & sent for your Authorization.  Kindly Check & Authorize/Approve the data."
                                  + "Time Stamp: DateTime Stamp: " + DateTime.Now
                                  + "This is a System generated Email.";

                    string subject = "IRD Data Entry updated by " + SessionManager.UserName;

                    DataCollectionModelDataContext db = new DataCollectionModelDataContext();
                    var    hod    = db.RankUsers.Where(a => a.DeptID.ToLower() == SessionManager.DeptID.ToLower() && a.UserRole.ToLower() == UserRoles.User.ToString().ToLower() && a.UserWork.ToLower() == DataAccess.Enum.UserWork.HOD.ToString().ToLower()).FirstOrDefault();
                    string tomail = "*****@*****.**";
                    if (hod != null)
                    {
                        tomail = hod.UserEmail;
                    }

                    FormServices formServices = new FormServices();
                    formServices.SendEmail(tomail, "", subject, body);
                }
                catch (Exception ex) { }
            }

            return(formsViewModel.isSaveSuccessfully);
        }