Пример #1
0
        /// <summary>
        /// Retrieve billing client data
        /// </summary>
        /// <param name="BillingClientCodeSearch"></param>
        /// <returns></returns>
        public ActionResult MAS020_Retrieve(string BillingClientCodeSearch)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            try
            {
                if (CommonUtil.IsNullOrEmpty(BillingClientCodeSearch))
                {
                    string lblBillingClientCode = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_MASTER, "MAS020", "lblBillingClientCode");
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    res.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                        "MAS020",
                                        MessageUtil.MODULE_MASTER,
                                        MessageUtil.MessageList.MSG1045,
                                        new string[] { lblBillingClientCode },
                                        new string[] { "BillingClientCodeSearch" });
                    return(Json(res));
                }
                else
                {
                    CommonUtil cm = new CommonUtil();
                    string     BillingClientCode_LongFormat = cm.ConvertBillingClientCode(BillingClientCodeSearch, CommonUtil.CONVERT_TYPE.TO_LONG);

                    IBillingClientMasterHandler hand = ServiceContainer.GetService <IBillingClientMasterHandler>() as IBillingClientMasterHandler;
                    List <tbm_BillingClient>    list = hand.GetTbm_BillingClient(BillingClientCode_LongFormat);

                    tbm_BillingClient data = null;
                    if (list.Count > 0)
                    {
                        data = list[0];
                        if (data.DeleteFlag == true)
                        {
                            res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION_OK;
                            res.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                                "MAS020",
                                                MessageUtil.MODULE_MASTER,
                                                MessageUtil.MessageList.MSG1058,
                                                null,
                                                new string[] { "BillingClientCodeSearch" });
                            return(Json(res));
                        }
                        MAS020_ScreenParameter MAS020Param = GetScreenObject <MAS020_ScreenParameter>();
                        MAS020Param.currentBillingClient = data;
                    }
                    else
                    {
                        res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION_OK;
                        res.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                            "MAS020",
                                            MessageUtil.MODULE_MASTER,
                                            MessageUtil.MessageList.MSG1058,
                                            null,
                                            new string[] { "BillingClientCodeSearch" });
                    }
                    res.ResultData = data;
                    return(Json(res));
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Пример #2
0
        /// <summary>
        /// Update billing client data
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public ActionResult MAS020_Update(MAS020_BillingClientData data)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            try
            {
                ICommonHandler commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                if (commonHandler.IsSystemSuspending())
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                    return(Json(res));
                }

                if (!(CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_BILLING_CLIENT_INFO, FunctionID.C_FUNC_ID_VIEW) == true ||
                      CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_BILLING_CLIENT_INFO, FunctionID.C_FUNC_ID_EDIT) == true ||
                      CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_BILLING_CLIENT_INFO, FunctionID.C_FUNC_ID_DEL) == true
                      ))
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                    return(Json(res));
                }
                data.DeleteFlag = (data.DeleteFlag == null ? false : true);

                if (!(bool)data.DeleteFlag)
                {
                    // Check required field.
                    if (ModelState.IsValid == false)
                    {
                        ValidatorUtil.BuildErrorMessage(res, this);
                        if (res.IsError)
                        {
                            return(Json(res));
                        }
                    }

                    //Add by Jutarat A. on 25122013
                    if (data.CustTypeCode == CustomerType.C_CUST_TYPE_JURISTIC ||
                        data.CustTypeCode == CustomerType.C_CUST_TYPE_ASSOCIATION ||
                        data.CustTypeCode == CustomerType.C_CUST_TYPE_PUBLIC_OFFICE)
                    {
                        ValidatorUtil validator = new ValidatorUtil();

                        if (CommonUtil.IsNullOrEmpty(data.IDNo))
                        {
                            validator.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                                      "MAS020",
                                                      MessageUtil.MODULE_COMMON,
                                                      MessageUtil.MessageList.MSG0007,
                                                      "IDNo",
                                                      "lblIDNoTaxIDNo",
                                                      "IDNo");
                        }

                        //if (CommonUtil.IsNullOrEmpty(data.BranchNo))
                        //    validator.AddErrorMessage(MessageUtil.MODULE_MASTER,
                        //                              "MAS020",
                        //                              MessageUtil.MODULE_COMMON,
                        //                              MessageUtil.MessageList.MSG0007,
                        //                              "BranchNo",
                        //                              "lblBranchNo",
                        //                              "BranchNo");

                        //if (CommonUtil.IsNullOrEmpty(data.BranchNameEN))
                        //    validator.AddErrorMessage(MessageUtil.MODULE_MASTER,
                        //                              "MAS020",
                        //                              MessageUtil.MODULE_COMMON,
                        //                              MessageUtil.MessageList.MSG0007,
                        //                              "BranchNameEN",
                        //                              "lblBranchNameEN",
                        //                              "BranchNameEN");

                        //if (CommonUtil.IsNullOrEmpty(data.BranchNameLC))
                        //    validator.AddErrorMessage(MessageUtil.MODULE_MASTER,
                        //                              "MAS020",
                        //                              MessageUtil.MODULE_COMMON,
                        //                              MessageUtil.MessageList.MSG0007,
                        //                              "BranchNameLC",
                        //                              "lblBranchNameLC",
                        //                              "BranchNameLC");

                        ValidatorUtil.BuildErrorMessage(res, validator);
                        if (res.IsError)
                        {
                            return(Json(res));
                        }
                    }
                    //End Add

                    if (data.CustTypeCode == CustomerType.C_CUST_TYPE_JURISTIC)
                    {
                        if (CommonUtil.IsNullOrEmpty(data.CompanyTypeCode))
                        {
                            string lblCompanyType = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_MASTER, "MAS020", "lblCompanyType");
                            res.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                                "MAS020",
                                                MessageUtil.MODULE_COMMON,
                                                MessageUtil.MessageList.MSG0007,
                                                new string[] { lblCompanyType },
                                                new string[] { "CompanyTypeCode" });
                            return(Json(res));
                        }
                    }

                    //Add by Jutarat A. on 25122013
                    if (data.CustTypeCode == CustomerType.C_CUST_TYPE_JURISTIC ||
                        data.CustTypeCode == CustomerType.C_CUST_TYPE_ASSOCIATION ||
                        data.CustTypeCode == CustomerType.C_CUST_TYPE_PUBLIC_OFFICE)
                    {
                        if (CommonUtil.IsNullOrEmpty(data.IDNo) == false && data.IDNo.Length != 15)
                        {
                            res.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                                "MAS020",
                                                MessageUtil.MODULE_MASTER,
                                                MessageUtil.MessageList.MSG1060,
                                                null,
                                                new string[] { "IDNo" });
                            res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                            return(Json(res));
                        }

                        if (CommonUtil.IsNullOrEmpty(data.BranchNo) == false && data.BranchNo.Length != 5)
                        {
                            res.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                                "MAS020",
                                                MessageUtil.MODULE_MASTER,
                                                MessageUtil.MessageList.MSG1061,
                                                null,
                                                new string[] { "BranchNo" });
                            res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                            return(Json(res));
                        }

                        if (data.BranchType == "2" && data.BranchNo == "00000")
                        {
                            res.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                                "MAS020",
                                                MessageUtil.MODULE_MASTER,
                                                MessageUtil.MessageList.MSG1062,
                                                null,
                                                new string[] { "BranchNo" });
                            res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                            return(Json(res));
                        }
                    }
                    //End Add
                }

                MAS020_ScreenParameter param = GetScreenObject <MAS020_ScreenParameter>();

                tbm_BillingClient curBillingClient = param.currentBillingClient;

                IBillingClientMasterHandler hand             = ServiceContainer.GetService <IBillingClientMasterHandler>() as IBillingClientMasterHandler;
                List <tbm_BillingClient>    oldBillingClient = hand.GetTbm_BillingClient(curBillingClient.BillingClientCode);

                if (!(oldBillingClient.Count > 0) || DateTime.Compare(oldBillingClient[0].UpdateDate.Value, curBillingClient.UpdateDate.Value) != 0)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019);
                    return(Json(res));
                }


                //string BillingClientCode = curBillingClient.BillingClientCode ;
                curBillingClient = data;

                curBillingClient.BillingClientCode = param.currentBillingClient.BillingClientCode;
                curBillingClient.CreateBy          = param.currentBillingClient.CreateBy;
                curBillingClient.CreateDate        = param.currentBillingClient.CreateDate;
                curBillingClient.UpdateBy          = CommonUtil.dsTransData.dtUserData.EmpNo;
                curBillingClient.UpdateDate        = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;

                List <tbm_BillingClient> list = hand.UpdateBillingClient(curBillingClient);

                string result = (list.Count > 0) ? "1" : null;

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