public MetaResponse UpdateCustomerMasterMaintenances(string ClientCertificateList)
        {
            DataTable dgvList = Utility.Utility_Component.JsonToDt(ClientCertificateList);

            for (int i = 0; i < dgvList.Rows.Count; i++)
            {
                BOL_CUSTOMER_MASTER     oCUSTOMER_MMASTER    = new BOL_CUSTOMER_MASTER();
                BOL_BANK_ACCOUNT_MASTER oBANK_ACCOUNT_MASTER = new BOL_BANK_ACCOUNT_MASTER();
                oCUSTOMER_MMASTER    = Cast_CUSTOMER_MASTER(dgvList.Rows[i]);
                oBANK_ACCOUNT_MASTER = Cast_BANK_ACCOUNT_MASTER(dgvList.Rows[i]);

                switch (dgvList.Rows[i]["MK"].ToString())
                {
                case "M":
                    HandleModify(oCUSTOMER_MMASTER, oBANK_ACCOUNT_MASTER, "M", dgvList.Rows[i]);
                    break;

                default:
                    break;
                }
            }

            response.Data = Utility.Utility_Component.DtToJSon(dgvList, "CustomerMaster Update");
            timer.Stop();
            response.Meta.Duration = timer.Elapsed.TotalMilliseconds;
            return(response);
        }
        public bool IsAlreadyUpdated(BOL_BANK_ACCOUNT_MASTER oBANK_ACCOUNT_MASTER, out string strMsg)
        {
            ConnectionMaster oMaster = new ConnectionMaster(strConnectionString, strAlreadyUpdate);

            oMaster.crudCommand.Parameters.Add(new SqlParameter("@COMPANY_NO_BOX", oBANK_ACCOUNT_MASTER.COMPANY_NO_BOX));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@REQ_SEQ", oBANK_ACCOUNT_MASTER.REQ_SEQ));
            oMaster.ExcuteQuery(4, out strMsg);

            int count;

            try
            {
                count = int.Parse(oMaster.dtExcuted.Rows[0][0].ToString());
            }
            catch (Exception)
            {
                count = 0;
            }

            if (count <= 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void HandleModify(BOL_CUSTOMER_MASTER oCUSTOMER_MASTER, BOL_BANK_ACCOUNT_MASTER oBANK_ACCOUNT_MASTER, string OPERATION, DataRow row)
        {
            string          strMsg = "";
            CUSTOMER_MASTER DAL_CUSTOMER_MASTER = new CUSTOMER_MASTER(con);

            using (TransactionScope dbTxn = new TransactionScope())
            {
                //check condition
                if (!DAL_CUSTOMER_MASTER.IsAlreadyUpdate(oCUSTOMER_MASTER, out strMsg))     // IF updated_at is not already modified
                {
                    DAL_CUSTOMER_MASTER.CustomerMasterUpdate(oCUSTOMER_MASTER, CURRENT_DATETIME, CURRENT_USER, out strMsg);

                    if (!string.IsNullOrEmpty(strMsg))
                    {
                        dbTxn.Dispose();
                        ResponseUtility.ReturnFailMessage(row);
                        return;
                    }
                }
                else
                {
                    //already use in another process
                    dbTxn.Dispose();
                    ResponseUtility.ReturnFailMessage(row);
                    return;
                }

                #region UPDATE BANK_ACCOUNT_MASTER
                BANK_ACCOUNT_MASTER DAL_BANK_ACCOUNT_MASTER = new BANK_ACCOUNT_MASTER(con);
                if (!DAL_BANK_ACCOUNT_MASTER.IsAlreadyUpdated(oBANK_ACCOUNT_MASTER, out strMsg))     // If updated_at is not already modified
                {
                    //insert the record
                    DAL_BANK_ACCOUNT_MASTER.BankAccountMasterUpdate(oBANK_ACCOUNT_MASTER, CURRENT_DATETIME, CURRENT_USER, out strMsg);
                }
                else
                {
                    dbTxn.Dispose();
                    ResponseUtility.ReturnFailMessage(row);
                    return;
                }

                //return message and MK value
                if (String.IsNullOrEmpty(strMsg))     //success
                {
                    dbTxn.Complete();
                    string S = Convert.ToDateTime(oCUSTOMER_MASTER.ORG_EFFECTIVE_DATE).ToString("yyyy/MM/dd");
                    row["EFFECTIVE_DATE"]     = Convert.ToDateTime(oCUSTOMER_MASTER.EFFECTIVE_DATE).ToString("yyyy/MM/dd");
                    row["ORG_EFFECTIVE_DATE"] = Convert.ToDateTime(oCUSTOMER_MASTER.EFFECTIVE_DATE).ToString("yyyy/MM/dd");
                    ResponseUtility.ReturnSuccessMessage(row, UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER);
                }
                else     //failed
                {
                    dbTxn.Dispose();
                    ResponseUtility.ReturnFailMessage(row);
                }
                #endregion
            }
        }
        public void Update(BOL_BANK_ACCOUNT_MASTER BANK_ACCOUNT, out string strMsg)
        {
            ConnectionMaster oMaster = new ConnectionMaster(strConnectionString, strUpdate);

            oMaster.crudCommand.Parameters.Add(new SqlParameter("@COMPANY_NO_BOX", BANK_ACCOUNT.COMPANY_NO_BOX));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@REQ_SEQ", BANK_ACCOUNT.REQ_SEQ));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@BILL_BANK_ACCOUNT_NAME_1", BANK_ACCOUNT.BILL_BANK_ACCOUNT_NAME_1));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@BILL_BANK_ACCOUNT_NAME_2", BANK_ACCOUNT.BILL_BANK_ACCOUNT_NAME_2));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@BILL_BANK_ACCOUNT_NAME_3", BANK_ACCOUNT.BILL_BANK_ACCOUNT_NAME_3));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@BILL_BANK_ACCOUNT_NAME_4", BANK_ACCOUNT.BILL_BANK_ACCOUNT_NAME_4));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@UPDATED_AT", BANK_ACCOUNT.UPDATED_AT));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@UPDATED_BY", BANK_ACCOUNT.UPDATED_BY));
            oMaster.ExcuteQuery(2, out strMsg);
        }
        public void BankAccountMasterUpdate(BOL_BANK_ACCOUNT_MASTER oCUSTOMER_MASTER, string CURRENT_DATETIME, string CURRENT_USER, out String strMsg)
        {
            ConnectionMaster oMaster = new ConnectionMaster(strConnectionString, strBankAccountMasterUpdate);

            oMaster.crudCommand.Parameters.Add(new SqlParameter("@COMPANY_NO_BOX", oCUSTOMER_MASTER.COMPANY_NO_BOX != null ? oCUSTOMER_MASTER.COMPANY_NO_BOX : (object)DBNull.Value));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@REQ_SEQ", oCUSTOMER_MASTER.REQ_SEQ.ToString() != null ? oCUSTOMER_MASTER.REQ_SEQ : (object)DBNull.Value));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@BILL_BANK_ACCOUNT_NAME_1", oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NAME_1 != null ? oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NAME_1 : (object)DBNull.Value));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@BILL_BANK_ACCOUNT_NAME_2", oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NAME_2 != null ? oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NAME_2 : (object)DBNull.Value));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@BILL_BANK_ACCOUNT_NAME_3", oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NAME_3 != null ? oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NAME_3 : (object)DBNull.Value));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@BILL_BANK_ACCOUNT_NAME_4", oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NAME_4 != null ? oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NAME_4 : (object)DBNull.Value));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@BILL_BANK_ACCOUNT_NUMBER_1", oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NUMBER_1 != null ? oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NUMBER_1 : (object)DBNull.Value));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@BILL_BANK_ACCOUNT_NUMBER_2", oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NUMBER_2 != null ? oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NUMBER_2 : (object)DBNull.Value));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@BILL_BANK_ACCOUNT_NUMBER_3", oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NUMBER_3 != null ? oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NUMBER_3 : (object)DBNull.Value));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@BILL_BANK_ACCOUNT_NUMBER_4", oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NUMBER_4 != null ? oCUSTOMER_MASTER.BILL_BANK_ACCOUNT_NUMBER_4 : (object)DBNull.Value));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@CURRENT_DATETIME", CURRENT_DATETIME));
            oMaster.crudCommand.Parameters.Add(new SqlParameter("@CURRENT_USER", CURRENT_USER));

            oMaster.ExcuteQuery(2, out strMsg);
        }
        private BOL_BANK_ACCOUNT_MASTER Cast_BANK_ACCOUNT_MASTER(DataRow row)
        {
            BOL_BANK_ACCOUNT_MASTER oBANK_ACCOUNT_MASTER = new BOL_BANK_ACCOUNT_MASTER();

            oBANK_ACCOUNT_MASTER.COMPANY_NO_BOX             = row["COMPANY_NO_BOX"].ToString().Trim();
            oBANK_ACCOUNT_MASTER.REQ_SEQ                    = Utility_Component.dtColumnToInt(row["REQ_SEQ"].ToString().Trim());
            oBANK_ACCOUNT_MASTER.BILL_BANK_ACCOUNT_NAME_1   = row["BILL_BANK_ACCOUNT_NAME-1"].ToString().Trim();
            oBANK_ACCOUNT_MASTER.BILL_BANK_ACCOUNT_NAME_2   = row["BILL_BANK_ACCOUNT_NAME-2"].ToString().Trim();
            oBANK_ACCOUNT_MASTER.BILL_BANK_ACCOUNT_NAME_3   = row["BILL_BANK_ACCOUNT_NAME-3"].ToString().Trim();
            oBANK_ACCOUNT_MASTER.BILL_BANK_ACCOUNT_NAME_4   = row["BILL_BANK_ACCOUNT_NAME-4"].ToString().Trim();
            oBANK_ACCOUNT_MASTER.BILL_BANK_ACCOUNT_NUMBER_1 = row["BILL_BANK_ACCOUNT_NUMBER-1"].ToString().Trim();
            oBANK_ACCOUNT_MASTER.BILL_BANK_ACCOUNT_NUMBER_2 = row["BILL_BANK_ACCOUNT_NUMBER-2"].ToString().Trim();
            oBANK_ACCOUNT_MASTER.BILL_BANK_ACCOUNT_NUMBER_3 = row["BILL_BANK_ACCOUNT_NUMBER-3"].ToString().Trim();
            oBANK_ACCOUNT_MASTER.BILL_BANK_ACCOUNT_NUMBER_4 = row["BILL_BANK_ACCOUNT_NUMBER-4"].ToString();
            oBANK_ACCOUNT_MASTER.UPDATED_AT                 = row["UPDATED_AT"].ToString().Length >= 1 ? row["UPDATED_AT"].ToString() : null;
            oBANK_ACCOUNT_MASTER.UPDATED_AT_RAW             = row["UPDATED_AT_RAW"].ToString() == "" ? null : row["UPDATED_AT_RAW"].ToString();
            oBANK_ACCOUNT_MASTER.UPDATED_BY                 = row["UPDATED_BY"].ToString().Length >= 1 ? row["UPDATED_BY"].ToString() : null;
            return(oBANK_ACCOUNT_MASTER);
        }
Exemplo n.º 7
0
        public Response UpdateCustomer(string Customers)
        {
            using (TransactionScope dbTxn = new TransactionScope())
            {
                try
                {
                    string    strMessage = "";
                    DataTable dgvList    = Utility.Utility_Component.JsonToDt(Customers);
                    if (dgvList.Rows.Count > 0)
                    {
                        for (int i = 0; i < dgvList.Rows.Count; i++)
                        {
                            BOL_CUSTOMER_MASTER B_Customer = new BOL_CUSTOMER_MASTER();
                            B_Customer.COMPANY_NO_BOX        = (dgvList.Rows[i]["COMPANY_NO_BOX"] != null ? dgvList.Rows[i]["COMPANY_NO_BOX"].ToString() : "");
                            B_Customer.TRANSACTION_TYPE      = Utility.Utility_Component.dtColumnToInt((dgvList.Rows[i]["TRANSACTION_TYPE"] != null ? dgvList.Rows[i]["TRANSACTION_TYPE"].ToString() : ""));
                            B_Customer.NCS_CUSTOMER_CODE     = (dgvList.Rows[i]["NCS_CUSTOMER_CODE"] != null ? dgvList.Rows[i]["NCS_CUSTOMER_CODE"].ToString() : "");
                            B_Customer.EFFECTIVE_DATE        = DateTime.Parse(dgvList.Rows[i]["EFFECTIVE_DATE"] != null ? dgvList.Rows[i]["EFFECTIVE_DATE"].ToString() : "");
                            B_Customer.BILL_BILLING_INTERVAL = Utility.Utility_Component.dtColumnToInt((dgvList.Rows[i]["BILL_BILLING_INTERVAL"] != null ? dgvList.Rows[i]["BILL_BILLING_INTERVAL"].ToString() : ""));
                            B_Customer.BILL_DEPOSIT_RULES    = Utility.Utility_Component.dtColumnToInt((dgvList.Rows[i]["BILL_DEPOSIT_RULES"] != null ? dgvList.Rows[i]["BILL_DEPOSIT_RULES"].ToString() : ""));
                            B_Customer.BILL_TRANSFER_FEE     = Utility.Utility_Component.dtColumnToDecimal((dgvList.Rows[i]["BILL_TRANSFER_FEE"] != null ? dgvList.Rows[i]["BILL_TRANSFER_FEE"].ToString() : ""));
                            B_Customer.BILL_EXPENSES         = Utility.Utility_Component.dtColumnToDecimal(dgvList.Rows[i]["BILL_EXPENSES"] != null ? dgvList.Rows[i]["BILL_EXPENSES"].ToString() : "");
                            B_Customer.REQ_SEQ    = Utility.Utility_Component.dtColumnToInt((dgvList.Rows[i]["REQ_SEQ"] != null ? dgvList.Rows[i]["REQ_SEQ"].ToString() : ""));
                            B_Customer.UPDATED_AT = CURRENT_DATETIME;
                            B_Customer.UPDATED_BY = CURRENT_USER;
                            CUSTOMER_MASTER DAL_Customer = new CUSTOMER_MASTER(con);
                            DAL_Customer.Update(B_Customer, out strMessage);

                            if (!string.IsNullOrEmpty(strMessage))
                            {
                                break;
                            }

                            BOL_BANK_ACCOUNT_MASTER B_BankAccounts = new BOL_BANK_ACCOUNT_MASTER();
                            B_BankAccounts.COMPANY_NO_BOX           = B_Customer.COMPANY_NO_BOX;
                            B_BankAccounts.REQ_SEQ                  = B_Customer.REQ_SEQ;
                            B_BankAccounts.BILL_BANK_ACCOUNT_NAME_1 = (dgvList.Rows[i]["BILL_BANK_ACCOUNT_NAME-1"] != null ? dgvList.Rows[i]["BILL_BANK_ACCOUNT_NAME-1"].ToString() : "");
                            B_BankAccounts.BILL_BANK_ACCOUNT_NAME_2 = (dgvList.Rows[i]["BILL_BANK_ACCOUNT_NAME-2"] != null ? dgvList.Rows[i]["BILL_BANK_ACCOUNT_NAME-2"].ToString() : "");
                            B_BankAccounts.BILL_BANK_ACCOUNT_NAME_3 = (dgvList.Rows[i]["BILL_BANK_ACCOUNT_NAME-3"] != null ? dgvList.Rows[i]["BILL_BANK_ACCOUNT_NAME-3"].ToString() : "");
                            B_BankAccounts.BILL_BANK_ACCOUNT_NAME_4 = (dgvList.Rows[i]["BILL_BANK_ACCOUNT_NAME-4"] != null ? dgvList.Rows[i]["BILL_BANK_ACCOUNT_NAME-4"].ToString() : "");
                            B_BankAccounts.UPDATED_AT               = CURRENT_DATETIME;
                            B_BankAccounts.UPDATED_BY               = CURRENT_USER;

                            BANK_ACCOUNT_MASTER DAL_BankAccount = new BANK_ACCOUNT_MASTER(con);
                            DAL_BankAccount.Update(B_BankAccounts, out strMessage);

                            if (!string.IsNullOrEmpty(strMessage))
                            {
                                break;
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(strMessage))
                    {
                        dbTxn.Complete();
                        response.Status  = 1;
                        response.Message = "Customer updated";
                    }
                    else
                    {
                        response.Status  = 0;
                        response.Message = strMessage;
                    }

                    return(response);
                }
                catch (Exception ex)
                {
                    dbTxn.Dispose();
                    response.Status  = 0;
                    response.Message = ex.Message + "\n" + ex.StackTrace;
                    return(response);
                }
            }
        }