private void fillGrid() { if (selectedIds.Count == 0) { return; } InsuranceInfoBS bs = new InsuranceInfoBS(); InsuranceInfoData data = bs.getByIds(selectedIds); DataRowCollection rows = data.Tables[0].Rows; for (int i = 0; i < rows.Count; i++) { long id = (long)rows[i][InsuranceInfoData.id_FIELD]; Object[] row = new object[8]; row[0] = i + 1; row[1] = ""; row[2] = ""; row[3] = rows[i][InsuranceInfoData.mobileNumber_FIELD]; row[4] = rows[i][InsuranceInfoData.name_FIELD]; row[5] = rows[i][InsuranceInfoData.family_FIELD]; row[6] = rows[i][InsuranceInfoData.insuranceNumber_FIELD]; row[7] = rows[i][InsuranceInfoData.id_FIELD] = id; dataGridView1.Rows.Add(row); } }
private void btnDo_Click(object sender, EventArgs e) { txtInsuranceNumber.Text = txtInsuranceNumber.Text.Trim(); if (txtInsuranceNumber.Text.Length <= 0) { return; } string cond = "insuranceNumber='" + txtInsuranceNumber.Text + "' and cancel=1"; ViewInsuranceInfoBS bs = new ViewInsuranceInfoBS(); ViewInsuranceInfoData dataset = bs.load(cond); if (dataset.Tables[0].Rows.Count <= 0) { MessageBox.Show("پیدا نشد"); return; } int n = new InsuranceInfoBS().recover(int.Parse(dataset.Tables[0].Rows[0][InsuranceInfoData.id_FIELD].ToString())); if (n <= 0) { MessageBox.Show("امکان بازگرداندن این رکورد حذف شده نیست"); } else { MessageBox.Show("رکورد مورد نظر بازگردانده شد"); } }
private void btnUpdate_Click(object sender, EventArgs e) { if (!insuranceNumberCheck()) { return; } InsuranceInfoBS isb = new InsuranceInfoBS(); string oldVal = _gridTools.getCurrentRowValue(InsuranceInfoData.insuranceNumber_FIELD).ToString(); string newValue = txtInsuranceNumber.Text.Trim(); isb.updateInsuranceNumber(oldVal, newValue); string insuranceNumber = txtInsuranceNumber.Text.Trim(); fillGrid(_condition); int addedRow = searcInGrid(insuranceNumber); if (addedRow == -1) { dataGridView1.Rows[dataGridView1.RowCount - 1].Selected = true; } else { dataGridView1.Rows[addedRow].Selected = true; } // frmMain.MainForm.fillGrid(); MessageBox.Show("به روز رسانی انجام شد"); }
private void checkForLogging(int insuranceInfoId, string endDateStr) { InsuranceInfoBS insBS = new InsuranceInfoBS(); InsuranceInfoData insData = insBS.getById(insuranceInfoId); if (insData.Tables[0].Rows.Count > 0) { Boolean haveDid = Boolean.Parse(insData.Tables[0].Rows[0][InsuranceInfoData.haveDid_FIELD].ToString()); if (haveDid == false) { addlog(true, insuranceInfoId, endDateStr); } } }
private void button1_Click_1(object sender, EventArgs e) { int rowCount = dataGridView1.RowCount; Boolean[] b = new Boolean[rowCount]; int[] id = new int[rowCount]; string[] dateTime = new string[rowCount]; for (int i = 0; i < rowCount; i++) { //dataGridView1.Rows[i].Selected = true; b[i] = Boolean.Parse(_gridTools.getValueByRowIndex(i, ViewInsuranceInfoData.haveDid_FIELD).ToString().Trim()); id[i] = int.Parse(_gridTools.getValueByRowIndex(i, ViewInsuranceInfoData.id_FIELD).ToString()); dateTime[i] = RMX_TOOLS.date.DateXFormer.persianToGreGorian(_gridTools.getValueByRowIndex(i, ViewInsuranceInfoData.endDate_FIELD).ToString()).ToString(); } string v = settingForm._ht[settingForm.cbxShowConfirmDialog_Alias].ToString(); Boolean b1 = Boolean.Parse(v); if (b1) { DialogResult dialog = MessageBox.Show("اطلاعات تغییر داده شده ذخیره شوند ؟", "", MessageBoxButtons.YesNo); if (dialog == DialogResult.No) { return; } } InsuranceInfoBS insBs = new InsuranceInfoBS(); bool ok = false; for (int i = 0; i < b.Length; i++) { if (b[i]) { addLog(id[i], dateTime[i]); insBs.updateHaveDid(id[i], true); ok = true; } } if (ok) { fillGrid(); msDoAgantsJobDirectly(); } }
private Boolean insuranceNumberCheck() { if (txtInsuranceNumber.Text.Trim().Length <= 0) { MessageBox.Show("شماره بیمه خالی است"); return(false); } InsuranceInfoBS isb = new InsuranceInfoBS(); int id = int.Parse(_gridTools.getCurrentRowValue(InsuranceInfoData.id_FIELD).ToString()); if (isb.checkInsuranceNumberExists(txtInsuranceNumber.Text.Trim(), id)) { MessageBox.Show(" شماره بیمه تکراری است"); txtInsuranceNumber.Focus(); return(false); } return(true); }
private void btnUpdate_Click(object sender, EventArgs e) { string check = checkData(); if (check != null) { MessageBox.Show(check); return; } if (dataMode == EDIT_MODE) { if (dataGridView1.CurrentRow.Selected) { if (cbxHaveDid.Checked) { cbxHaveDid.Checked = Boolean.Parse(_gridTools.getCurrentRowValue(InsuranceInfoData.haveDid_FIELD).ToString()); } } } if (dataMode == NEW_MODE) { cbxHaveDid.Checked = false; } if (dataGridView1.RowCount <= 0) { dataMode = NEW_MODE; } InsuranceInfoBS isb = new InsuranceInfoBS(); InsuranceInfoData inData = new InsuranceInfoData(); DataRow dr = inData.Tables[InsuranceInfoData.insuranceInfo_TABLE].NewRow(); dr[InsuranceInfoData.name_FIELD] = txtName.Text.Trim(); dr[InsuranceInfoData.family_FIELD] = txtFamily.Text.Trim(); dr[InsuranceInfoData.phoneNumber_FIELD] = txtPhoneNumber.Text.Trim(); dr[InsuranceInfoData.insuranceNumber_FIELD] = txtInsuranceNumber.Text.Trim(); dr[InsuranceInfoData.haveDid_FIELD] = cbxHaveDid.Checked; dr[InsuranceInfoData.address_FIELD] = txtAddress.Text.Trim(); dr[InsuranceInfoData.description_FIELD] = txtDescription.Text.Trim(); dr[InsuranceInfoData.mobileNumber_FIELD] = txtMobilePhone.Text.Trim(); dr[InsuranceInfoData.CustomerType_FIELD] = cmbCustomerType.SelectedIndex; if (!dataMode.Equals(NEW_MODE)) { dr[InsuranceInfoData.id_FIELD] = _gridTools.getCurrentRowValue(InsuranceInfoData.id_FIELD); } // Date validation and converion #region dateValidation GregorianCalendar gcal = new GregorianCalendar(); int d = 12; int m = 0; int y = 0; CheckDate.checkDate(txtBeginDate.Text, ref y, ref m, ref d); DateTime persianDateDime = new DateTime(y, m, d, new PersianCalendar()); DateTime greorianDateTime = new DateTime(gcal.GetYear(persianDateDime), gcal.GetMonth(persianDateDime), gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar()); dr[InsuranceInfoData.beginDate_FIELD] = greorianDateTime; // CheckDate.checkDate(txtEndDate.Text, ref y, ref m, ref d); persianDateDime = new DateTime(y, m, d, new PersianCalendar()); greorianDateTime = new DateTime(gcal.GetYear(persianDateDime), gcal.GetMonth(persianDateDime), gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar()); dr[InsuranceInfoData.endDate_FIELD] = greorianDateTime; // //Creation Date String todayShamsi; String[] dateArr; CheckDate.checkDate(txtCreationDate.Text, ref y, ref m, ref d); if (dataMode.Equals(NEW_MODE)) { todayShamsi = RMX_TOOLS.date.DateXFormer.gregorianToPersianString(DateTime.Now); dateArr = todayShamsi.Split('/'); persianDateDime = new DateTime(int.Parse(dateArr[0]), int.Parse(dateArr[1]), int.Parse(dateArr[2]), new PersianCalendar()); } else { persianDateDime = new DateTime(y, m, d, new PersianCalendar()); } greorianDateTime = new DateTime(gcal.GetYear(persianDateDime), gcal.GetMonth(persianDateDime), gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar()); dr[InsuranceInfoData.creationDate_FIELD] = greorianDateTime; // //Last update date todayShamsi = RMX_TOOLS.date.DateXFormer.gregorianToPersianString(DateTime.Now); dateArr = todayShamsi.Split('/'); persianDateDime = new DateTime(int.Parse(dateArr[0]), int.Parse(dateArr[1]), int.Parse(dateArr[2]), new PersianCalendar()); greorianDateTime = new DateTime(gcal.GetYear(persianDateDime), gcal.GetMonth(persianDateDime), gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar()); dr[InsuranceInfoData.lastUpdateDate_FIELD] = greorianDateTime; // //Birth date if (txtBirthDate.Text.Trim() != DateConstants.NULL_Date.Trim()) { CheckDate.checkDate(txtBirthDate.Text, ref y, ref m, ref d); persianDateDime = new DateTime(y, m, d, new PersianCalendar()); greorianDateTime = new DateTime(gcal.GetYear(persianDateDime), gcal.GetMonth(persianDateDime), gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar()); dr[InsuranceInfoData.BirthDate_FIELD] = greorianDateTime; } #endregion //fetch id from comboBox int id = int.Parse(cmbInsuranceType.SelectedValue + ""); dr[InsuranceInfoData.insuranceType_FIELD] = id; string insuranceNumber = txtInsuranceNumber.Text.Trim(); inData.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows.Add(dr); try { int index; if (dataMode == NEW_MODE) { index = -1; } else { index = int.Parse(_gridTools.getCurrentRowValue(InsuranceInfoData.id_FIELD).ToString()); } if (isb.checkInsuranceNumberExists(txtInsuranceNumber.Text.Trim(), index)) { MessageBox.Show("امکان اضافه کردن این رکورد وجود ندارد ، شماره بیمه تکراری است"); txtInsuranceNumber.Focus(); return; } if (dataMode.Equals(NEW_MODE)) { isb.add(inData); InsuranceInfoData iData = isb.getByInsuranceNumer(txtInsuranceNumber.Text.Trim()); if (iData.Tables[0].Rows.Count > 0) { addlog(cbxHaveDid.Checked, int.Parse(iData.Tables[0].Rows[0][InsuranceInfoData.id_FIELD].ToString()), iData.Tables[0].Rows[0][InsuranceInfoData.endDate_FIELD].ToString()); } } else if (dataMode.Equals(EDIT_MODE)) { if (cbxHaveDid.Checked) { checkForLogging(int.Parse(_gridTools.getCurrentRowValue(InsuranceInfoData.id_FIELD).ToString()), _gridTools.getCurrentRowValue(InsuranceInfoData.endDate_FIELD).ToString()); } isb.update(inData); } } catch (Exception ex) { string s = ex.ToString(); if (s.IndexOf("duplicate") >= 0) { MessageBox.Show("امکان اضافه کردن این رکورد وجود ندارد ، شماره بیمه تکراری است"); txtInsuranceNumber.Focus(); } else { MessageBox.Show(ex.ToString()); } return; } btnRefresh_Click(null, null); MainForm.MainFormInstance.fillGrid(); int addedRow = searcInGrid(insuranceNumber); if (addedRow == -1) { dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[0]; } else { dataGridView1.CurrentCell = dataGridView1.Rows[addedRow].Cells[0]; } dataGridView1_SelectionChanged(null, null); dataMode = EDIT_MODE; fillSearchMap(); MainForm.MainFormInstance.msDoAgantsJobDirectly(); //frmMain.msDoAgantsJobDirectly(); }
private void btnUpdate_Click(object sender, EventArgs e) { string check = checkData(); if (check != null) { MessageBox.Show(check); return; } if (_gridTools.getCurrentRowValue(InsuranceInfoData.id_FIELD) == null) { return; } InsuranceInfoBS isb = new InsuranceInfoBS(); InsuranceInfoData inData = new InsuranceInfoData(); DataRow dr = inData.Tables[InsuranceInfoData.insuranceInfo_TABLE].NewRow(); // if (cmbHaveDid.SelectedIndex == 1) // dr[InsuranceInfoData.haveDid_FIELD] = true; // if (cmbHaveDid.SelectedIndex == 2) // dr[InsuranceInfoData.haveDid_FIELD] = false; dr[InsuranceInfoData.name_FIELD] = txtName.Text; dr[InsuranceInfoData.family_FIELD] = txtFamily.Text; dr[InsuranceInfoData.phoneNumber_FIELD] = txtPhoneNumber.Text; dr[InsuranceInfoData.insuranceNumber_FIELD] = txtInsuranceNumber.Text; dr[InsuranceInfoData.id_FIELD] = _gridTools.getCurrentRowValue(InsuranceInfoData.id_FIELD); dr[InsuranceInfoData.address_FIELD] = _gridTools.getCurrentRowValue(InsuranceInfoData.address_FIELD); dr[InsuranceInfoData.haveDid_FIELD] = _gridTools.getCurrentRowValue(InsuranceInfoData.haveDid_FIELD); dr[InsuranceInfoData.cancel_FIELD] = _gridTools.getCurrentRowValue(InsuranceInfoData.cancel_FIELD); dr[InsuranceInfoData.address_FIELD] = txtAddress.Text.Trim(); dr[InsuranceInfoData.description_FIELD] = txtDescription.Text.Trim(); // Date validation and converion #region dateValidation GregorianCalendar gcal = new GregorianCalendar(); int d = 0; int m = 0; int y = 0; CheckDate.checkDate(txtBeginDate.Text, ref y, ref m, ref d); DateTime persianDateDime = new DateTime(y, m, d, new PersianCalendar()); DateTime greorianDateTime = new DateTime(gcal.GetYear(persianDateDime), gcal.GetMonth(persianDateDime), gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar()); dr[InsuranceInfoData.beginDate_FIELD] = greorianDateTime; CheckDate.checkDate(txtEndDate.Text, ref y, ref m, ref d); persianDateDime = new DateTime(y, m, d, new PersianCalendar()); greorianDateTime = new DateTime(gcal.GetYear(persianDateDime), gcal.GetMonth(persianDateDime), gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar()); dr[InsuranceInfoData.endDate_FIELD] = greorianDateTime; #endregion //fetch id from comboBox int id = int.Parse(cmbInsuranceType.SelectedValue + ""); dr[InsuranceInfoData.insuranceType_FIELD] = id; inData.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows.Add(dr); isb.update(inData); string insuranceNumber = txtInsuranceNumber.Text.Trim(); fillGrid(_condition); int addedRow = searcInGrid(insuranceNumber); if (addedRow == -1) { dataGridView1.Rows[dataGridView1.RowCount - 1].Selected = true; } else { dataGridView1.Rows[addedRow].Selected = true; } MainForm.MainFormInstance.fillGrid(); MessageBox.Show("به روز رسانی انجام شد"); }