public bool UdpateDOAA1Form(FormsViewModel dOAA1ViewModel)
        {
            FormsRepository formsRepository = new FormsRepository();
            bool            isUpdate        = formsRepository.Update(dOAA1ViewModel.info);

            GetDOAA1Data(dOAA1ViewModel.info.DataCaptYM, dOAA1ViewModel.info.MenuID);
            return(isUpdate);
        }
        public bool UdpateLIBForm(FormsViewModel formsViewModel)
        {
            FormsRepository formsRepository = new FormsRepository();
            bool            isUpdate        = formsRepository.UpdateToLibInfo(formsViewModel.libInfo);

            GetDOAA1Data(formsViewModel.libInfo.DataCaptYM, formsViewModel.libInfo.MenuID);
            return(isUpdate);
        }
        public bool SaveDOAA1Form(FormsViewModel dOAA1ViewModel)
        {
            FormsRepository formsRepository = new FormsRepository();
            int             isSave          = formsRepository.Insert(dOAA1ViewModel.info);

            GetDOAA1Data(dOAA1ViewModel.info.DataCaptYM, dOAA1ViewModel.info.MenuID);
            return(isSave > 0);
        }
        public bool SaveLIBForm(FormsViewModel formsViewModel)
        {
            FormsRepository formsRepository = new FormsRepository();
            bool            isSave          = formsRepository.InsertToLibInfo(formsViewModel.libInfo);

            GetDOAA1Data(formsViewModel.libInfo.DataCaptYM, formsViewModel.libInfo.MenuID);
            return(isSave);
        }
        public bool UdpateADIRAndDOSWForm(FormsViewModel formsViewModel)
        {
            FormsRepository formsRepository = new FormsRepository();
            bool            isUpdate        = formsRepository.UpdateTostInfo2(formsViewModel.info2);

            GetDOAA1Data(formsViewModel.info2.DataCaptYM, formsViewModel.info2.MenuID);
            return(isUpdate);
        }
        public bool SaveADIRAndDOSWForm(FormsViewModel formsViewModel)
        {
            FormsRepository formsRepository = new FormsRepository();
            bool            isSave          = formsRepository.InsertTostInfo2(formsViewModel.info2);

            GetDOAA1Data(formsViewModel.info2.DataCaptYM, formsViewModel.info2.MenuID);
            return(isSave);
        }
        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);
        }
Example #8
0
        public Tuple <bool, bool?> SaveUpdateFormData(object objectData, string action, string menu, string needModificationMSG, out string msg)
        {
            msg = string.Empty;
            FormsViewModel formsViewModel = new FormsViewModel();
            int            DataCaptYM     = 0;
            string         DeptID         = string.Empty;
            bool?          IsEmailSent    = null;

            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    = FormCommonMethods.GetStatusByAction(action);
                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");
                DeptID     = info2.DeptID;
                DataCaptYM = info2.DataCaptYM;
                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    = FormCommonMethods.GetStatusByAction(action);
                info.DataUser      = SessionManager.UserName;
                info.DeptID        = string.IsNullOrEmpty(info.EmpDept) ? SessionManager.DeptID : info.EmpDept;
                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();
                DataCaptYM         = info.DataCaptYM;
                DeptID             = info.DeptID;

                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    = FormCommonMethods.GetStatusByAction(action);
                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();
                DataCaptYM            = libInfo.DataCaptYM;
                DeptID = libInfo.DeptID;

                formsViewModel.libInfo = libInfo;

                if (formsViewModel.libInfo.IDNo > 0)
                {
                    formsViewModel.isSaveSuccessfully = formsViewModel.UdpateLIBForm(formsViewModel);
                }
                else
                {
                    formsViewModel.isSaveSuccessfully = formsViewModel.SaveLIBForm(formsViewModel);
                }
            }
            else if (menu == DataAccess.Enum.Menu.DOFA.ToString())
            {
                if (objectData != null && typeof(DofaViewModel) == objectData.GetType())
                {
                    DofaViewModel dvm = (DofaViewModel)objectData;
                    DataCaptYM = dvm.DataCaptYM;
                    DeptID     = "DOFA";
                    formsViewModel.isSaveSuccessfully = dvm.SaveDOFAData(action, out msg);
                }
                else
                {
                    formsViewModel.isSaveSuccessfully = false;
                }
            }
            else if (menu == DataAccess.Enum.Menu.SRICFA.ToString())
            {
                if (objectData != null && typeof(SricFAViewModel) == objectData.GetType())
                {
                    SricFAViewModel sfvm = (SricFAViewModel)objectData;
                    DataCaptYM = sfvm.DataCaptYM;
                    DeptID     = "SRIC Agency";
                    formsViewModel.isSaveSuccessfully = sfvm.SaveSricFAData(action, out msg);
                }
                else
                {
                    formsViewModel.isSaveSuccessfully = false;
                }
            }
            else if (menu == DataAccess.Enum.Menu.SRIC.ToString())
            {
                if (objectData != null && typeof(SricDeptViewModel) == objectData.GetType())
                {
                    SricDeptViewModel sdvm = (SricDeptViewModel)objectData;
                    DataCaptYM = sdvm.DataCaptYM;
                    DeptID     = "SRIC";
                    formsViewModel.isSaveSuccessfully = sdvm.SaveSricDeptData(action, out msg);
                }
                else
                {
                    formsViewModel.isSaveSuccessfully = false;
                }
            }
            else if (menu == DataAccess.Enum.Menu.DOFAPEER.ToString())
            {
                if (objectData != null && typeof(DofaPeerViewModel) == objectData.GetType())
                {
                    DofaPeerViewModel sdvm = (DofaPeerViewModel)objectData;
                    DataCaptYM = sdvm.DataCaptYM;
                    DeptID     = "DOFA";
                    int    EmpNo   = 0;
                    string EmpName = string.Empty;

                    formsViewModel.isSaveSuccessfully = sdvm.SaveDofaPeerData(action, out msg, out EmpNo, out EmpName);

                    if (formsViewModel.isSaveSuccessfully && action.ToLower().Trim() == "save")
                    {
                        IsEmailSent = FormCommonMethods.SendEmailOnSaveForDOFAPeer(action, EmpNo, EmpName);
                    }
                }
                else
                {
                    formsViewModel.isSaveSuccessfully = false;
                }
            }
            else if (menu == DataAccess.Enum.Menu.TPDEPT.ToString())
            {
                if (objectData != null && typeof(TPDeptViewModel) == objectData.GetType())
                {
                    TPDeptViewModel sdvm = (TPDeptViewModel)objectData;
                    DataCaptYM = sdvm.DataCaptYM;
                    DeptID     = "TPDEPT";
                    formsViewModel.isSaveSuccessfully = sdvm.SaveTPDeptData(action, out msg);
                }
                else
                {
                    formsViewModel.isSaveSuccessfully = false;
                }
            }
            else if (menu == DataAccess.Enum.Menu.INFRA.ToString())
            {
                if (objectData != null && typeof(InfraViewModel) == objectData.GetType())
                {
                    InfraViewModel sdvm = (InfraViewModel)objectData;
                    DataCaptYM = sdvm.DataCaptYM;
                    DeptID     = "INFRA";
                    formsViewModel.isSaveSuccessfully = sdvm.SaveInfraData(action, out msg);
                }
                else
                {
                    formsViewModel.isSaveSuccessfully = false;
                }
            }

            else if (menu == DataAccess.Enum.Menu.DFNP.ToString())
            {
                if (objectData != null && typeof(DFNPViewModel) == objectData.GetType())
                {
                    DFNPViewModel vm = (DFNPViewModel)objectData;
                    formsViewModel.isSaveSuccessfully = vm.SaveDFNPData(action, out msg);
                }
                else
                {
                    formsViewModel.isSaveSuccessfully = false;
                }
            }

            if (formsViewModel.isSaveSuccessfully && action.ToLower().Trim() != "save")
            {
                IsEmailSent = FormCommonMethods.SendFinallizeEmail(action, DataCaptYM, DeptID, needModificationMSG);
            }

            return(new Tuple <bool, bool?>(formsViewModel.isSaveSuccessfully, IsEmailSent));
        }