private void btnDeleteTerm_Click(object sender, EventArgs e) { if (MessageBox.Show("تمامی کارکردهای مربوط به دوره " + lstTermNo.SelectedItem.Text + " حذف خواهند گردید. آیا تأیید می نمایید؟", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { dataAccess.ExecuteAccess("delete from tbl_usage where term_no = " + lstTermNo.SelectedItem.Text); FillLstTermNo(); //SetDtSelectedTermUsage(); } }
private void btnReturn_Click(object sender, EventArgs e) { if (modeIsUpdate && dataModified) { dataAccess.ExecuteAccess("delete from Tbl_Instalment where Bill_Term_No = " + termNo + " and Cntr_No = " + cntrNo); } if (!(modeIsUpdate && !dataModified)) { foreach (DataRow dr in dtInstalment.Rows) { string query = "insert into Tbl_Instalment (Bill_Term_No,Pay_Term_No,Cntr_No,Balance) values (" + dr["Bill_Term_No"].ToString() + "," + dr["Pay_Term_No"].ToString() + "," + dr["Cntr_No"].ToString() + "," + dr["Balance"].ToString() + ")"; dataAccess.ExecuteAccess(query); } } }
private bool InsertUpdateAction() { string query = ""; if (usageExistsInDB) { query += "update tbl_usage set "; query += "Cntr_Liter=" + (txtCounter.Text.Trim()) + ","; query += "Wtr_Price=" + (txtWaterPrice.Text.Trim()) + ","; query += "Garbage=" + (txtGarbage.Text.Trim()) + ","; query += "Partnership=" + (txtPartnership.Text.Trim()) + ","; query += "Renovation=" + (txtRenovation.Text.Trim()) + ","; query += "Communion=" + (txtCommunion.Text.Trim()) + ","; query += "Others=" + (txtOther.Text.Trim()) + ","; query += "Discount=" + (txtDiscount.Text.Trim()); query += " where cust_No = " + cmbCust.Text; query += " and term_no = " + cmbTermNo.Text; } 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_Usage (Cntr_Liter,Wtr_Price,Garbage,Partnership,Renovation,Communion," + "Others,Discount,Subscription,term_no,Cntr_no,Cust_No)"; query += " values (" + txtCounter.Text.Trim() + "," + txtWaterPrice.Text.Trim() + "," + txtGarbage.Text.Trim() + "," + txtPartnership.Text.Trim() + "," + txtRenovation.Text.Trim() + "," + txtCommunion.Text.Trim() + "," + txtOther.Text.Trim() + "," + txtDiscount.Text.Trim() + "," + txtSubscription.Text.Trim() + "," + cmbTermNo.Text + "," + Cntr_No + "," + cmbCust.Text + ")"; } dataAccess.ExecuteAccess(query); if (cmbCust.SelectedIndex < dtCust.Rows.Count - 1) { cmbCust.SelectedIndex++; } txtCounter.Select(); return(true); }
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 btnOK_Click(object sender, EventArgs e) { if (!(txtFName.Text.Trim() == "" && txtLName.Text.Trim() == "")) { string query = ""; if (modeIsUpdate) { bool cntr_noIsChanged = false; if (txtCntr_No.Text.Trim() != cntr_No) { cntr_noIsChanged = true; } if (cntr_noIsChanged && frmMain.ExistsInTable("tbl_cust", "cntr_No", txtCntr_No.Text.Trim(), true)) { MessageBox.Show("این شماره کنتور قبلاً برای فرد دیگری ثبت شده است"); txtCntr_No.Select(); txtCntr_No.SelectAll(); } else { if (txtAddr.Text.Trim() == "") { txtAddr.Text = "-----------"; } query += "update tbl_cust set "; query += "cntr_No='" + (txtCntr_No.Text.Trim()) + "',"; query += "fname='" + (txtFName.Text.Trim()) + "',"; query += "lname='" + (txtLName.Text.Trim()) + "',"; query += "addr='" + (txtAddr.Text.Trim()) + "' "; query += " where cntr_No = " + cntr_No; dataAccess.ExecuteAccess(query); if (cntr_noIsChanged) { query = "update tbl_usage set cntr_No=" + txtCntr_No.Text.Trim() + " where cntr_no=" + cntr_No; // +"'"; dataAccess.ExecuteAccess(query); query = "update tbl_payment set cntr_No=" + txtCntr_No.Text.Trim() + " where cntr_no=" + cntr_No; // +"'"; dataAccess.ExecuteAccess(query); } DialogResult = DialogResult.OK; Close(); } } else { if (txtCntr_No.Text.Trim() != "" || txtCust_No.Text.Trim() != "") { if (frmMain.ExistsInTable("tbl_cust", "cntr_No", txtCntr_No.Text.Trim(), true)) { MessageBox.Show("این شماره کنتور قبلاً برای فرد دیگری ثبت شده است"); txtCntr_No.Select(); txtCntr_No.SelectAll(); } else if (frmMain.ExistsInTable("tbl_cust", "Cust_No", txtCust_No.Text.Trim(), true)) { MessageBox.Show("این شماره اشتراک قبلاً برای فرد دیگری ثبت شده است"); txtCust_No.Select(); txtCust_No.SelectAll(); } else if (txtAddr.Text.Trim() == "") { MessageBox.Show("آدرس نباید خالی باشد"); txtAddr.Select(); txtAddr.SelectAll(); } else { query += "insert into tbl_cust (Cust_No,cntr_No,fname,lname,addr)"; query += " values (" + txtCust_No.Text.Trim() + "," + txtCntr_No.Text.Trim() + ",'" + txtFName.Text.Trim() + "','" + txtLName.Text.Trim() + "','" + txtAddr.Text.Trim() + "')"; dataAccess.ExecuteAccess(query); DialogResult = DialogResult.OK; Close(); } } else { MessageBox.Show("لطفاً شماره کنتور و شماره اشتراک را وارد نمایید"); txtCntr_No.Select(); } } } else { MessageBox.Show("لطفاً نام و نام خانوادگی را وارد نمایید"); } }