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
            }
        }
Ejemplo n.º 2
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);
                }
            }
        }