private void BindGrid() { string strCompanyName = txtCompanyName.Text.Trim(); string strBillToCompanyName = txtBillToCompanyName.Text.Trim(); string strAccountName = txtAccountName.Text.Trim(); string strCompanyNameNumberBox = txtCompanyNumberBox.Text.Trim(); string strCompanyNameReading = txtCompanyNameReading.Text.Trim(); DataTable dt = new DataTable(); Controllers.frm38Controller oController = new Controllers.frm38Controller(); try { DataTable dtCustomerMaster = oController.getCustomerList(strCompanyName, strBillToCompanyName, strAccountName, strCompanyNameNumberBox, strCompanyNameReading, Utility.Id, Utility.Password); if (dtCustomerMaster.Rows.Count > 0) { dgvList.DataSource = dtCustomerMaster; } else { //clear data except headers var empty = dgvList.DataSource as DataTable; try { empty.Rows.Clear(); } catch (Exception)//handle null result on first search { } dgvList.DataSource = empty; } } catch (System.TimeoutException) { MetroMessageBox.Show(this, "\n" + Messages.General.ServerTimeOut, "Search Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.Net.WebException) { MetroMessageBox.Show(this, "\n" + Messages.General.NoConnection, "Search Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { Utility.WriteErrorLog(ex.Message, ex, false); MetroMessageBox.Show(this, "\n" + Messages.General.ThereWasAnError, "Search Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnChange_Click_1(object sender, EventArgs e) { DataTable dt = getFormat_UpdateCustomer(); if (this.checkSelectedRow()) { try { for (int i = 0; i < dgvList.Rows.Count; i++) { bool status = dgvList.Rows[i].Cells["colCheck"].Value == null ? false : bool.Parse(dgvList.Rows[i].Cells["colCheck"].Value.ToString()); string strBillingInterval = dgvList.Rows[i].Cells["colBILL_BILLING_INTERVAL"].Value.ToString(); string strBillingDepositRules = dgvList.Rows[i].Cells["colBILL_DEPOSIT_RULES"].Value.ToString(); if (status == true) { if (strBillingInterval != "" && strBillingDepositRules != "") { #region BillingInterval int intBilllingInterval = 0; if (strBillingInterval == "月額") { intBilllingInterval = 1; } else if (strBillingInterval == "四半期") { intBilllingInterval = 2; } else if (strBillingInterval == "半期") { intBilllingInterval = 3; } else if (strBillingInterval == "年額") { intBilllingInterval = 4; } else { intBilllingInterval = int.Parse(strBillingInterval); } #endregion #region BillingDepositRules int intBillingDepositRules = 0; if (strBillingDepositRules == "翌月") { intBillingDepositRules = 0; } else if (strBillingDepositRules == "当月") { intBillingDepositRules = 1; } else if (strBillingDepositRules == "翌々月月頭") { intBillingDepositRules = 2; } else { intBillingDepositRules = int.Parse(strBillingDepositRules); } #endregion DataRow dr = dt.NewRow(); dr["BILL_BANK_ACCOUNT_NAME-1"] = dgvList.Rows[i].Cells["colBILL_BANK_ACCOUNT_NAME_1"].Value.ToString().Trim(); dr["BILL_BANK_ACCOUNT_NAME-2"] = dgvList.Rows[i].Cells["colBILL_BANK_ACCOUNT_NAME_2"].Value.ToString().Trim(); dr["BILL_BANK_ACCOUNT_NAME-3"] = dgvList.Rows[i].Cells["colBILL_BANK_ACCOUNT_NAME_3"].Value.ToString().Trim(); dr["BILL_BANK_ACCOUNT_NAME-4"] = dgvList.Rows[i].Cells["colBILL_BANK_ACCOUNT_NAME_4"].Value.ToString().Trim(); dr["BILL_BILLING_INTERVAL"] = intBilllingInterval; dr["BILL_DEPOSIT_RULES"] = intBillingDepositRules; dr["BILL_TRANSFER_FEE"] = decimal.Parse(dgvList.Rows[i].Cells["colBILL_TRANSFER_FEE"].Value.ToString()); dr["BILL_EXPENSES"] = decimal.Parse(dgvList.Rows[i].Cells["colBILL_EXPENSES"].Value.ToString()); dr["COMPANY_NO_BOX"] = dgvList.Rows[i].Cells["colCOMPANY_NO_BOX"].Value.ToString().Trim(); dr["TRANSACTION_TYPE"] = dgvList.Rows[i].Cells["colTRANSACTION_TYPE"].Value.ToString().Trim(); dr["EFFECTIVE_DATE"] = dgvList.Rows[i].Cells["colEFFECTIVE_DATE"].Value.ToString().Trim(); dr["REQ_SEQ"] = dgvList.Rows[i].Cells["colREQ_SEQ"].Value.ToString().Trim(); dr["NCS_CUSTOMER_CODE"] = dgvList.Rows[i].Cells["colNCS_CUSTOMER_CODE"].Value.ToString().Trim(); dt.Rows.Add(dr); } } } Controllers.frm38Controller o38 = new Controllers.frm38Controller(); bool statuss = o38.UpdateCustomer(dt); if (statuss) { BindGrid(); MetroMessageBox.Show(this, "\n" + Messages.UpdateCUSTOMER_MASTER.RecordUpdated, "Record updated", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MetroMessageBox.Show(this, "\n" + Messages.General.ThereWasAnError, "Update Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (System.TimeoutException) { MetroMessageBox.Show(this, "\n" + Messages.General.ServerTimeOut, "Update Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.Net.WebException) { MetroMessageBox.Show(this, "\n" + Messages.General.NoConnection, "Update Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { Utility.WriteErrorLog(ex.Message, ex, false); MetroMessageBox.Show(this, "\n" + Messages.General.ThereWasAnError, "Update Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MetroMessageBox.Show(this, "\n" + Messages.UpdateCUSTOMER_MASTER.NoSelectedRow, "Update Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }