private void BindGrid(string strdatetimeid) { try { Controllers.frm33Controller oController = new Controllers.frm33Controller(); DataTable dtNonAmigoData = oController.NonAmigo_BankTR(strDateTimeID); if (dtNonAmigoData.Rows.Count > 0) { dgvList.DataSource = dtNonAmigoData; ResetHeader(); } 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; } lblNoOfDeposit.Text = dgvList.Rows.Count.ToString(); } 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 BtnMoveToAmigo_Click(object sender, EventArgs e) { #region CheckSelectedRow int status = 0; int index = 0; int foundindex = 0; foreach (DataGridViewRow row in dgvList.Rows) { if (row.Cells["colCheck"].Value == null ? false : bool.Parse(row.Cells["colCheck"].Value.ToString())) { if (status >= 1) //if already found { status = 2; } else //first selected { status = 1; foundindex = index; } } index++; } #endregion if (status == 0) //if no row selected { MetroMessageBox.Show(this, "\n" + Messages.ConfirmationOfNonAmigo.NoSelectedRow, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { int intseqno = 0; string strbankno = ""; int selectedcount = 0; Controllers.frm33Controller oController = new Controllers.frm33Controller(); DataTable dtConvertNonAmigoAmigo = new DataTable(); dtConvertNonAmigoAmigo.Columns.Add("SEQNO"); dtConvertNonAmigoAmigo.Columns.Add("bankAccountName"); for (int i = 0; i < dgvList.Rows.Count; i++) { bool value = bool.Parse(dgvList[0, i].Value == null ? "false" : dgvList[0, i].Value.ToString()); if (value == true) { intseqno = dgvList.Rows[i].Cells["colNo"].Value.ToString() == "" ? 0 : int.Parse(dgvList.Rows[i].Cells["colNo"].Value.ToString()); strbankno = dgvList.Rows[i].Cells["CUSTOMER_NAME"].Value.ToString(); DataRow dr = dtConvertNonAmigoAmigo.NewRow(); dr["SEQNO"] = intseqno; dr["bankAccountName"] = strbankno; dtConvertNonAmigoAmigo.Rows.Add(dr); selectedcount++; } } dynamic result = oController.ConvertNonAmigoToAmigo(dtConvertNonAmigoAmigo); if (result.Status == "1") // success { BindGrid(strDateTimeID); MetroMessageBox.Show(this, "\n" + Messages.ConfirmationOfNonAmigo.MovedToAmigo, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (result.Message != 0) // no customer found { if (result.Message > 1 || dtConvertNonAmigoAmigo.Rows.Count > 1) //multi case { string msg = Messages.ConfirmationOfNonAmigo.CustomerNotFoundMultiCase; msg = msg.Insert(3, " " + selectedcount.ToString() + " "); string failed = result.Message; msg = msg.Insert(0, (selectedcount - int.Parse(failed)) + " "); MetroMessageBox.Show(this, "\n" + msg, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); BindGrid(strDateTimeID); } else { MetroMessageBox.Show(this, "\n" + Messages.ConfirmationOfNonAmigo.CustomerNotFound, "Move Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MetroMessageBox.Show(this, "\n" + Messages.General.ThereWasAnError, "Move Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (System.TimeoutException) { MetroMessageBox.Show(this, "\n" + Messages.General.ServerTimeOut, "Move Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.Net.WebException) { MetroMessageBox.Show(this, "\n" + Messages.General.NoConnection, "Move Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { Utility.WriteErrorLog(ex.Message, ex, false); MetroMessageBox.Show(this, "\n" + Messages.General.ThereWasAnError, "Move Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }