Пример #1
0
        public ActionResult MAS070()
        {
            MAS070_ScreenParameter MAS070Param = new MAS070_ScreenParameter();

            ViewBag.HasPermissionAdd    = "";
            ViewBag.HasPermissionEdit   = "";
            ViewBag.HasPermissionDelete = "";
            try
            {
                MAS070Param = GetScreenObject <MAS070_ScreenParameter>();
                ViewBag.HasPermissionAdd    = CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_USER_INFO, FunctionID.C_FUNC_ID_ADD);
                ViewBag.HasPermissionEdit   = CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_USER_INFO, FunctionID.C_FUNC_ID_EDIT);
                ViewBag.HasPermissionDelete = CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_USER_INFO, FunctionID.C_FUNC_ID_DEL);
            }
            catch
            {
            }


            ICommonHandler cHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

            emailSuffix         = cHand.GetSystemStatusValue(ConfigName.C_EMAIL_SUFFIX);
            ViewBag.EmailSuffix = emailSuffix;
            ViewBag.EmailLength = C_EMAIL_LENGTH - emailSuffix.Length;

            IEmployeeMasterHandler handler      = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
            List <string>          positionCode = handler.GetPositionCodeAtMaxPositionLevel();

            if (positionCode != null && positionCode.Count != 0)
            {
                ViewBag.DefaultPositionCode = positionCode[0].Trim();
            }

            return(View());
        }
Пример #2
0
        /// <summary>
        /// Get active name of Employee data
        /// </summary>
        /// <param name="empNo"></param>
        /// <returns></returns>
        public ActionResult GetActiveEmployeeName(string empNo)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                if (empNo != null)
                {
                    IEmployeeMasterHandler handler = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;

                    List <tbm_Employee> empLst = new List <tbm_Employee>();
                    empLst.Add(new tbm_Employee()
                    {
                        EmpNo = empNo
                    });
                    List <doActiveEmployeeList> lst = handler.GetActiveEmployeeList(empLst);
                    if (lst.Count > 0)
                    {
                        res.ResultData = lst[0].EmpFullName;
                    }
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Пример #3
0
        public ActionResult GetPersonInChargeFirstElementAllCombo(string filter)
        {
            filter = filter == "" ? null : filter;
            try
            {
                List <dtBelongingEmpNo> result = new List <dtBelongingEmpNo>();
                string strDisplayName          = "EmpValueCode";
                try
                {
                    if (filter != null)
                    {
                        IEmployeeMasterHandler handler = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                        result = handler.GetBelongingEmpNoByOffice(filter);
                        CommonUtil.MappingObjectLanguage <dtBelongingEmpNo>(result);
                    }
                }
                catch
                {
                    result = new List <dtBelongingEmpNo>();
                }

                ComboBoxModel cboModel = new ComboBoxModel();
                cboModel.SetList <dtBelongingEmpNo>(result, strDisplayName, "EmpNo", true, CommonUtil.eFirstElementType.All);

                return(Json(cboModel));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        private SupportStaff getStaff(string EmpNo, bool IsNeedMainBelonging)
        {
            IEmployeeMasterHandler EmpHand   = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
            List <tbm_Employee>    lstEmp    = new List <tbm_Employee>();
            List <doBelongingData> belonging = new List <doBelongingData>();
            SupportStaff           SupStff   = new SupportStaff();

            SupStff.EmpFullName = "";
            lstEmp = EmpHand.GetActiveEmployee(EmpNo);
            if (lstEmp.Count > 0)
            {
                if (IsNeedMainBelonging)
                {
                    belonging = EmpHand.GetMainBelongingByEmpNo(EmpNo);
                    if (belonging.Count > 0)
                    {
                        SupStff.BelongingOfficeDepart = belonging[0].BelongingOfficeDepart;
                    }
                }
                SupStff.EmpFullName = lstEmp[0].EmpFullName;

                return(SupStff);
            }

            return(SupStff);
        }
Пример #5
0
        /// <summary>
        /// Generate belonging office combobox
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="id"></param>
        /// <param name="attribute"></param>
        /// <param name="empNo"></param>
        /// <returns></returns>
        public static MvcHtmlString BelongingOfficeComboBox(this HtmlHelper helper, string id, object attribute = null, string empNo = null)
        {
            //IEmployeeMasterHandler emphandler = ServiceContainer.GetService<IEmployeeMasterHandler>() as IEmployeeMasterHandler;

            //var officeLst = emphandler.GetBelongingOfficeList(null);
            //CommonUtil.MappingObjectLanguage<dtBelongingOffice>(officeLst);

            //return CommonUtil.CommonComboBox<dtBelongingOffice>(id, officeLst
            //    , "OfficeCodeName"
            //    , "OfficeCode", attribute, true);

            List <dtBelongingOffice> lst    = new List <dtBelongingOffice>();
            List <dtBelongingOffice> vw_lst = new List <dtBelongingOffice>();

            try
            {
                IEmployeeMasterHandler handle = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                lst = handle.GetBelongingOfficeList(empNo);

                // Select language
                vw_lst = CommonUtil.ConvertObjectbyLanguage <dtBelongingOffice, dtBelongingOffice>(lst, "OfficeCodeName");

                vw_lst = (from p in vw_lst orderby p.OfficeCodeName ascending select p).ToList <dtBelongingOffice>();
            }
            catch
            {
                lst = new List <dtBelongingOffice>();
            }

            return(CommonUtil.CommonComboBox <dtBelongingOffice>(id, vw_lst, "OfficeCodeName", "OfficeCode", attribute));
        }
        /// <summary>
        /// Get project purchaser data
        /// </summary>
        /// <param name="strProjectCode"></param>
        /// <returns></returns>
        public ActionResult CTS260_GetProjectPurchaser(string strProjectCode)
        {
            IProjectHandler projh = ServiceContainer.GetService <IProjectHandler>() as IProjectHandler;
            List <dtTbt_ProjectPurchaserCustomerForView> lstPurchaser = new List <dtTbt_ProjectPurchaserCustomerForView>();

            lstPurchaser = projh.GetTbt_ProjectPurchaserCustomerForView(strProjectCode);
            if (lstPurchaser.Count > 0)
            {
                if (!CommonUtil.IsNullOrEmpty(lstPurchaser[0].CustCode))
                {
                    ICustomerMasterHandler icustMast = ServiceContainer.GetService <ICustomerMasterHandler>() as ICustomerMasterHandler;
                    List <doCustomer>      lstCust   = icustMast.GetCustomer(lstPurchaser[0].CustCode);

                    lstPurchaser = CommonUtil.ClonsObjectList <doCustomer, dtTbt_ProjectPurchaserCustomerForView>(lstCust);
                }
            }


            EmployeeMappingList emlst = new EmployeeMappingList();

            emlst.AddEmployee(lstPurchaser.ToArray());
            IEmployeeMasterHandler Emph = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;

            Emph.EmployeeListMapping(emlst);
            CommonUtil.MappingObjectLanguage <dtTbt_ProjectPurchaserCustomerForView>(lstPurchaser);

            MiscTypeMappingList miscMapList = new MiscTypeMappingList();

            miscMapList.AddMiscType(lstPurchaser.ToArray());
            ICommonHandler comh = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

            comh.MiscTypeMappingList(miscMapList);
            return(Json(lstPurchaser));
        }
        /// <summary>
        /// Get project data for view
        /// </summary>
        /// <param name="strProjectCode"></param>
        /// <returns></returns>
        public ActionResult CTS260_GetProjectForView(string strProjectCode)
        {
            ObjectResultData res = new ObjectResultData();

            if (CommonUtil.IsNullOrEmpty(strProjectCode))
            {
                res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, "CTS260",
                                    MessageUtil.MODULE_COMMON,
                                    MessageUtil.MessageList.MSG0007,
                                    new string[] { "lblProjectCode" },
                                    new string[] { "ProjectCode" });
                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                return(Json(res));
            }

            IProjectHandler      Projh      = ServiceContainer.GetService <IProjectHandler>() as IProjectHandler;
            List <doTbt_Project> lstProject = Projh.GetTbt_ProjectForView(strProjectCode);

            if (lstProject.Count <= 0)
            {
                res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0091,
                                    new string[] { strProjectCode },
                                    new string[] { "ProjectCode" });
                return(Json(res));
            }
            else
            {
                //CommonUtil.dsTransData.dtCommonSearch.ProjectCode = strProjectCode;
                CommonUtil comUtil = new CommonUtil();

                //CommonUtil.dsTransData.dtCommonSearch.ProjectCode = comUtil.ConvertProjectCode(lstProject[0].ProjectCode,CommonUtil.CONVERT_TYPE.TO_SHORT);
                //CommonUtil.dsTransData.dtCommonSearch.ContractCode = null;
                CTS260_ScreenParameter param = GetScreenObject <CTS260_ScreenParameter>();
                param.CommonSearch = new ScreenParameter.CommonSearchDo()
                {
                    ProjectCode = comUtil.ConvertProjectCode(lstProject[0].ProjectCode, CommonUtil.CONVERT_TYPE.TO_SHORT)
                };
            }
            EmployeeMappingList emlst = new EmployeeMappingList();

            emlst.AddEmployee(lstProject.ToArray());
            IEmployeeMasterHandler Emph = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;

            Emph.EmployeeListMapping(emlst);

            MiscTypeMappingList miscMapList = new MiscTypeMappingList();

            miscMapList.AddMiscType(lstProject.ToArray());
            ICommonHandler comh = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

            comh.MiscTypeMappingList(miscMapList);

            return(Json(lstProject));
        }
        /// <summary>
        /// Get support staff for view
        /// </summary>
        /// <param name="strProjectCode"></param>
        /// <returns></returns>
        public ActionResult CTS260_GetSupportStaffForView(string strProjectCode)
        {
            ObjectResultData res   = new ObjectResultData();
            IProjectHandler  Projh = ServiceContainer.GetService <IProjectHandler>() as IProjectHandler;

            List <dtTbt_ProjectSupportStaffDetailForView> lstStaff = Projh.GetTbt_ProjectSupportStaffDetailForView(strProjectCode);
            EmployeeMappingList emlst = new EmployeeMappingList();

            emlst.AddEmployee(lstStaff.ToArray());
            IEmployeeMasterHandler Emph = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;

            Emph.EmployeeListMapping(emlst);
            string result = CommonUtil.ConvertToXml <dtTbt_ProjectSupportStaffDetailForView>(lstStaff, "contract\\CTS260_support", CommonUtil.GRID_EMPTY_TYPE.VIEW);

            return(Json(result));
        }
Пример #9
0
 /// <summary>
 /// Get all tables of project stockout memo for view
 /// </summary>
 /// <param name="projectCode"></param>
 /// <returns></returns>
 public List <tbt_ProjectStockOutMemo> GetTbt_ProjectStockoutMemoForView(string projectCode)
 {
     try
     {
         List <tbt_ProjectStockOutMemo> lst   = base.GetTbt_ProjectStockoutMemoForView(projectCode);
         EmployeeMappingList            emlst = new EmployeeMappingList();
         emlst.AddEmployee(lst.ToArray());
         IEmployeeMasterHandler Emph = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
         Emph.EmployeeListMapping(emlst);
         return(lst);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ActionResult CTS230_SupportStaffCheck(string EmpNo)
        {
            IEmployeeMasterHandler EmpHand = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
            List <tbm_Employee>    lstEmp  = new List <tbm_Employee>();

            lstEmp = EmpHand.GetActiveEmployee(EmpNo);
            if (lstEmp.Count > 0)
            {
                List <doBelongingData> belonging = EmpHand.GetMainBelongingByEmpNo(EmpNo);
            }
            else
            {
                return(Json(""));
            }

            return(Json(""));
        }
Пример #11
0
        /// <summary>
        /// Refresh user data of dsTrans object
        /// </summary>
        /// <param name="dsTrans"></param>
        /// <param name="EmpNo"></param>
        public void RefreshUserData(dsTransDataModel dsTrans, string EmpNo)
        {
            try
            {
                dsTrans.dtUserData = null;

                IEmployeeMasterHandler handEmp = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                List <dtEmployeeData>  dtEmp   = handEmp.GetUserData(EmpNo);
                if (dtEmp.Count > 0)
                {
                    dsTrans.dtUserData = CommonUtil.CloneObject <dtEmployeeData, UserDataDo>(dtEmp[0]);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #12
0
        /// <summary>
        /// Logical delete employee.<br />
        /// - Check system suspending.<br />
        /// - Set delete flag and update database.
        /// </summary>
        /// <param name="employee"></param>
        /// <returns></returns>
        public ActionResult MAS070_DeleteEmployee(tbm_Employee employee)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                res = checkSystemSuspending();
                if (res.IsError)
                {
                    return(Json(res));
                }

                MAS070_ScreenParameter MAS070Param = GetScreenObject <MAS070_ScreenParameter>();
                employee.UpdateDate = MAS070Param.updateDate;

                IEmployeeMasterHandler hand = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                List <tbm_Employee>    list = hand.DeleteEmployee(employee);

                if (list == null || list.Count == 0)
                {
                    return(Json(res));
                }

                doTransactionLog logData = new doTransactionLog()
                {
                    TransactionType = doTransactionLog.eTransactionType.Update,
                    TableName       = TableName.C_TBL_NAME_EMPLOYEE,
                    TableData       = CommonUtil.ConvertToXml(list)
                };
                ILogHandler loghand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                loghand.WriteTransactionLog(logData);

                string xml = CommonUtil.ConvertToXml <tbm_Employee>(list);
                res.ResultData = xml;
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.ResultData = "NP";
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Пример #13
0
        private String getEmployeeDisplayName(string GroupEmpNo)
        {
            String empDisplayName = String.Empty;

            try
            {
                IEmployeeMasterHandler employeeHandler = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                List <dtEmpNo>         dtEmpNo         = employeeHandler.GetEmployeeNameByEmpNo(GroupEmpNo);
                if (dtEmpNo.Count > 0)
                {
                    empDisplayName = dtEmpNo[0].EmployeeNameDisplay;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(empDisplayName);
        }
Пример #14
0
        /// <summary>
        /// Get all tables of project for view
        /// </summary>
        /// <param name="strProjectCode"></param>
        /// <returns></returns>
        public List <doTbt_Project> GetTbt_ProjectForView(string strProjectCode)
        {
            List <tbt_Project>   lstTbt_Project = base.GetTbt_ProjectForViewSQL(strProjectCode);
            List <doTbt_Project> doTbt_Project  = CommonUtil.ClonsObjectList <tbt_Project, doTbt_Project>(lstTbt_Project);
            EmployeeMappingList  emlst          = new EmployeeMappingList();

            emlst.AddEmployee(doTbt_Project.ToArray());
            IEmployeeMasterHandler Emph = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;

            Emph.EmployeeListMapping(emlst);
            MiscTypeMappingList miscMapList = new MiscTypeMappingList();

            miscMapList.AddMiscType(doTbt_Project.ToArray());
            ICommonHandler comh = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

            comh.MiscTypeMappingList(miscMapList);

            return(doTbt_Project);
        }
Пример #15
0
        /// <summary>
        /// Search employee data.
        /// </summary>
        /// <param name="txtEmployeeCodeSearch"></param>
        /// <param name="txtEmployeeNameSearch"></param>
        /// <returns></returns>
        public ActionResult MAS070_EmployeeSearch(string txtEmployeeCodeSearch, string txtEmployeeNameSearch)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                txtEmployeeCodeSearch = txtEmployeeCodeSearch == "" ? null : txtEmployeeCodeSearch;
                txtEmployeeNameSearch = txtEmployeeNameSearch == "" ? null : txtEmployeeNameSearch;
                IEmployeeMasterHandler hand = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                List <dtEmployee>      list = hand.GetEmployee(txtEmployeeCodeSearch, txtEmployeeNameSearch, null);
                string xml = CommonUtil.ConvertToXml <dtEmployee>(list, "Master\\MAS070_employee", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                res.ResultData = xml;
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Пример #16
0
        /// <summary>
        /// Get email of default department
        /// </summary>
        /// <returns></returns>
        private String getEmailsOfDefaultDepartment()
        {
            //1.1 Get default department to send email
            ICommonHandler        handCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            List <doSystemConfig> doSystem   = handCommon.GetSystemConfig(ConfigName.C_CONFIG_DEPARTMENT_NOTIFY_CHANGE_FEE);
            String strDeptCode = doSystem[0].ConfigValue;

            //1.2 Get employee belonging to default department
            //1.2.1 Get belonging list
            IEmployeeMasterHandler handMaster  = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
            List <dtBelonging>     dtBelonging = handMaster.GetBelonging(null, strDeptCode, null, null);

            List <tbm_Employee> empList = new List <tbm_Employee>();

            foreach (dtBelonging belonging in dtBelonging)
            {
                tbm_Employee employee = new tbm_Employee();
                employee.EmpNo = belonging.EmpNo;
                empList.Add(employee);
            }

            //1.2.2 Get employee list
            List <tbm_Employee> dtEmployee = handMaster.GetEmployeeList(empList);

            //1.3 Generate list of email
            //1.3.1 Set emailTo = Combine all dtEmployee.EmailAddrss with seperated by semi-colon
            StringBuilder sbEmailTo = new StringBuilder("");

            foreach (tbm_Employee employee in dtEmployee)
            {
                sbEmailTo.Append(employee.EmailAddress + ";");
            }

            if (sbEmailTo.Length > 0)
            {
                sbEmailTo = sbEmailTo.Remove(sbEmailTo.Length - 1, 1);
            }

            return(sbEmailTo.ToString());
        }
Пример #17
0
        /// <summary>
        ///  Refresh office data of dsTrans object
        /// </summary>
        /// <param name="dsTrans"></param>
        public void RefreshOfficeData(dsTransDataModel dsTrans)
        {
            try
            {
                #region Belonging User

                dsTrans.dtUserBelongingData = new List <UserBelongingData>();

                IEmployeeMasterHandler handEmp = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;

                List <dtUserBelonging> dtUserBelong = handEmp.getBelongingByEmpNo(dsTrans.dtUserData.EmpNo);
                foreach (dtUserBelonging usrb in dtUserBelong)
                {
                    UserBelongingData UsrBelong = new UserBelongingData(
                        usrb.OfficeCode,
                        usrb.DepartmentCode,
                        usrb.PositionCode);

                    dsTrans.dtUserBelongingData.Add(UsrBelong);
                }

                #endregion
                #region Office

                dsTrans.dtOfficeData = new List <OfficeDataDo>();

                IOfficeMasterHandler handOffice = ServiceContainer.GetService <IOfficeMasterHandler>() as IOfficeMasterHandler;

                List <dtAuthorizeOffice> dtAuthorizedOffice = handOffice.GetAuthorizeOffice(CommonUtil.ConvertToXml_Store <dtUserBelonging>(dtUserBelong));
                dsTrans.dtOfficeData = CommonUtil.ConvertObjectbyLanguage <dtAuthorizeOffice, OfficeDataDo>(dtAuthorizedOffice, "OfficeName");

                #endregion
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #18
0
        /// <summary>
        /// Search selected employee detail.
        /// </summary>
        /// <returns></returns>
        public ActionResult MAS070_EmployeeSearchDetail()
        {
            ObjectResultData res = new ObjectResultData();
            string           empNo;

            try
            {
                empNo = (Request["EmpNo"] == "" ? null : Request["EmpNo"]);
                IEmployeeMasterHandler  hand = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                List <dtEmployeeDetail> list = hand.GetEmployeeDetail(empNo);
                if (list != null && list.Count != 0)
                {
                    dtEmployeeDetail emp = list[0];
                    try
                    {
                        if (emp.EmailAddress != null)
                        {
                            emp.EmailAddress = emp.EmailAddress.Substring(0, emp.EmailAddress.IndexOf('@'));
                        }

                        MAS070_ScreenParameter MAS070Param = GetScreenObject <MAS070_ScreenParameter>();
                        if (emp.UpdateDate.HasValue)
                        {
                            MAS070Param.updateDate = emp.UpdateDate.Value;
                        }
                    }
                    catch { }
                    res.ResultData = emp;
                }
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Пример #19
0
        /// <summary>
        /// Get belonging of selected employee.
        /// </summary>
        /// <param name="empNo"></param>
        /// <returns></returns>
        public ActionResult MAS070_SearchBelonging(string empNo)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                empNo = empNo == "" ? null : empNo;
                IEmployeeMasterHandler hand = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                List <dtBelonging>     list = hand.GetBelonging(null, null, null, empNo);
                CommonUtil.MappingObjectLanguage <dtBelonging>(list);

                MAS070_ScreenParameter MAS070Param = GetScreenObject <MAS070_ScreenParameter>();
                MAS070Param.belongingList = list;

                string xml = CommonUtil.ConvertToXml <dtBelonging>(list, "Master\\MAS070_belonging", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                res.ResultData = xml;
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Пример #20
0
        public ActionResult MAS080_GetEmpNameByEmpNo(string empNo)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                IEmployeeMasterHandler hand   = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                List <dtEmpNo>         result = hand.GetEmployeeNameByEmpNo(empNo);

                if (result != null && result.Count > 0)
                {
                    res.ResultData = result[0].EmployeeNameDisplay;
                }
                else
                {
                    res.ResultData = "";
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
        /// <summary>
        /// Validate employee data
        /// </summary>
        /// <param name="Project"></param>
        /// <returns></returns>
        public CTS230_doValidateEmpNo CTS230_ValidateEmployee(tbt_Project_CTS230 Project)
        {
            ObjectResultData res = new ObjectResultData();

            List <tbm_Employee> dtEmp = new List <tbm_Employee>();

            if (!CommonUtil.IsNullOrEmpty(Project.HeadSalesmanEmpNo))
            {
                tbm_Employee tmp = new tbm_Employee();
                tmp.EmpNo = Project.HeadSalesmanEmpNo;
                dtEmp.Add(tmp);
            }
            if (!CommonUtil.IsNullOrEmpty(Project.ProjectManagerEmpNo))
            {
                tbm_Employee tmp = new tbm_Employee();
                tmp.EmpNo = Project.ProjectManagerEmpNo;
                dtEmp.Add(tmp);
            }
            if (!CommonUtil.IsNullOrEmpty(Project.ProjectSubManagerEmpNo))
            {
                tbm_Employee tmp = new tbm_Employee();
                tmp.EmpNo = Project.ProjectSubManagerEmpNo;
                dtEmp.Add(tmp);
            }
            if (!CommonUtil.IsNullOrEmpty(Project.SecurityPlanningChiefEmpNo))
            {
                tbm_Employee tmp = new tbm_Employee();
                tmp.EmpNo = Project.SecurityPlanningChiefEmpNo;
                dtEmp.Add(tmp);
            }
            if (!CommonUtil.IsNullOrEmpty(Project.InstallationChiefEmpNo))
            {
                tbm_Employee tmp = new tbm_Employee();
                tmp.EmpNo = Project.InstallationChiefEmpNo;
                dtEmp.Add(tmp);
            }
            CTS230_doValidateEmpNo      EmpError       = new CTS230_doValidateEmpNo();
            IEmployeeMasterHandler      EmpH           = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
            List <doActiveEmployeeList> dtTbm_Employee = EmpH.GetActiveEmployeeList(dtEmp);
            string EmpNo;
            string Controls;

            string Prefix = "sysin";

            if (dtTbm_Employee.Count != dtEmp.Count)
            {
                if (!CommonUtil.IsNullOrEmpty(Project.HeadSalesmanEmpNo) &&
                    !dtTbm_Employee.Any(a => a.EmpNo == Project.HeadSalesmanEmpNo))
                {
                    EmpNo             = Project.HeadSalesmanEmpNo;
                    Controls          = Prefix + "HeadSalesmanEmpNo";
                    EmpError.EmpNo    = EmpNo;
                    EmpError.controls = Controls;
                    return(EmpError);
                }
                if (!CommonUtil.IsNullOrEmpty(Project.ProjectManagerEmpNo) &&
                    !dtTbm_Employee.Any(a => a.EmpNo == Project.ProjectManagerEmpNo))
                {
                    EmpNo             = Project.ProjectManagerEmpNo;
                    Controls          = Prefix + "ProjectManagerEmpNo";
                    EmpError.EmpNo    = EmpNo;
                    EmpError.controls = Controls;
                    return(EmpError);
                }
                if (!CommonUtil.IsNullOrEmpty(Project.ProjectSubManagerEmpNo) &&
                    !dtTbm_Employee.Any(a => a.EmpNo == Project.ProjectSubManagerEmpNo))
                {
                    EmpNo             = Project.ProjectSubManagerEmpNo;
                    Controls          = Prefix + "ProjectSubManagerEmpNo";
                    EmpError.EmpNo    = EmpNo;
                    EmpError.controls = Controls;
                    return(EmpError);
                }
                if (!CommonUtil.IsNullOrEmpty(Project.SecurityPlanningChiefEmpNo) &&
                    !dtTbm_Employee.Any(a => a.EmpNo == Project.SecurityPlanningChiefEmpNo))
                {
                    EmpNo             = Project.SecurityPlanningChiefEmpNo;
                    Controls          = Prefix + "SecurityPlanningChiefEmpNo";
                    EmpError.EmpNo    = EmpNo;
                    EmpError.controls = Controls;
                    return(EmpError);
                }
                if (!CommonUtil.IsNullOrEmpty(Project.InstallationChiefEmpNo) &&
                    !dtTbm_Employee.Any(a => a.EmpNo == Project.InstallationChiefEmpNo))
                {
                    EmpNo             = Project.InstallationChiefEmpNo;
                    Controls          = Prefix + "InstallationChiefEmpNo";
                    EmpError.EmpNo    = EmpNo;
                    EmpError.controls = Controls;
                    return(EmpError);
                }
            }
            return(new CTS230_doValidateEmpNo());
        }
Пример #22
0
        private List <tbm_Employee> SaveEmployee(dsEmployeeBelonging employeeInfo, IEmployeeMasterHandler hand)
        {
            List <tbm_Employee> result = null;

            doTransactionLog.eTransactionType?TransactionType = null;
            MAS070_ScreenParameter            MAS070Param     = GetScreenObject <MAS070_ScreenParameter>();
            PasswordHandler handler = new PasswordHandler();

            using (TransactionScope scope = new TransactionScope())
            {
                if (employeeInfo.employee.ModifyMode.Equals("ADD"))
                {
                    employeeInfo.employee.CreateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                    employeeInfo.employee.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                    employeeInfo.employee.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                    employeeInfo.employee.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                    employeeInfo.employee.Password   = handler.GeneratePasswordHash(employeeInfo.employee.Password);
                    List <tbm_Employee> insertList = new List <tbm_Employee>();
                    insertList.Add(employeeInfo.employee);
                    string xml = CommonUtil.ConvertToXml_Store(insertList);
                    result          = hand.InsertEmployee(xml);
                    TransactionType = doTransactionLog.eTransactionType.Insert;
                }
                else
                {
                    if (employeeInfo.employee.ChangePasswordFlag)
                    {
                        employeeInfo.employee.Password = handler.GeneratePasswordHash(employeeInfo.employee.Password);
                        employeeInfo.employee.PasswordLastUpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                        employeeInfo.employee.PasswordWrongCount     = 0;
                        employeeInfo.employee.Status = null;
                    }
                    result          = hand.UpdateEmployee(employeeInfo.employee);
                    TransactionType = doTransactionLog.eTransactionType.Update;
                }

                if (result.Count == 0)
                {
                    return(null);
                }
                else
                {
                    doTransactionLog logData = new doTransactionLog()
                    {
                        TransactionType = TransactionType,
                        TableName       = TableName.C_TBL_NAME_EMPLOYEE,
                        TableData       = CommonUtil.ConvertToXml(result)
                    };
                    ILogHandler loghand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                    loghand.WriteTransactionLog(logData);
                }

                List <tbm_Belonging>      insertBelList      = new List <tbm_Belonging>();
                List <View_tbm_Belonging> checkUpdateBelList = new List <View_tbm_Belonging>();
                List <View_tbm_Belonging> updateBelList      = new List <View_tbm_Belonging>();

                foreach (var item in employeeInfo.belongingList)
                {
                    if (item.ModifyMode.Equals("NONE"))
                    {
                        continue;
                    }

                    if (item.ModifyMode.Equals("ADD"))
                    {
                        item.CreateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                        item.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                        item.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                        item.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                        insertBelList.Add(item);
                    }
                    else if (item.ModifyMode.Equals("EDIT"))
                    {
                        if (MAS070Param.belongingList != null)
                        {
                            var updateDate = from g in MAS070Param.belongingList
                                             where g.BelongingID == item.BelongingID
                                             select g.UpdateDate;

                            foreach (var date in updateDate)
                            {
                                item.UpdateDate = date;
                            }
                        }

                        if (item.UpdateDate != null)
                        {
                            checkUpdateBelList.Add(item);
                            updateBelList.Add(item);
                        }
                        else
                        {
                            item.CreateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                            item.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                            item.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                            item.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                            insertBelList.Add(item);
                        }
                    }
                }


                if (employeeInfo.delBelList != null && employeeInfo.delBelList.Count != 0)
                {
                    foreach (var item in employeeInfo.delBelList)
                    {
                        var updateDate = from g in MAS070Param.belongingList
                                         where g.BelongingID == item.BelongingID
                                         select g.UpdateDate;

                        foreach (var date in updateDate)
                        {
                            item.UpdateDate = date;
                        }
                    }

                    checkUpdateBelList.AddRange(employeeInfo.delBelList);
                }

                if (checkUpdateBelList.Count != 0)
                {
                    hand.checkBelongingUpdateDate(checkUpdateBelList);
                }

                if (insertBelList.Count != 0)
                {
                    string xml = CommonUtil.ConvertToXml_Store(insertBelList);
                    List <tbm_Belonging> insertedList = hand.InsertBelonging(xml);
                    if (insertedList.Count == 0)
                    {
                        return(null);
                    }
                    else
                    {
                        doTransactionLog logData = new doTransactionLog()
                        {
                            TransactionType = doTransactionLog.eTransactionType.Insert,
                            TableName       = TableName.C_TBL_NAME_BELONGING,
                            TableData       = CommonUtil.ConvertToXml(insertedList)
                        };
                        ILogHandler loghand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                        loghand.WriteTransactionLog(logData);
                    }
                }

                foreach (var item in updateBelList)
                {
                    List <tbm_Belonging> updateList = new List <tbm_Belonging>();
                    updateList.Add(item);
                    string xml = CommonUtil.ConvertToXml_Store(updateList);
                    List <tbm_Belonging> updatedList = hand.UpdateBelonging(xml, item.BelongingID);
                    if (updatedList.Count == 0)
                    {
                        return(null);
                    }
                    else
                    {
                        doTransactionLog logData = new doTransactionLog()
                        {
                            TransactionType = doTransactionLog.eTransactionType.Update,
                            TableName       = TableName.C_TBL_NAME_BELONGING,
                            TableData       = CommonUtil.ConvertToXml(updatedList)
                        };
                        ILogHandler loghand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                        loghand.WriteTransactionLog(logData);
                    }
                }

                if (employeeInfo.delBelList != null && employeeInfo.delBelList.Count != 0)
                {
                    foreach (var item in employeeInfo.delBelList)
                    {
                        List <tbm_Belonging> deletedList = hand.DeleteBelonging(item.BelongingID);
                        if (deletedList.Count == 0)
                        {
                            return(null);
                        }
                        else
                        {
                            doTransactionLog logData = new doTransactionLog()
                            {
                                TransactionType = doTransactionLog.eTransactionType.Delete,
                                TableName       = TableName.C_TBL_NAME_BELONGING,
                                TableData       = CommonUtil.ConvertToXml(deletedList)
                            };
                            ILogHandler loghand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                            loghand.WriteTransactionLog(logData);
                        }
                    }
                }

                scope.Complete();
            }

            return(result);
        }
Пример #23
0
        /// <summary>
        /// Check username and password.<br />
        /// Check is Employee No. active.<br />
        /// Get user default language.<br/>
        /// Refresh user data.
        /// </summary>
        /// <param name="Cond"></param>
        /// <returns></returns>
        public ActionResult Login(doLogin Cond)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                if (ModelState.IsValid == false)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                    return(Json(res));
                }

                //1.2
                ILoginHandler handLogin  = ServiceContainer.GetService <ILoginHandler>() as ILoginHandler;
                bool          bLogDomain = handLogin.LoginDomain(Cond);
                //if (!bLogDomain)
                //{
                //    if (handLogin.IsLockedEmployee(Cond.EmployeeNo))
                //    {
                //        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0PWL);
                //    }
                //    else
                //    {
                //        //Comment for Test Only : Nattapong N.
                //        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0099);
                //    }
                //    ILogHandler handLog = ServiceContainer.GetService<ILogHandler>() as ILogHandler;
                //    handLog.WriteWindowLog(EventType.C_EVENT_TYPE_ERROR, LogMessage.C_LOG_INVALID_USER, EventID.C_EVENT_ID_LOGIN_FAIL);

                //    return Json(res);
                //}

                // Clear Temporary pdf file where crate date < today
                bool isClear = ReportUtil.ClearTemporaryFile();

                //1.3
                IEmployeeMasterHandler handEmp = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                bool blnExistEmployee          = handEmp.CheckExistActiveEmployee(Cond.EmployeeNo);
                //if (!blnExistEmployee)
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0099);
                //    return Json(res);
                //}


                dsTransDataModel  dsTrans   = new dsTransDataModel();
                ITransDataHandler handTrans = ServiceContainer.GetService <ITransDataHandler>() as ITransDataHandler;

                #region Language

                dsTrans.dtTransHeader          = new TransHeaderDo();
                dsTrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_EN;

                if (this.RouteData.Values["lang"] != null &&
                    !string.IsNullOrWhiteSpace(this.RouteData.Values["lang"].ToString()))
                {
                    // set the culture from the route data (url)
                    string lang = this.RouteData.Values["lang"].ToString();

                    if (lang.ToLower() == CommonValue.DEFAULT_SHORT_LANGUAGE_EN)
                    {
                        dsTrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_EN;
                    }
                    else if (lang.ToLower() == CommonValue.DEFAULT_SHORT_LANGUAGE_JP)
                    {
                        dsTrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_JP;
                    }
                    else if (lang.ToLower() == CommonValue.DEFAULT_SHORT_LANGUAGE_LC)
                    {
                        dsTrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_LC;
                    }
                }
                CommonUtil.dsTransData = dsTrans;

                #endregion
                #region Refesh Data

                handTrans.RefreshUserData(dsTrans, Cond.EmployeeNo);
                handTrans.RefreshOfficeData(dsTrans);
                handTrans.RefreshPermissionData(dsTrans);

                #endregion

                handLogin.KeepHistory(Cond.EmployeeNo, LogType.C_LOG_IN);

                dsTrans.dtOperationData = new OperationDataDo();
                dsTrans.dtOperationData.ProcessDateTime = DateTime.Now;

                dsTrans.dtCommonSearch = new CommonSearchDo();

                CommonUtil.dsTransData = dsTrans;


                //-----------Add by Narupon W.-------(Menu list)-----------------//

                IMasterHandler    handMAS  = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;
                List <tbm_Object> menuList = handMAS.GetTbm_Object();
                dsTrans.dtMenuNameList = CommonUtil.ClonsObjectList <tbm_Object, MenuName>(menuList);
                CommonUtil.MappingObjectLanguage <MenuName>(dsTrans.dtMenuNameList);

                //-----------END Add by Narupon W.-------(Menu list)-------------//



                res.ResultData = "/Common/CMS020";

                doDirectScreen dos = CommonUtil.GetSession <doDirectScreen>("DIRECT_SCREEN");
                if (dos != null)
                {
                    res.ResultData = dos;
                    CommonUtil.SetSession("DIRECT_SCREEN", null);
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Пример #24
0
        /// <summary>
        /// Add/Edit customer group.<br />
        /// - Validate field.<br />
        /// - Check exist active employee.<br />
        /// - Check duplicate group.<br />
        /// - Update database.
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ActionResult MAS060_AddEdit(MAS060_AddEdit cond)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            try
            {
                //Validate Required Field
                if (ModelState.IsValid == false)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                    if (res.IsError)
                    {
                        return(Json(res));
                    }
                }

                //Already validate when load emp name
                //if (!CommonUtil.IsNullOrEmpty(cond.GroupEmpNo) && CommonUtil.IsNullOrEmpty(cond.GroupEmpName))
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0024);
                //    return Json(res);
                //}

                if (CommonUtil.IsNullOrEmpty(cond.GroupEmpNo) == false)
                {
                    IEmployeeMasterHandler handler = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                    if (handler.CheckExistActiveEmployee(cond.GroupEmpNo) == false)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON,
                                            MessageUtil.MessageList.MSG0095,
                                            new string[] { cond.GroupEmpNo },
                                            new string[] { "GroupEmpNo" });
                        return(Json(res));
                    }
                }

                IGroupMasterHandler hand = ServiceContainer.GetService <IGroupMasterHandler>() as IGroupMasterHandler;
                bool bResult             = hand.CheckDuplicateGroupData(cond.GroupNameEN, cond.GroupCode);
                if (bResult)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1010);
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    return(Json(res));
                }
                else
                {
                    //Check System Suspending
                    res = checkSystemSuspending();
                    if (res.IsError)
                    {
                        return(Json(res));
                    }

                    MAS060_ScreenParameter MAS060Param = GetScreenObject <MAS060_ScreenParameter>();
                    doGroup resultObj = new doGroup();
                    if (cond.CurrentMode == FunctionID.C_FUNC_ID_ADD)
                    {
                        string strGroupCode = hand.GenerateGroupCode();
                        if (!CommonUtil.IsNullOrEmpty(strGroupCode))
                        {
                            //set insert value
                            doGroup group = new doGroup();
                            group.GroupCode       = strGroupCode;
                            group.GroupNameEN     = cond.GroupNameEN;
                            group.GroupNameLC     = cond.GroupNameLC;
                            group.Memo            = cond.Memo;
                            group.GroupOfficeCode = cond.GroupOfficeCode;
                            group.GroupEmpNo      = cond.GroupEmpNo;
                            group.GroupEmpName    = cond.GroupEmpName;
                            group.DeleteFlag      = cond.DeleteFlag;

                            //Insert data in db
                            List <tbm_Group> inserted = hand.InsertGroup(group);

                            //Set new UpdateDate
                            group.UpdateDate = inserted[0].UpdateDate;

                            //Add new data in session
                            if (MAS060Param.SearchResult == null)
                            {
                                MAS060Param.SearchResult = new List <doGroup>();
                            }
                            MAS060Param.SearchResult.Add(group);
                            UpdateScreenObject(MAS060Param);
                            resultObj.GroupCode = strGroupCode;
                        }
                    }
                    else if (cond.CurrentMode == FunctionID.C_FUNC_ID_EDIT)
                    {
                        var doGroupList = from g in MAS060Param.SearchResult
                                          where g.GroupCode == cond.GroupCode
                                          select g;

                        foreach (var group in doGroupList)
                        {
                            //set update value
                            group.GroupCode       = cond.GroupCode;
                            group.GroupNameEN     = cond.GroupNameEN;
                            group.GroupNameLC     = cond.GroupNameLC;
                            group.Memo            = cond.Memo;
                            group.GroupOfficeCode = cond.GroupOfficeCode;
                            group.GroupEmpNo      = cond.GroupEmpNo;
                            group.GroupEmpName    = cond.GroupEmpName;
                            group.DeleteFlag      = cond.DeleteFlag;

                            if (CommonUtil.IsNullOrEmpty(group.UpdateDate))
                            {
                                res.AddErrorMessage(
                                    MessageUtil.MODULE_COMMON,
                                    MessageUtil.MessageList.MSG0007,
                                    new string[] { "UpdateDate" });
                                return(Json(res));
                            }

                            //Update data in db
                            List <tbm_Group> updated = hand.UpdateGroup(group);

                            //Set new UpdateDate
                            group.UpdateDate = updated[0].UpdateDate;

                            //Save edit data in session
                            UpdateScreenObject(MAS060Param);
                            resultObj.GroupCode = cond.GroupCode;
                            break;
                        }
                    }

                    //when finish with out error
                    Object[] result = new Object[2];
                    result[0] = resultObj;
                    result[1] = MessageUtil.GetMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0046);

                    res.ResultData = result;
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Пример #25
0
        /// <summary>
        /// Get entire draft sale contract
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="mode"></param>
        /// <param name="procType"></param>
        /// <returns></returns>
        public doDraftSaleContractData GetEntireDraftSaleContract(doDraftSaleContractCondition cond, doDraftSaleContractData.SALE_CONTRACT_MODE mode, doDraftSaleContractData.PROCESS_TYPE procType)
        {
            try
            {
                doDraftSaleContractData saleData = null;

                if (mode == doDraftSaleContractData.SALE_CONTRACT_MODE.QUOTATION)
                {
                    CommonUtil cmm = new CommonUtil();
                    doGetQuotationDataCondition qcond = new doGetQuotationDataCondition();
                    qcond.QuotationTargetCode = cond.QuotationTargetCodeLong;
                    qcond.Alphabet            = cond.Alphabet;
                    qcond.ServiceTypeCode     = ServiceType.C_SERVICE_TYPE_SALE;


                    if (procType == doDraftSaleContractData.PROCESS_TYPE.NEW)
                    {
                        qcond.TargetCodeTypeCode = TargetCodeType.C_TARGET_CODE_TYPE_QTN_CODE;
                    }
                    else
                    {
                        qcond.TargetCodeTypeCode = TargetCodeType.C_TARGET_CODE_TYPE_CONTRACT_CODE;
                    }

                    qcond.ContractFlag = true;

                    IQuotationHandler qhandler = ServiceContainer.GetService <IQuotationHandler>() as IQuotationHandler;
                    dsQuotationData   qData    = qhandler.GetQuotationData(qcond);
                    if (qData != null)
                    {
                        #region Check Authority

                        bool hasAuthority             = false;
                        List <OfficeDataDo> officeLst = CommonUtil.dsTransData.dtOfficeData;
                        if (qData.dtTbt_QuotationTarget != null &&
                            officeLst.Count > 0)
                        {
                            foreach (OfficeDataDo office in officeLst)
                            {
                                if (office.OfficeCode == qData.dtTbt_QuotationTarget.QuotationOfficeCode ||
                                    office.OfficeCode == qData.dtTbt_QuotationTarget.OperationOfficeCode)
                                {
                                    hasAuthority = true;
                                    break;
                                }
                            }
                        }
                        if (hasAuthority == false)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0063);
                        }

                        #endregion

                        saleData = new doDraftSaleContractData();

                        if (qData.dtTbt_QuotationTarget.UpdateDate != null)
                        {
                            saleData.LastUpdateDateQuotationData = qData.dtTbt_QuotationTarget.UpdateDate.Value;
                        }

                        #region Set Draft Sale Contract

                        saleData.doTbt_DraftSaleContract = CommonUtil.CloneObject <tbt_QuotationBasic, tbt_DraftSaleContract>(qData.dtTbt_QuotationBasic);
                        if (saleData.doTbt_DraftSaleContract != null)
                        {
                            saleData.doTbt_DraftSaleContract.QuotationTargetCode = cond.QuotationTargetCodeLong;
                            saleData.doTbt_DraftSaleContract.Alphabet            = cond.Alphabet;
                            saleData.doTbt_DraftSaleContract.ProductTypeCode     = qData.dtTbt_QuotationTarget.ProductTypeCode;
                            saleData.doTbt_DraftSaleContract.BranchNameEN        = qData.dtTbt_QuotationTarget.BranchNameEN;
                            saleData.doTbt_DraftSaleContract.BranchNameLC        = qData.dtTbt_QuotationTarget.BranchNameLC;
                            saleData.doTbt_DraftSaleContract.BranchAddressEN     = qData.dtTbt_QuotationTarget.BranchAddressEN;
                            saleData.doTbt_DraftSaleContract.BranchAddressLC     = qData.dtTbt_QuotationTarget.BranchAddressLC;

                            saleData.doTbt_DraftSaleContract.PurchaserMemo    = qData.dtTbt_QuotationTarget.ContractTargetMemo;
                            saleData.doTbt_DraftSaleContract.RealCustomerMemo = qData.dtTbt_QuotationTarget.RealCustomerMemo;

                            foreach (tbt_QuotationCustomer cust in qData.dtTbt_QuotationCustomer)
                            {
                                if (cust.CustPartTypeCode == CustPartType.C_CUST_PART_TYPE_CONTRACT_TARGET)
                                {
                                    saleData.doTbt_DraftSaleContract.PurchaserCustCode = cust.CustCode;
                                }
                                else if (cust.CustPartTypeCode == CustPartType.C_CUST_PART_TYPE_REAL_CUST)
                                {
                                    saleData.doTbt_DraftSaleContract.RealCustomerCustCode = cust.CustCode;
                                }
                            }
                            if (qData.dtTbt_QuotationSite != null)
                            {
                                saleData.doTbt_DraftSaleContract.SiteCode = qData.dtTbt_QuotationSite.SiteCode;
                            }

                            saleData.doTbt_DraftSaleContract.ConnectTargetCode = qData.dtTbt_QuotationBasic.SaleOnlineContractCode;
                            if (CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.ConnectTargetCode) == false)
                            {
                                saleData.doTbt_DraftSaleContract.ConnectionFlag = FlagType.C_FLAG_ON;
                            }
                            else
                            {
                                saleData.doTbt_DraftSaleContract.ConnectionFlag = FlagType.C_FLAG_OFF;
                            }


                            saleData.doTbt_DraftSaleContract.NormalProductPriceCurrencyType = qData.dtTbt_QuotationBasic.ProductPriceCurrencyType;
                            saleData.doTbt_DraftSaleContract.NormalProductPrice             = qData.dtTbt_QuotationBasic.ProductPrice;
                            saleData.doTbt_DraftSaleContract.NormalProductPriceUsd          = qData.dtTbt_QuotationBasic.ProductPriceUsd;

                            saleData.doTbt_DraftSaleContract.NormalInstallFeeCurrencyType = qData.dtTbt_QuotationBasic.InstallationFeeCurrencyType;
                            saleData.doTbt_DraftSaleContract.NormalInstallFee             = qData.dtTbt_QuotationBasic.InstallationFee;
                            saleData.doTbt_DraftSaleContract.NormalInstallFeeUsd          = qData.dtTbt_QuotationBasic.InstallationFeeUsd;

                            if (CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.NormalProductPrice) == false ||
                                CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.NormalInstallFee) == false)
                            {
                                saleData.doTbt_DraftSaleContract.NormalSalePrice = 0;

                                //if (CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.NormalProductPrice) == false)
                                //    saleData.doTbt_DraftSaleContract.NormalSalePrice += saleData.doTbt_DraftSaleContract.NormalProductPrice;
                                //if (CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.NormalInstallFee) == false)
                                //    saleData.doTbt_DraftSaleContract.NormalSalePrice += saleData.doTbt_DraftSaleContract.NormalInstallFee;
                            }
                            saleData.doTbt_DraftSaleContract.NormalSpecialItemPrice = 0;
                            saleData.doTbt_DraftSaleContract.NormalOtherProdPrice   = 0;
                            saleData.doTbt_DraftSaleContract.NormalOtherInstallFee  = 0;

                            //saleData.doTbt_DraftSaleContract.OrderProductPrice = qData.dtTbt_QuotationBasic.ProductPrice;
                            //saleData.doTbt_DraftSaleContract.OrderInstallFee = qData.dtTbt_QuotationBasic.InstallationFee;
                            //saleData.doTbt_DraftSaleContract.OrderSalePrice = saleData.doTbt_DraftSaleContract.NormalSalePrice;

                            saleData.doTbt_DraftSaleContract.OrderProductPriceCurrencyType = qData.dtTbt_QuotationBasic.ProductPriceCurrencyType;
                            saleData.doTbt_DraftSaleContract.OrderProductPrice             = null;
                            saleData.doTbt_DraftSaleContract.OrderProductPriceUsd          = null;

                            saleData.doTbt_DraftSaleContract.OrderInstallFeeCurrencyType = qData.dtTbt_QuotationBasic.InstallationFeeCurrencyType;
                            saleData.doTbt_DraftSaleContract.OrderInstallFee             = null;
                            saleData.doTbt_DraftSaleContract.OrderInstallFeeUsd          = null;

                            saleData.doTbt_DraftSaleContract.OrderSalePrice = null;

                            saleData.doTbt_DraftSaleContract.TotalSaleBilingAmt_Agreed = 0;

                            saleData.doTbt_DraftSaleContract.QuotationStaffEmpNo = qData.dtTbt_QuotationTarget.QuotationStaffEmpNo;
                            saleData.doTbt_DraftSaleContract.QuotationOfficeCode = qData.dtTbt_QuotationTarget.QuotationOfficeCode;
                            saleData.doTbt_DraftSaleContract.OperationOfficeCode = qData.dtTbt_QuotationTarget.OperationOfficeCode;
                            saleData.doTbt_DraftSaleContract.AcquisitionTypeCode = qData.dtTbt_QuotationTarget.AcquisitionTypeCode;
                            saleData.doTbt_DraftSaleContract.IntroducerCode      = qData.dtTbt_QuotationTarget.IntroducerCode;
                            saleData.doTbt_DraftSaleContract.MotivationTypeCode  = qData.dtTbt_QuotationTarget.MotivationTypeCode;

                            saleData.doTbt_DraftSaleContract.ApproveNo1 = null;
                            saleData.doTbt_DraftSaleContract.ApproveNo2 = null;
                            saleData.doTbt_DraftSaleContract.ApproveNo3 = null;
                            saleData.doTbt_DraftSaleContract.ApproveNo4 = null;
                            saleData.doTbt_DraftSaleContract.ApproveNo5 = null;

                            saleData.doTbt_DraftSaleContract.CreateBy   = null;
                            saleData.doTbt_DraftSaleContract.CreateDate = null;
                            saleData.doTbt_DraftSaleContract.UpdateBy   = null;
                            saleData.doTbt_DraftSaleContract.UpdateDate = null;

                            List <tbt_DraftSaleContract> contractLst = this.GetTbt_DraftSaleContract(cond.QuotationTargetCodeLong);
                            if (contractLst.Count > 0)
                            {
                                saleData.doTbt_DraftSaleContract.CreateBy   = contractLst[0].CreateBy;
                                saleData.doTbt_DraftSaleContract.CreateDate = contractLst[0].CreateDate;
                                saleData.doTbt_DraftSaleContract.UpdateBy   = contractLst[0].UpdateBy;
                                saleData.doTbt_DraftSaleContract.UpdateDate = contractLst[0].UpdateDate;
                            }

                            if (saleData.doTbt_DraftSaleContract.ProductTypeCode == ProductType.C_PROD_TYPE_ONLINE)
                            {
                                ISaleContractHandler shandler = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
                                if (qData.dtTbt_QuotationBasic.SaleOnlineContractCode != null)
                                {
                                    doSaleContractData doSaleContract = shandler.GetSaleContractData(qData.dtTbt_QuotationBasic.SaleOnlineContractCode, null);
                                    if (doSaleContract != null)
                                    {
                                        saleData.doTbt_DraftSaleContract.SecurityAreaFrom = doSaleContract.dtTbt_SaleBasic.SecurityAreaFrom;
                                        saleData.doTbt_DraftSaleContract.SecurityAreaTo   = doSaleContract.dtTbt_SaleBasic.SecurityAreaTo;
                                    }
                                }
                            }
                        }

                        #endregion
                        #region Set Draft Sale Customer

                        MiscTypeMappingList    cmLst    = new MiscTypeMappingList();
                        ICustomerMasterHandler chandler = ServiceContainer.GetService <ICustomerMasterHandler>() as ICustomerMasterHandler;
                        foreach (tbt_QuotationCustomer cust in qData.dtTbt_QuotationCustomer)
                        {
                            doCustomerWithGroup icust = null;
                            if (cust.CustCode != null)
                            {
                                List <doCustomerWithGroup> lst = chandler.GetCustomerWithGroup(cust.CustCode);
                                if (lst.Count > 0)
                                {
                                    icust = lst[0];
                                }
                            }
                            else
                            {
                                icust = CommonUtil.CloneObject <tbt_QuotationCustomer, doCustomerWithGroup>(cust);
                                if (icust != null)
                                {
                                    icust.CustomerGroupData = new List <dtCustomeGroupData>();
                                }

                                IMasterHandler mhandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;

                                if (icust.BusinessTypeCode != null)
                                {
                                    List <tbm_BusinessType> btLst = mhandler.GetTbm_BusinessType();
                                    foreach (tbm_BusinessType bt in btLst)
                                    {
                                        if (bt.BusinessTypeCode == icust.BusinessTypeCode)
                                        {
                                            icust.BusinessTypeName = bt.BusinessTypeName;
                                            break;
                                        }
                                    }
                                }
                                if (icust.RegionCode != null)
                                {
                                    List <tbm_Region> rLst = mhandler.GetTbm_Region();
                                    foreach (tbm_Region r in rLst)
                                    {
                                        if (r.RegionCode == icust.RegionCode)
                                        {
                                            icust.Nationality = r.Nationality;
                                            break;
                                        }
                                    }
                                }
                                if (icust.CustTypeCode != null)
                                {
                                    cmLst.AddMiscType(icust);
                                }
                            }
                            if (icust != null)
                            {
                                if (cust.CustPartTypeCode == CustPartType.C_CUST_PART_TYPE_CONTRACT_TARGET)
                                {
                                    saleData.doPurchaserCustomer = icust;
                                }
                                else if (cust.CustPartTypeCode == CustPartType.C_CUST_PART_TYPE_REAL_CUST)
                                {
                                    saleData.doRealCustomer = icust;
                                }
                            }
                        }

                        ICommonHandler cmmhandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                        cmmhandler.MiscTypeMappingList(cmLst);

                        #endregion
                        #region Set Draft Sale Site

                        if (qData.dtTbt_QuotationSite != null)
                        {
                            if (qData.dtTbt_QuotationSite.SiteCode != null)
                            {
                                ISiteMasterHandler shandler = ServiceContainer.GetService <ISiteMasterHandler>() as ISiteMasterHandler;
                                List <doSite>      lst      = shandler.GetSite(qData.dtTbt_QuotationSite.SiteCode, null);
                                if (lst.Count > 0)
                                {
                                    saleData.doSite = lst[0];
                                }
                            }
                            else
                            {
                                saleData.doSite = CommonUtil.CloneObject <tbt_QuotationSite, doSite>(qData.dtTbt_QuotationSite);

                                IMasterHandler           mhandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;
                                List <tbm_BuildingUsage> blst     = mhandler.GetTbm_BiuldingUsage();
                                foreach (tbm_BuildingUsage b in blst)
                                {
                                    if (b.BuildingUsageCode == saleData.doSite.BuildingUsageCode)
                                    {
                                        saleData.doSite.BuildingUsageName = b.BuildingUsageName;
                                        break;
                                    }
                                }
                            }
                        }

                        #endregion
                        #region Set Draft Sale Instrument

                        saleData.doTbt_DraftSaleInstrument = new List <tbt_DraftSaleInstrument>();
                        if (qData.dtTbt_QuotationInstrumentDetails != null)
                        {
                            foreach (tbt_QuotationInstrumentDetails inst in qData.dtTbt_QuotationInstrumentDetails)
                            {
                                tbt_DraftSaleInstrument dInst = new tbt_DraftSaleInstrument();
                                dInst.QuotationTargetCode = cond.QuotationTargetCodeLong;
                                dInst.InstrumentCode      = inst.InstrumentCode;
                                dInst.InstrumentQty       = inst.InstrumentQty;
                                dInst.InstrumentTypeCode  = InstrumentType.C_INST_TYPE_GENERAL;

                                if (CommonUtil.IsNullOrEmpty(dInst.InstrumentQty) == false)
                                {
                                    if (CommonUtil.IsNullOrEmpty(inst.AddQty) == false)
                                    {
                                        dInst.InstrumentQty += inst.AddQty;
                                    }
                                    if (CommonUtil.IsNullOrEmpty(inst.RemoveQty) == false)
                                    {
                                        dInst.InstrumentQty -= inst.RemoveQty;
                                    }
                                }

                                saleData.doTbt_DraftSaleInstrument.Add(dInst);
                            }
                        }
                        if (qData.dtTbt_QuotationFacilityDetails != null)
                        {
                            foreach (tbt_QuotationFacilityDetails facility in qData.dtTbt_QuotationFacilityDetails)
                            {
                                tbt_DraftSaleInstrument dInst = new tbt_DraftSaleInstrument();
                                dInst.QuotationTargetCode = cond.QuotationTargetCode;
                                dInst.InstrumentCode      = facility.FacilityCode;
                                dInst.InstrumentQty       = facility.FacilityQty;
                                dInst.InstrumentTypeCode  = InstrumentType.C_INST_TYPE_MONITOR;

                                saleData.doTbt_DraftSaleInstrument.Add(dInst);
                            }
                        }

                        if (saleData.doTbt_DraftSaleInstrument.Count > 0)
                        {
                            InstrumentMappingList instMappingLst = new InstrumentMappingList();
                            instMappingLst.AddInstrument(saleData.doTbt_DraftSaleInstrument.ToArray());

                            IInstrumentMasterHandler ihandler = ServiceContainer.GetService <IInstrumentMasterHandler>() as IInstrumentMasterHandler;
                            ihandler.InstrumentListMapping(instMappingLst);
                        }

                        #endregion
                        #region Set Draft Relation Type

                        saleData.doTbt_RelationType = new List <tbt_RelationType>();

                        /* -- Sale Online --- */
                        if (CommonUtil.IsNullOrEmpty(qData.dtTbt_QuotationBasic.SaleOnlineContractCode) == false)
                        {
                            saleData.doTbt_RelationType.Add(new tbt_RelationType()
                            {
                                RelatedContractCode = qData.dtTbt_QuotationBasic.SaleOnlineContractCode,
                                RelatedOCC          = qData.dtTbt_QuotationBasic.LastOccNo,
                                OCC          = null,
                                RelationType = RelationType.C_RELATION_TYPE_SALE
                            });
                        }

                        #endregion
                    }
                }
                else if (mode == doDraftSaleContractData.SALE_CONTRACT_MODE.DRAFT ||
                         mode == doDraftSaleContractData.SALE_CONTRACT_MODE.APPROVE)
                {
                    saleData = new doDraftSaleContractData();

                    #region Set Draft Sale Contract

                    List <tbt_DraftSaleContract> contractLst = this.GetTbt_DraftSaleContract(cond.QuotationTargetCodeLong);
                    if (contractLst.Count > 0)
                    {
                        saleData.doTbt_DraftSaleContract = contractLst[0];
                    }
                    else
                    {
                        return(null);
                    }

                    #endregion
                    #region Check Authority

                    bool hasAuthority             = false;
                    List <OfficeDataDo> officeLst = CommonUtil.dsTransData.dtOfficeData;
                    if (saleData.doTbt_DraftSaleContract != null &&
                        officeLst.Count > 0)
                    {
                        foreach (OfficeDataDo office in officeLst)
                        {
                            if (office.OfficeCode == saleData.doTbt_DraftSaleContract.QuotationOfficeCode ||
                                office.OfficeCode == saleData.doTbt_DraftSaleContract.OperationOfficeCode)
                            {
                                hasAuthority = true;
                                break;
                            }
                        }
                    }
                    if (hasAuthority == false)
                    {
                        throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0063);
                    }

                    #endregion
                    #region Check Contract status

                    if (mode == doDraftSaleContractData.SALE_CONTRACT_MODE.DRAFT &&
                        saleData.doTbt_DraftSaleContract.DraftSaleContractStatus != ApprovalStatus.C_APPROVE_STATUS_RETURNED)
                    {
                        throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3100);
                    }
                    else if (mode == doDraftSaleContractData.SALE_CONTRACT_MODE.APPROVE)
                    {
                        if (saleData.doTbt_DraftSaleContract.DraftSaleContractStatus == ApprovalStatus.C_APPROVE_STATUS_APPROVED)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3246);
                        }
                        else if (saleData.doTbt_DraftSaleContract.DraftSaleContractStatus == ApprovalStatus.C_APPROVE_STATUS_REJECTED)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3244);
                        }
                        else if (saleData.doTbt_DraftSaleContract.DraftSaleContractStatus == ApprovalStatus.C_APPROVE_STATUS_RETURNED)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3245);
                        }
                    }

                    #endregion

                    #region Set Draft Sale E-mail

                    saleData.doTbt_DraftSaleEmail = this.GetTbt_DraftSaleEmail(cond.QuotationTargetCodeLong);
                    if (saleData.doTbt_DraftSaleEmail != null)
                    {
                        IEmployeeMasterHandler empHandler = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;

                        List <tbm_Employee> emps = new List <tbm_Employee>();
                        foreach (tbt_DraftSaleEmail email in saleData.doTbt_DraftSaleEmail)
                        {
                            emps.Add(new tbm_Employee()
                            {
                                EmpNo = email.ToEmpNo
                            });
                        }
                        List <tbm_Employee> empList = empHandler.GetEmployeeList(emps);
                        if (empList.Count > 0)
                        {
                            foreach (tbt_DraftSaleEmail email in saleData.doTbt_DraftSaleEmail)
                            {
                                foreach (tbm_Employee emp in empList)
                                {
                                    if (emp.EmpNo == email.ToEmpNo)
                                    {
                                        email.EmailAddress = emp.EmailAddress;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    #endregion
                    #region Set Draft Sale Instrument

                    saleData.doTbt_DraftSaleInstrument = this.GetTbt_DraftSaleInstrument(cond.QuotationTargetCodeLong);
                    if (saleData.doTbt_DraftSaleInstrument.Count > 0)
                    {
                        InstrumentMappingList instMappingLst = new InstrumentMappingList();
                        instMappingLst.AddInstrument(saleData.doTbt_DraftSaleInstrument.ToArray());

                        IInstrumentMasterHandler ihandler = ServiceContainer.GetService <IInstrumentMasterHandler>() as IInstrumentMasterHandler;
                        ihandler.InstrumentListMapping(instMappingLst);
                    }

                    #endregion
                    #region Set Draft Sale Billing Target

                    saleData.doTbt_DraftSaleBillingTarget = this.GetTbt_DraftSaleBillingTarget(cond.QuotationTargetCodeLong);

                    #endregion

                    #region Set Contract Customer

                    ICustomerMasterHandler custhandler = ServiceContainer.GetService <ICustomerMasterHandler>() as ICustomerMasterHandler;
                    if (CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.PurchaserCustCode) == false)
                    {
                        List <doCustomerWithGroup> custLst = custhandler.GetCustomerWithGroup(saleData.doTbt_DraftSaleContract.PurchaserCustCode);
                        if (custLst.Count > 0)
                        {
                            saleData.doPurchaserCustomer = custLst[0];
                        }
                    }
                    if (CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.RealCustomerCustCode) == false)
                    {
                        List <doCustomerWithGroup> custLst = custhandler.GetCustomerWithGroup(saleData.doTbt_DraftSaleContract.RealCustomerCustCode);
                        if (custLst.Count > 0)
                        {
                            saleData.doRealCustomer = custLst[0];
                        }
                    }

                    #endregion
                    #region Set Site

                    ISiteMasterHandler shandler = ServiceContainer.GetService <ISiteMasterHandler>() as ISiteMasterHandler;
                    List <doSite>      siteLst  = shandler.GetSite(saleData.doTbt_DraftSaleContract.SiteCode, saleData.doTbt_DraftSaleContract.RealCustomerCustCode);
                    if (siteLst.Count > 0)
                    {
                        saleData.doSite = siteLst[0];
                    }

                    #endregion

                    doGetQuotationDataCondition qcond = new doGetQuotationDataCondition();
                    qcond.QuotationTargetCode = cond.QuotationTargetCodeLong;
                    qcond.Alphabet            = saleData.doTbt_DraftSaleContract.Alphabet;//cond.Alphabet;
                    qcond.ServiceTypeCode     = ServiceType.C_SERVICE_TYPE_SALE;

                    if (saleData.doTbt_DraftSaleContract.SaleProcessType == SaleProcessType.C_SALE_PROCESS_TYPE_ADD_SALE)
                    {
                        qcond.TargetCodeTypeCode = TargetCodeType.C_TARGET_CODE_TYPE_CONTRACT_CODE;
                    }
                    else
                    {
                        qcond.TargetCodeTypeCode = TargetCodeType.C_TARGET_CODE_TYPE_QTN_CODE;
                    }

                    qcond.ContractFlag = true;

                    IQuotationHandler qhandler = ServiceContainer.GetService <IQuotationHandler>() as IQuotationHandler;
                    dsQuotationData   qData    = qhandler.GetQuotationData(qcond);
                    if (qData != null)
                    {
                        if (qData.dtTbt_QuotationTarget.UpdateDate != null)
                        {
                            saleData.LastUpdateDateQuotationData = qData.dtTbt_QuotationTarget.UpdateDate.Value;
                        }
                    }
                }

                if (saleData != null)
                {
                    if (saleData.doTbt_DraftSaleContract != null)
                    {
                        #region Set Product Name

                        IProductMasterHandler   mhandler = ServiceContainer.GetService <IProductMasterHandler>() as IProductMasterHandler;
                        List <View_tbm_Product> pLst     = mhandler.GetTbm_ProductByLanguage(
                            saleData.doTbt_DraftSaleContract.ProductCode,
                            saleData.doTbt_DraftSaleContract.ProductTypeCode);

                        if (pLst.Count > 0)
                        {
                            saleData.doTbt_DraftSaleContract.ProductName = pLst[0].ProductName;
                        }

                        #endregion
                        #region Set Misc Name

                        MiscTypeMappingList miscLst = new MiscTypeMappingList();
                        miscLst.AddMiscType(saleData.doTbt_DraftSaleContract);
                        miscLst.AddMiscType(saleData.doTbt_DraftSaleInstrument.ToArray());

                        ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                        chandler.MiscTypeMappingList(miscLst);

                        #endregion
                        #region Set Employee Name

                        EmployeeMappingList empLst = new EmployeeMappingList();
                        empLst.AddEmployee(saleData.doTbt_DraftSaleContract);

                        IEmployeeMasterHandler emphandler = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                        emphandler.EmployeeListMapping(empLst);

                        #endregion
                    }
                }

                return(saleData);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #26
0
        /// <summary>
        /// Validate belonging before save.<br />
        /// - Check require field.<br />
        /// - Check exist main department person in charge.
        /// </summary>
        /// <param name="belonging"></param>
        /// <returns></returns>
        public ActionResult MAS070_ValidateBelonging(MAS070_SaveBelonging belonging)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                //12.1	Validate require field
                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                if (false == ModelState.IsValid)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                }

                if (res.IsError)
                {
                    return(Json(res));
                }

                IEmployeeMasterHandler hand = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                ////12.2	Check exist Primary belonging
                //if (belonging.MainDepartmentFlag != null && belonging.MainDepartmentFlag == true) {
                //    List<bool?> listCheck = hand.CheckExistMainDepartmentFlag(belonging.EmpNo, belonging.BelongingID);
                //    if (listCheck.Count != 0 && listCheck[0].Value) {
                //        res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1014);
                //    }
                //}

                if (belonging.DepPersonInchargeFlag != null && belonging.DepPersonInchargeFlag == true)
                {
                    List <bool?> listCheck = hand.CheckExistMainDepartmentPersonInCharge(belonging.OfficeCode, belonging.DepartmentCode, belonging.BelongingID);
                    if (listCheck.Count != 0 && listCheck[0].Value)
                    {
                        bool isError = true;
                        if (belonging.delBelList != null)
                        {
                            foreach (View_tbm_Belonging b in belonging.delBelList)
                            {
                                if (b.OfficeCode == belonging.OfficeCode &&
                                    b.DepartmentCode == belonging.DepartmentCode &&
                                    b.DepPersonInchargeFlag == true)
                                {
                                    isError = false;
                                    break;
                                }
                            }
                        }
                        if (isError == true)
                        {
                            res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1038);
                        }
                    }
                }

                //List<bool?> listCheckBel = hand.CheckExistBelonging(belonging.OfficeCode, belonging.DepartmentCode, belonging.EmpNo, belonging.BelongingID);
                //if (listCheckBel.Count != 0 && listCheckBel[0].Value) {
                //    res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1011);
                //}

                if (!res.IsError)
                {
                    res.ResultData = "P";
                }

                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Пример #27
0
        /// <summary>
        /// Save employee.<br />
        /// - Check system suspending.<br />
        /// - Validate data.<br />
        /// - Save employee data.<br />
        /// - Save belonging data.<br />
        /// </summary>
        /// <param name="employeeInfo"></param>
        /// <returns></returns>
        public ActionResult MAS070_SaveEmployee(dsEmployeeBelonging employeeInfo)
        {
            ObjectResultData res = new ObjectResultData();

            List <tbm_Employee> resultList = null;

            try
            {
                res = checkSystemSuspending();
                if (res.IsError)
                {
                    return(Json(res));
                }

                //12.1	Validate require field
                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                if (false == ModelState.IsValid)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                }

                bool foundPrimary = false;
                foreach (var item in employeeInfo.belongingList)
                {
                    if (item.MainDepartmentFlag == true)
                    {
                        foundPrimary = true;
                    }

                    if (item.ModifyMode.Equals("NONE"))
                    {
                        continue;
                    }
                }

                if (!foundPrimary)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1042);
                }

                if (res.IsError)
                {
                    return(Json(res));
                }

                IEmployeeMasterHandler  hand = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                List <dtEmployeeDetail> emp  = hand.GetEmployeeDetail(employeeInfo.employee.EmpNo);
                // Akat K. : check exist employee number
                if (employeeInfo.employee.ModifyMode.Equals("ADD"))
                {
                    if (emp != null && emp.Count != 0)
                    {
                        if (emp[0].DeleteFlag.Value)
                        {
                            MAS070_ScreenParameter MAS070Param = GetScreenObject <MAS070_ScreenParameter>();
                            MAS070Param.updateDate      = emp[0].UpdateDate.Value;
                            MAS070Param.isReactivate    = true;
                            MAS070Param.reactivateEmpNo = employeeInfo.employee.EmpNo;
                            res.ResultData = "CONF";
                            return(Json(res));
                        }
                        else
                        {
                            res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1013);
                            return(Json(res));
                        }
                    }
                }
                else
                {
                    if (emp != null && emp.Count != 0)
                    {
                        employeeInfo.employee.PasswordWrongCount     = emp[0].PasswordWrongCount;
                        employeeInfo.employee.PasswordLastUpdateDate = emp[0].PasswordLastUpdateDate;
                        employeeInfo.employee.Status = emp[0].Status;
                    }

                    MAS070_ScreenParameter MAS070Param = GetScreenObject <MAS070_ScreenParameter>();
                    if (MAS070Param.isReactivate)
                    {
                        if (employeeInfo.employee.EmpNo.Equals(MAS070Param.reactivateEmpNo))
                        {
                            hand.DeleteAllBelonging(MAS070Param.reactivateEmpNo);
                        }
                        MAS070Param.isReactivate    = false;
                        MAS070Param.reactivateEmpNo = null;
                    }
                }

                if (employeeInfo.belongingList != null)
                {
                    foreach (View_tbm_Belonging bl in employeeInfo.belongingList)
                    {
                        if (bl.StartDate < employeeInfo.employee.StartDate ||
                            bl.EndDate < employeeInfo.employee.StartDate)
                        {
                            res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1050);
                            return(Json(res));
                        }
                        if (employeeInfo.employee.EndDate != null)
                        {
                            if (bl.StartDate > employeeInfo.employee.EndDate ||
                                bl.EndDate > employeeInfo.employee.EndDate)
                            {
                                res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1051);
                                return(Json(res));
                            }
                        }
                    }
                }

                resultList = this.SaveEmployee(employeeInfo, hand);

                if (resultList != null && resultList.Count != 0)
                {
                    res.ResultData = "P";
                }
            }
            catch (Exception ex)
            {
                res.ResultData = "NP";
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Пример #28
0
        public ActionResult CTP060_UpdateEmailContentOfNotifyEmail()
        {
            ObjectResultData        res                  = new ObjectResultData();
            IContractHandler        conHandler           = ServiceContainer.GetService <IContractHandler>() as IContractHandler;
            IRentralContractHandler rentalConHandler     = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
            IMasterHandler          masterHandler        = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;
            IEmployeeMasterHandler  empMasterHandler     = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
            IBillingMasterHandler   billingmasterhandler = ServiceContainer.GetService <IBillingMasterHandler>() as IBillingMasterHandler;
            IOfficeMasterHandler    officehandler        = ServiceContainer.GetService <IOfficeMasterHandler>() as IOfficeMasterHandler;
            IBillingHandler         billinghandler       = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;

            List <tbm_Customer>  dtCustomer;
            List <doGetTbm_Site> dtSite;
            List <tbm_Employee>  dtEmployee;
            decimal?contractFeeBeforeChange;
            decimal?ChangeContractFee;

            try
            {
                CommonUtil comUtil = new CommonUtil();
                doNotifyChangeFeeContract doNotifyEmail           = new doNotifyChangeFeeContract();
                List <tbt_ContractEmail>  updateContractEmailList = new List <tbt_ContractEmail>();

                using (TransactionScope scope = new TransactionScope())
                {
                    List <tbt_ContractEmail> contractEmailList = conHandler.GetUnsentNotifyEmail();
                    foreach (tbt_ContractEmail data in contractEmailList)
                    {
                        List <tbt_BillingBasic>  doBillingBasic  = billinghandler.GetTbt_BillingBasic(data.ContractCode, "01");
                        List <tbt_BillingTarget> doBillingTarget = billinghandler.GetTbt_BillingTarget(doBillingBasic[0].BillingTargetCode, null, null);

                        dsRentalContractData dsRentalContract = rentalConHandler.GetEntireContract(data.ContractCode, data.OCC);
                        if (dsRentalContract.dtTbt_RentalSecurityBasic[0].ReturnToOriginalFeeDate != null)
                        {
                            var operationOfficeDat = officehandler.GetTbm_Office(dsRentalContract.dtTbt_RentalContractBasic[0].OperationOfficeCode);
                            var billingOfficeDat   = officehandler.GetTbm_Office(doBillingTarget[0].BillingOfficeCode);

                            EmailTemplateUtil mailUtil = new EmailTemplateUtil(EmailTemplateName.C_EMAIL_TEMPLATE_NAME_CHANGE_FEE);
                            dtCustomer = masterHandler.GetTbm_Customer(dsRentalContract.dtTbt_RentalContractBasic[0].ContractTargetCustCode);
                            dtSite     = masterHandler.GetTbm_Site(dsRentalContract.dtTbt_RentalContractBasic[0].SiteCode);
                            dtEmployee = empMasterHandler.GetTbm_Employee(data.CreateBy);
                            contractFeeBeforeChange = rentalConHandler.GetContractFeeBeforeChange(dsRentalContract.dtTbt_RentalContractBasic[0].ContractCode, dsRentalContract.dtTbt_RentalSecurityBasic[0].OCC, dsRentalContract);

                            doNotifyEmail.ContractCode            = comUtil.ConvertContractCode(dsRentalContract.dtTbt_RentalContractBasic[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                            doNotifyEmail.ContractTargetNameEN    = dtCustomer[0].CustFullNameEN;
                            doNotifyEmail.ContractTargetNameLC    = dtCustomer[0].CustFullNameLC;
                            doNotifyEmail.SiteNameEN              = dtSite[0].SiteNameEN;
                            doNotifyEmail.SiteNameLC              = dtSite[0].SiteNameLC;
                            doNotifyEmail.ChangeDateOfContractFee = CommonUtil.TextDate(dsRentalContract.dtTbt_RentalSecurityBasic[0].ChangeImplementDate);
                            doNotifyEmail.ContractFeeBeforeChange = CommonUtil.TextNumeric(contractFeeBeforeChange);

                            if (dsRentalContract.dtTbt_RentalContractBasic[0].ContractStatus == ContractStatus.C_CONTRACT_STATUS_STOPPING)
                            {
                                ChangeContractFee = dsRentalContract.dtTbt_RentalSecurityBasic[0].ContractFeeOnStop;
                            }
                            else
                            {
                                ChangeContractFee = dsRentalContract.dtTbt_RentalSecurityBasic[0].OrderContractFee;
                            }

                            doNotifyEmail.ContractFeeAfterChange  = CommonUtil.TextNumeric(ChangeContractFee);
                            doNotifyEmail.ReturnToOriginalFeeDate = CommonUtil.TextDate(dsRentalContract.dtTbt_RentalSecurityBasic[0].ReturnToOriginalFeeDate);
                            doNotifyEmail.OperationOfficeEN       = operationOfficeDat[0].OfficeNameEN;
                            doNotifyEmail.OperationOfficeLC       = operationOfficeDat[0].OfficeNameLC;
                            doNotifyEmail.RegisterChangeEmpNameEN = dtEmployee[0].EmpFirstNameEN + ' ' + dtEmployee[0].EmpLastNameEN;
                            doNotifyEmail.RegisterChangeEmpNameLC = dtEmployee[0].EmpFirstNameLC + ' ' + dtEmployee[0].EmpLastNameLC;
                            doNotifyEmail.BillingOfficeEN         = billingOfficeDat[0].OfficeNameEN;
                            doNotifyEmail.BillingOfficeLC         = billingOfficeDat[0].OfficeNameLC;

                            var mailTemplate = mailUtil.LoadTemplate(doNotifyEmail);
                            data.EmailContent = mailTemplate.TemplateContent;

                            tbt_ContractEmail conEmailTemp = CommonUtil.CloneObject <tbt_ContractEmail, tbt_ContractEmail>(data);
                            updateContractEmailList.Add(conEmailTemp);
                        }
                    }

                    if (updateContractEmailList != null && updateContractEmailList.Count > 0)
                    {
                        conHandler.UpdateTbt_ContractEmail(updateContractEmailList);
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Пример #29
0
        /// <summary>
        /// To send notify email for change contract fee
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="BatchDate"></param>
        /// <returns></returns>
        public SECOM_AJIS.Common.Util.doBatchProcessResult SendNotifyEmailForChangeFee(string UserId, DateTime BatchDate)
        {
            SECOM_AJIS.Common.Util.doBatchProcessResult doResult = new SECOM_AJIS.Common.Util.doBatchProcessResult();
            try
            {
                ILogHandler handLog = ServiceContainer.GetService <ILogHandler>() as ILogHandler;

                //1. Get list of unsent email
                List <tbt_ContractEmail> dtTbt_ContractEmail = this.GetUnsentNotifyEmail();

                //2. For each unsent email in dtTbt_ContractEmail
                int failedItem    = 0;
                int completdeItem = 0;
                foreach (tbt_ContractEmail email in dtTbt_ContractEmail)
                {
                    //2.1 Prepare destination email
                    //2.1.1 Get employee data of destination email
                    IEmployeeMasterHandler handMaster = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                    List <tbm_Employee>    dtEmployee = handMaster.GetTbm_Employee(email.ToEmpNo);

                    //2.1.2 If dtEmployee is empty
                    if (dtEmployee.Count <= 0)
                    {
                        handLog.WriteWindowLog(EventType.C_EVENT_TYPE_ERROR, (MessageUtil.GetMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3077, email.ToEmpNo)).Message, EventID.C_EVENT_ID_NOTIFY_EMAIL_ERROR);
                        failedItem += 1;
                        continue;
                    }

                    //2.1.3 Get default email if endDate is not empty
                    String strEmailTo = (dtEmployee[0].EndDate != null) ?
                                        this.getEmailsOfDefaultDepartment() :
                                        dtEmployee[0].EmailAddress;

                    //2.2 Prepare email object for sending
                    doEmailProcess emailProc = new doEmailProcess();
                    emailProc.MailTo   = strEmailTo;
                    emailProc.MailFrom = email.EmailFrom;
                    emailProc.Subject  = email.EmailSubject;
                    emailProc.Message  = email.EmailContent;

                    //2.3 Send email
                    //2.3.1 Retry for 3 times while strStatus is still fails
                    int retry = 0;
                    do
                    {
                        try
                        {
                            ICommonHandler commonHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                            commonHand.SendMail(emailProc);
                            break;
                        }
                        catch (Exception)
                        {
                            retry += 1;
                        }
                    } while (retry < 3);

                    ICommonContractHandler comContractHand = ServiceContainer.GetService <ICommonContractHandler>() as ICommonContractHandler;
                    if (retry == 3)
                    {
                        failedItem += 1;
                        email.FailSendingCounter = (email.FailSendingCounter == null) ? 1 : email.FailSendingCounter + 1;
                        email.UpdateBy           = UserId;
                        //Update to database
                        comContractHand.UpdateTbt_ContractEmail(email);

                        //Check the number of fail for reporting error
                        if (email.FailSendingCounter >= 6 && email.FailSendingCounter % 3 == 0)
                        {
                            handLog.WriteWindowLog(EventType.C_EVENT_TYPE_ERROR, (MessageUtil.GetMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3078, strEmailTo)).Message, EventID.C_EVENT_ID_NOTIFY_EMAIL_ERROR);
                        }
                    }
                    else
                    {
                        completdeItem += 1;

                        //Delete sent email
                        comContractHand.DeleteTbt_ContractEmail(email.ContractEmailID, UserId);
                    }
                }

                //3. Prepare process result for returning
                doResult.Result   = FlagType.C_FLAG_ON;
                doResult.Total    = dtTbt_ContractEmail.Count;
                doResult.Complete = completdeItem;
                doResult.Failed   = failedItem;
            }
            catch (Exception)
            {
                throw;
            }
            return(doResult);
        }