private void btnDateSourceCancel_Click(object sender, EventArgs e) { mskDateSource.Text = System.IO.File.ReadAllText(Application.StartupPath + "\\DateSource.txt"); CLSValidityCheck.IsDate(mskDateSource); mskDateSource.ReadOnly = true; btnDateSourceCancel.Visible = false; DateSourceIsInUpdateMode = false; btnDateSourceUpdate.Image = Benis.Properties.Resources.Update_42; }
private void btnInsert_Click(object sender, EventArgs e) { bool valueIsValid = true; if (CLSValidityCheck.IsInt(txtInstalmentBalance)) { if (int.Parse(txtInstalmentBalance.Text) <= 0) valueIsValid = false; } else valueIsValid = false; if (valueIsValid) { double newInstalment = double.Parse(txtInstalmentBalance.Text); if (newInstalment <= remainBalance) { bool termExistsInTable = false; DataRow drCurrentTerm = null; foreach (DataRow dr in dtInstalment.Rows) { if (dr["Pay_Term_No"].ToString() == numTermNo.Value.ToString()) { termExistsInTable = true; drCurrentTerm = dr; } } if (termExistsInTable) { if (MessageBox.Show("مبلغ " + drCurrentTerm["Balance"].ToString() + " برای این دوره ثبت گردیده است. مبلغ جدید به مبلغ قبلی اضافه شود؟", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { drCurrentTerm["Balance"] = double.Parse(drCurrentTerm["Balance"].ToString()) + newInstalment; CalcFormBalances(); } } else { DataRow drNew = dtInstalment.Rows.Add(); drNew["Bill_Term_No"] = termNo; drNew["Pay_Term_No"] = (int)numTermNo.Value; drNew["Cntr_No"] = int.Parse(cntrNo); drNew["Balance"] = newInstalment; drNew["cmdDelete"] = "حذف"; instalmentSum += newInstalment; lblInstalmentSum.Text = instalmentSum.ToString(); remainBalance = billBalance - instalmentSum; lblRemainBalance.Text = remainBalance.ToString(); txtInstalmentBalance.Text = remainBalance.ToString(); numTermNo.Value++; } } else { MessageBox.Show("مقدار وارد شده از مبلغ باقیمانده قبض بیشتر است."); } } else MessageBox.Show("مقدار وارد شده معتبر نیست."); txtInstalmentBalance.Focus(); txtInstalmentBalance.SelectAll(); }
private void grdPayment_CellEndEdit(object sender, GridViewCellEventArgs e) { if (e.RowIndex != -1) { if (e.Column.Name == "Pay_Date") { if (!CLSValidityCheck.IsDate("13" + e.Value.ToString())) { grdPayment.Rows[e.RowIndex].Cells["Pay_Date"].Value = editingDate; MessageBox.Show("تاریخ وارد شده صحیح نیست"); } } } }
private void btnDateSourceUpdate_Click(object sender, EventArgs e) { if (!DateSourceIsInUpdateMode) { mskDateSource.ReadOnly = false; DateSourceIsInUpdateMode = true; btnDateSourceUpdate.Image = Benis.Properties.Resources.OK_42; btnDateSourceCancel.Visible = true; mskDateSource.Select(); mskDateSource.SelectAll(); } else { if (CLSValidityCheck.IsDate(mskDateSource) && mskDateSource.Value.ToString() != "") { if (Convert.ToInt16(mskDateSource.Text.Substring(6, 2)) == 1) { System.IO.File.WriteAllText(Application.StartupPath + "\\DateSource.txt", mskDateSource.Text.Trim()); mskDateSource.ReadOnly = true; DateSourceIsInUpdateMode = false; btnDateSourceCancel.Visible = false; btnDateSourceUpdate.Image = Benis.Properties.Resources.Update_42; lblUsageFromDate.Text = GetTermStart(Convert.ToInt16(lstTermNo.SelectedItem.Text)); lblUsageToDate.Text = GetTermStart(Convert.ToInt16(lstTermNo.SelectedItem.Text) + 1); } else { MessageBox.Show("مبدأ دوره بایستی از ابتدای ماه شروع گردد", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); } } else { MessageBox.Show("لطفاً یک مقدار معتبر برای تاریخ وارد نمایید", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); } } }
private bool InsertUpdateAction() { if (CLSValidityCheck.IsInt(txtPayBalance) && CLSValidityCheck.IsDate(mskPayDate)) { string query = ""; if (modeIsUpdate) { query += "update tbl_payment set "; query += "Pay_Balance =" + txtPayBalance.Text.Trim() + ","; query += "Pay_Date = '" + (mskPayDate.Text.Trim()) + "'"; query += " where Cust_No = " + cmbCust.Text + " and Pay_Date = '" + original_Pay_Date + "' and Pay_Balance = " + original_Pay_Balance; } else { string Cntr_No = ""; try { Cntr_No = dataAccess.GetAccessDataSetByQuery("select Cntr_No from tbl_Cust where cust_No = " + cmbCust.Text).Tables[0].Rows[0]["Cntr_No"].ToString(); } catch { MessageBox.Show("مشتری با این شماره وجود ندارد", "", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); return(false); } query += "insert into tbl_payment (cust_No,cntr_No,Pay_Date,Pay_Balance)"; query += " values (" + cmbCust.Text.Trim() + "," + Cntr_No + ",'" + mskPayDate.Text.Trim() + "'," + txtPayBalance.Text + ")"; } dataAccess.ExecuteAccess(query); if (!modeIsUpdate) { if (cmbCust.SelectedIndex < dtCust.Rows.Count - 1) { cmbCust.SelectedIndex++; } if (mskPayDate.Enabled) { mskPayDate.Select(); mskPayDate.SelectAll(); } else { txtPayBalance.Select(); txtPayBalance.SelectAll(); } } else { DialogResult = DialogResult.OK; //Close(); } } else { MessageBox.Show("لطفاً مقادیر وارد شده را تصحیح نمایید"); return(false); } return(true); }
private void txtPayBalance_Leave(object sender, EventArgs e) { CLSValidityCheck.IsInt(txtPayBalance); }
private void mskPayDate_Leave(object sender, EventArgs e) { CLSValidityCheck.IsDate(mskPayDate); }