Esempio n. 1
0
        public bool SaveDOFAData(string action, out string msg)
        {
            msg = string.Empty;
            bool success = false;

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

            if (DofaData.Any(n => n.empNo <= 0 || string.IsNullOrWhiteSpace(n.empName) || string.IsNullOrWhiteSpace(n.empDEPT)))
            {
                msg = "Minimum EmpNo, Name, Dept should not be blank";
                return(success);
            }

            if (DofaData.GroupBy(n => n.empNo).Any(c => c.Count() > 1))
            {
                msg = "Duplicate EmpNo Exist.! Data saving aborted.";
                return(success);
            }


            foreach (var item in DofaData)
            {
                item.MenuID        = DataAccess.Enum.Menu.DOFA.ToString();
                item.DeptID        = SessionManager.DeptID;
                item.DataUser      = SessionManager.UserName;
                item.DataUpdatedOn = DateTime.Now;
                item.DataCaptYM    = SessionManager.DataCaptYR;
                item.DataStatus    = FormCommonMethods.GetStatusByAction(action);
                item.DataValid     = "Y";
                item.DataLocked    = "N";
                item.DataStatusLog = SessionManager.UserName + " " + DateTime.Now.ToString("ddd, dd MMM yyyy HH:mm:ss");
            }

            try
            {
                FormsRepository formsRepository = new FormsRepository();
                DataTable       dt = ToDataTable(DofaData);
                success = formsRepository.UpdateBulkDOFAFormData(dt, SessionManager.DataCaptYR, SessionManager.DeptID, EmpDept);
            }
            catch (Exception ex)
            {
            }
            return(success);
        }