private void btnAdd_Click(object sender, EventArgs e) { bool emptyFields = isEmptyFields(); if (emptyFields == false) { MyDialog.Show("Error...!", "Plese fill all fields"); } else { if (Validator.IsValidIntNumber(txtcurmilage.Text)) { if (Validator.IsValidIntNumber(txtinvoiceid.Text) && Validator.IsValidPrice(txtamount.Text)) { if (Validator.IsValidDescription(txtinfo.Text)) { addNewService(); resetFields(); } else { MyDialog.Show("Error...!", "Plese enter correct Service Infomation!"); } } else { MyDialog.Show("Error...!", "Plese enter correct InvoiceId , Amount!"); } } else { MyDialog.Show("Error...!", "Plese enter correct milage!"); } } }
private void btn_update_Click_1(object sender, EventArgs e) { try { Database db = new Database(); db.openConnection(); bool test = Validte_Data(); if (test == true) { string query = "UPDATE customers SET fname ='" + txt_cus_fname.Text + "', lname ='" + txt_cus_lname.Text + "',NIC ='" + txt_cus_NIC.Text + "',Mobile ='" + txt_cus_mobile.Text + "',address_1 ='" + txt_cus_addrees_L1.Text + "',address_2 ='" + txt_cus_addrees_L2.Text + "',city ='" + txt_cus_city.Text + "',email ='" + txt_cus_email.Text + "' WHERE c_code = '" + txt_cus_id.Text + "' "; db.sqlQuery(query); db.nonQuery(); loadData(); MyDialog.Show("Update Successful..", "Customer Record Successfully Updated"); } db.closeConnection(); } catch (Exception ex) { MessageBox.Show(Convert.ToString(ex)); } }
public void BindGridView(string query) { try { bunifuCustomDataGrid1.DataSource = null; bunifuCustomDataGrid1.Rows.Clear(); bunifuCustomDataGrid1.Refresh(); Database db = new Database(); DataTable table = new DataTable(); db.openConnection(); db.sqlQuery(query); table = db.executeQuery(); db.closeConnection(); bunifuCustomDataGrid1.DataSource = null; bunifuCustomDataGrid1.Rows.Clear(); bunifuCustomDataGrid1.Refresh(); bunifuCustomDataGrid1.DataSource = table; } catch (SqlException ex) { MyDialog.Show("SQLException", Convert.ToString(ex)); } catch (InvalidOperationException ex) { MyDialog.Show("InvalidOperationException", Convert.ToString(ex)); } catch (Exception e) { MyDialog.Show("Exception...!", Convert.ToString(e)); } }
private void btnRepairAdd_Click(object sender, EventArgs e) { bool test = Validte_Data(); if (test == true) { string gender = ""; if (rbMale.Checked) { gender = "Male"; } else if (rbFemale.Checked) { gender = "Female"; } Database db = new Database(); SqlConnection conn = db.getConnection(); SqlCommand cmd = conn.CreateCommand(); string query = "INSERT INTO employee ( e_code,fname, lname, b_date, gender, add_line_01, add_line_02, city, nic, tel_phone, position,card_id) VALUES('" + txtEID.Text + "','" + txtFName.Text + "','" + txtLName.Text + "','" + dpDOB.Text + "','" + gender + "','" + txtAddress1.Text + "','" + txtAddress2.Text + "','" + txtCity.Text + "','" + txtNIC.Text + "','" + txtPhone.Text + "','" + cmbPosition.Text + "','" + Convert.ToInt32(txtCID.Text) + "')"; db.openConnection(); db.sqlQuery(query); if (db.nonQuery()) { MyDialog.Show("Success...!", "Employee Registered"); insert_to_employee_work_hours_and_rate(txtEID.Text, Convert.ToDecimal(txtRate.Text), Convert.ToDecimal(txtORate.Text), Convert.ToInt32(txtCID.Text)); } else { MyDialog.Show("Error...!", "Employee not Registered"); resetFields(); } } }
private void Search() { if (tbxSearchBox.Text.Length > 0) { if (cmbFilter.SelectedIndex == 0) { if (Validator.IsValidVehicleNumber(tbxSearchBox.Text)) { serachRepairedVehicles(tbxSearchBox.Text, (cmbFilter.SelectedIndex == 0)); } else { MyDialog.Show("Error...!", "Invalid Vehicle Number"); } } else { if (Validator.IsValidPrimaryCode(tbxSearchBox.Text, "R")) { serachRepairedVehicles(tbxSearchBox.Text, (cmbFilter.SelectedIndex == 0)); } else { MyDialog.Show("Error...!", "Invalid Repair Code"); } } } else { MyDialog.Show("Opps!", "Search key cannot be empty"); } }
private void btnUpdate_Click(object sender, EventArgs e) { int selectedrowindex = bunifuCustomDataGrid1.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = bunifuCustomDataGrid1.Rows[selectedrowindex]; string id = Convert.ToString(selectedRow.Cells[0].Value); string charges = tbxCharges.Text; if (Validator.IsValidCharges(charges)) { if (sc.updateServiceTypeCharges(id, charges)) { MyDialog.Show("Success...!", "Service Charges updated"); BindGridView(null); resetFields(); } else { MyDialog.Show("Error...!", "Service Charges not updated"); } } else { MyDialog.Show("Error...!", "Invalid Charges"); } }
private void btnAdd_Click(object sender, EventArgs e) { if (Validator.IsValidPastDate(serviceDate.Value.ToString(DATE_FORMAT))) { if (Validator.IsValidNumber(tbxOdoMeter.Text)) { if (Validator.IsValidFutureDate(nextServiceDate.Value.ToString(DATE_FORMAT))) { addNewService(); } else { MyDialog.Show("Error...!", "Next Service Date is invalid"); } } else { MyDialog.Show("Error...!", "ODO Meter is invalid"); } } else { MyDialog.Show("Error...!", "Service Date is invalid"); } }
private void btn_add_Click_1(object sender, EventArgs e) { Database db = new Database(); db.openConnection(); try { bool test = Validte_Data(); if (test == true) { string query = "INSERT INTO customers VALUES ( '" + txt_cus_id.Text + "','" + txt_cus_fname.Text + "', '" + txt_cus_lname.Text + "', '" + txt_cus_NIC.Text + "', '" + txt_cus_mobile.Text + "', '" + txt_cus_addrees_L1.Text + "','" + txt_cus_addrees_L2.Text + "','" + txt_cus_city.Text + "','" + txt_cus_email.Text + "')"; db.sqlQuery(query); db.nonQuery(); loadData(); MyDialog.Show("Insert Successful..", "Customer Was Successfully Added"); } db.closeConnection(); } catch (Exception ex) { MessageBox.Show(Convert.ToString(ex)); } }
private void btnAddRepairType_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbxRepairTypeName.Text) || string.IsNullOrWhiteSpace(tbxDesc.Text) || string.IsNullOrWhiteSpace(tbxCharges.Text)) { MyDialog.Show("Error...!", "Please fill all fields"); } else { if (Validator.IsValidName(tbxRepairTypeName.Text)) { if (Validator.IsValidCharges(tbxCharges.Text)) { addNewRepairType(); } else { MyDialog.Show("Error...!", "Invalid charges"); } } else { MyDialog.Show("Error...!", "Repair Type Name is invalid"); } } }
private void btnAdd_Click_1(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(txtName.Text) || String.IsNullOrWhiteSpace(txtBrand.Text) || String.IsNullOrWhiteSpace(txtPrice.Text) || String.IsNullOrWhiteSpace(txtQty.Text) || String.IsNullOrWhiteSpace(txtDescription.Text)) { MyDialog.Show("Error...!", "Please fill all fields"); } else { if (Validator.IsValidNumber(txtQty.Text)) { if (Validator.IsValidPrice(txtPrice.Text)) { addNewItem(); } else { MyDialog.Show("Error...!", "Invalid Price"); } } else { MyDialog.Show("Error...!", "Invalid Quantity"); } } }
private void btnUpdate_Click(object sender, EventArgs e) { if (rowSelected == true) { string query = "update bills "; query += "set b_type = '" + cmbType.SelectedItem.ToString() + "', b_monthly_amount = " + float.Parse(txtMonthly.Text) + ", b_issue_date = '" + issueDate.Value.ToShortDateString() + "' "; query += "where b_id = '" + txtId.Text + "'; "; Database db = new Database(); db.sqlQuery(query); db.openConnection(); if (db.nonQuery()) { MyDialog.Show("Update Successful", "Bill was updated successfully"); query = "select b_id as 'Bill ID', b_type as 'Type', b_monthly_amount as 'Monthly Amount', b_issue_date as 'Issue Date' from bills;"; BindGridView(query); } else { MyDialog.Show("Error...!", "Updating bill failed"); } db.closeConnection(); } else { MyDialog.Show("Error...!", "No Row Selected"); } }
private void btnUpdate_Click(object sender, EventArgs e) { if ((MessageBox.Show("Updating a loan will delete all its payment records", "Confirm Update", MessageBoxButtons.OKCancel) == DialogResult.OK) && (ValidateFields())) { try { string query = "update loans set l_lender_name = '" + txtName.Text + "', l_start_date = '" + dateStart.Value.ToShortDateString() + "', l_period = " + Convert.ToInt32(txtPeriod.Text) + ", l_amount = " + float.Parse(txtAmount.Text) + ", l_rate = " + float.Parse(txtRate.Text) + " "; query += "where l_id = '" + id + "'; "; Database db = new Database(); db.openConnection(); db.sqlQuery(query); if (db.nonQuery()) { MyDialog.Show("Update Successful", "Loan was successfully Updated"); clearFields(); query = "select l_id as 'Loan ID', l_lender_name as 'Lender Name', l_start_date as 'Start Date', l_period as 'Period', l_amount as 'Amount', l_rate as 'Rate' from loans"; BindGridView(query); DeleteLoanPayments(id); } else { MyDialog.Show("Update Failed", "Updating Loan Failed"); } db.closeConnection(); } catch (Exception exc) { MyDialog.Show("Exception...!", exc.ToString()); } } else { MyDialog.Show("Error...!", "Input Error"); } }
private void InsertLoan() { string loanId = CodeGenerator.generateLoanID(); int period = Convert.ToInt32(txtPeriod.Text); float amount = float.Parse(txtAmount.Text); float rate = float.Parse(txtRate.Text); string query = "INSERT INTO loans (l_id, l_lender_name, l_start_date, l_period, l_amount, l_rate) VALUES ( "; query += "'" + loanId + "', '" + txtName.Text + "', '" + dateStart.Value.ToString("yyyy-MM-dd") + "', " + period + ", " + amount + ", " + rate + ") "; Database db = new Database(); db.openConnection(); db.sqlQuery(query); if (db.nonQuery()) { MyDialog.Show("Success...!", "Loan Added"); DateTime dt = dateStart.Value; float monthlyAmount = GetMonthlyAmount(amount, rate, period); CreateInstallmentRecords(loanId, monthlyAmount, period, dt.Year, dt.Month); query = "select l_id as 'Loan ID', l_lender_name as 'Lender Name', l_start_date as 'Start Date', l_period as 'Period', l_amount as 'Amount', l_rate as 'Rate' from loans"; BindGridView(query); } else { MyDialog.Show("Failed...!", "Loan Not Added"); } db.closeConnection(); }
private void btnAdd_Click(object sender, EventArgs e) { bool emptyFields = isEmptyFields(); if (emptyFields == false) { MyDialog.Show("Error...!", "Plese fill all fields"); } else { if (Validator.IsValidBeforeOrTodayDate(renewdate.Value)) { if (Validator.IsValidPrice(txtamount.Text) && Validator.IsValidIntNumber(txtinvoiceid.Text)) { addNewRenew(); resetFields(); } else { MyDialog.Show("Error...!", "Plese Enter correct invoiceID , Price!"); } } else { MyDialog.Show("Error...!", "Plese Enter Correct Date!"); } } }
private void btnAdd_Click(object sender, EventArgs e) { string code = tbxErrorCode.Text; string desc = tbxErrorDesc.Text; string remark = tbxRemark.Text; if (tbxErrorCode.Text.Length > 0 && tbxErrorDesc.Text.Length > 0) { if (Validator.IsValidErrorCode(code)) { if (!isErrorAlreadyAdded(code)) { string[] row = { code, desc, remark }; bunifuCustomDataGrid1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; bunifuCustomDataGrid1.Rows.Add(row); lblErrorCount.Text = bunifuCustomDataGrid1.Rows.Count.ToString(); } else { MyDialog.Show("Error..!", "Vehicle Error Already Added"); } } else { MyDialog.Show("Error..!", "Invalid Error Code"); } } else { MyDialog.Show("Error..!", "Error Code && Description are Required"); } }
private void Search() { bunifuCustomDataGrid1.DataSource = null; if (tbxSearchBox.Text.Length > 0) { if (cmbFilter.SelectedIndex == 0) { if (Validator.IsValidVehicleNumber(tbxSearchBox.Text)) { checkForErrors(tbxSearchBox.Text, (cmbFilter.SelectedIndex == 0)); } else { MyDialog.Show("Error...!", "Invalid Vehicle Number"); } } else { if (Validator.IsValidPrimaryCode(tbxSearchBox.Text, "R")) { checkForErrors(tbxSearchBox.Text, (cmbFilter.SelectedIndex == 0)); } else { MyDialog.Show("Error...!", "Invalid Repair Code"); } } } else { MyDialog.Show("Opps!", "Search key cannot be empty"); } }
private void btn_update_Click(object sender, EventArgs e) { try { Database db = new Database(); db.openConnection(); bool test = Validte_Data(); if (test == true) { string query = "UPDATE rental_vehicle SET rv_brand ='" + txt_v_brand.Text + "', rv_model ='" + txt_v_model.Text + "',rv_year ='" + txt_v_year.Text + "',rv_fual_type ='" + cmb_fual_type.Text + "',rv_millage ='" + txt_v_milage.Text + "',rv_status ='" + cmb_status.Text + "',rv_km_per_day ='" + txt_v_km_per_day.Text + "',rv_rate_per_day ='" + txt_v_rate_per_day.Text + "', rv_number ='" + txt_v_number.Text + "',rv_exceed_rate ='" + txt_v_exceed_rate.Text + "',rv_category ='" + cmb_catagory.Text + "',rv_minimum_diposit ='" + txt_v_min_deposit.Text + "' WHERE rv_id = '" + txt_v_id.Text + "' "; db.sqlQuery(query); db.nonQuery(); db.closeConnection(); loadData(); MyDialog.Show("Update Successful..", "Rental Vehicle Record Successfully Updated"); } } catch (Exception ex) { MessageBox.Show(Convert.ToString(ex)); } }
private void btn_add_Click(object sender, EventArgs e) { try { bool test = Validte_Data(); if (test == true) { Database db = new Database(); db.openConnection(); string query = "INSERT INTO rental_vehicle VALUES ('" + txt_v_id.Text + "', '" + txt_v_brand.Text + "', '" + txt_v_model.Text + "', '" + Convert.ToInt32(txt_v_year.Text) + "', '" + cmb_fual_type.Text + "', '" + Convert.ToInt32(txt_v_milage.Text) + "','" + cmb_status.Text + "','" + Convert.ToInt32(txt_v_km_per_day.Text) + "','" + Convert.ToDecimal(txt_v_rate_per_day.Text) + "','" + txt_v_number.Text + "','" + Convert.ToDecimal(txt_v_exceed_rate.Text) + "', '" + cmb_catagory.Text + "','" + txt_v_min_deposit.Text + "' )"; db.sqlQuery(query); db.nonQuery(); db.closeConnection(); loadData(); MyDialog.Show("Insert Successful..", "Rental Vehicle Was Successfully Added"); } } catch (Exception ex) { MessageBox.Show(Convert.ToString(ex)); } }
private void btnPrint_Click_1(object sender, EventArgs e) { string sup_code = ((KeyValuePair <string, string>)cmbSup.SelectedItem).Key; String order_date = orderDate.Value.ToString("yyyy-MM-dd"); String order_code = CodeGenerator.generateOrderCode(); if (Validator.IsValidPastDate(order_date)) { Order odr = new Order(); odr.OrderCode = order_code; odr.SuppCode = sup_code; odr.OrderDate = orderDate.Value; if (oc.addNewOrder(odr)) { MyDialog.Show("Success...!", "Order Registered"); oc.AddOrderItems(bunifuCustomDataGrid2); resetFields(); new Receipt(order_code, order_date).Show(); } else { MyDialog.Show("Error...!", "Order Not Registered"); } } else { MyDialog.Show("Error...!", "Invalid Order date"); } }
private void CreateInstallmentRecords(string loan_id, float amount, int period, int year, int month) { string installment_id; string query = ""; bool temp_error = false; int m, y; DateTime dt = Convert.ToDateTime(month + "/01" + "/" + year); //MessageBox.Show(dt.ToString()); for (int count = 1; count <= period; count++) { installment_id = CodeGenerator.generateInstallmentID(); dt = dt.AddMonths(1); month = dt.Month; year = dt.Year; query = "INSERT INTO installments (ins_id, ins_l_id, ins_amount, ins_year, ins_month) VALUES ('" + installment_id + "', '" + loan_id + "', " + amount + ", " + year + ", " + month + ");"; Database db = new Database(); db.openConnection(); db.sqlQuery(query); if (!db.nonQuery()) { temp_error = true; } db.closeConnection(); } if (temp_error == true) { MyDialog.Show("Success...!", "Error Adding Installments"); } else { MyDialog.Show("Success...!", "Installments Added"); } }
private void addNewItem() { string key = ((KeyValuePair <string, string>)cmbSup.SelectedItem).Key; string type = cmbType.SelectedItem.ToString(); Stock st_data = new Stock(); st_data.SupName = key; st_data.Type = type; st_data.ItemName = txtName.Text; st_data.Brand = txtBrand.Text; st_data.Description = txtDescription.Text; st_data.Quantity = txtQty.Text; st_data.UnitPrice = txtPrice.Text; if (stc.addItem(st_data)) { MyDialog.Show("Success...!", "Item Registered"); resetFields(); BindGridView(null); } else { MyDialog.Show("Error...!", "Item Not Registered"); } }
private void addNewService() { try { Service sv = new Service(); sv.VehicleCode = sc.getVehicleCode(tbxVehicleNumber.Text); sv.ServiceDate = serviceDate.Value; sv.OdoMeter = tbxOdoMeter.Text; sv.NextServiceDate = nextServiceDate.Value; if (sc.addService(sv)) { MyDialog.Show("Success...!", "New Service Registered"); addProvidedServices(); resetFields(); } else { MyDialog.Show("Error...!", "New Service Not Registered"); } } catch (Exception e) { MessageBox.Show(e.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { int selectedrowindex = bunifuCustomDataGrid1.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = bunifuCustomDataGrid1.Rows[selectedrowindex]; String v_code = Convert.ToString(selectedRow.Cells[0].Value); String vehicle_type = cmbVehicleType.SelectedItem.ToString(); string cus_name = ((KeyValuePair <string, string>)cmbCusName.SelectedItem).Key; if (String.IsNullOrWhiteSpace(tbxVehicleNo.Text) || String.IsNullOrWhiteSpace(tbxBrand.Text) || String.IsNullOrWhiteSpace(tbxModel.Text) || String.IsNullOrWhiteSpace(tbxVehicleNo.Text)) { MyDialog.Show("Error...!", "Please fill all fields"); } else { if (Validator.IsValidName(tbxBrand.Text)) { if (Validator.IsValidVehicleNumber(tbxVehicleNo.Text)) { if (Validator.IsValidName(tbxModel.Text)) { Vehicle v_data = new Vehicle(); v_data.VehicleCode = v_code; v_data.CustomerName = cus_name; v_data.VehicleNo = tbxVehicleNo.Text; v_data.Type = vehicle_type; v_data.Brand = tbxBrand.Text; v_data.Model = tbxModel.Text; if (vc.updateVehicle(v_data)) { BindGridView(null); resetFields(); MyDialog.Show("Success...!", "Vehicle updated"); } else { MyDialog.Show("Error...!", "Vehicle not updated"); } } else { MyDialog.Show("Error...!", "Invalid Model Name"); } } else { MyDialog.Show("Error...!", "Invalid Vehicle Number"); } } else { MyDialog.Show("Error...!", "Invalid Brand Name"); } } }
private bool Validte_Data() { Regex validate_number = new Regex("[0-9]+$"); Regex validate_float = new Regex("^[0-9]+(\\.[0-9][0-9]?)?$"); if (!validate_number.IsMatch(txt_bill_final_millage.Text)) { MyDialog.Show("Error...!", "Invalid Final Millage"); } else { if (!validate_float.IsMatch(txt_bill_damage_amount.Text)) { MyDialog.Show("Error...!", "Invalid Damage Amount"); } else { if (!validate_float.IsMatch(lbl_tot_bill.Text)) { MyDialog.Show("Error...!", "Invalid Total Amount"); } else { return(true); } return(false); } return(false); } return(false); }
private void btn_update_Click(object sender, EventArgs e) { try { bool test = Validte_Data(); if (test == true) { Database db = new Database(); db.openConnection(); string query = "UPDATE rental_bill_details SET bill_rnt_id ='" + cmb_bill_rent_id.Text + "',bill_date ='" + datepicker_bill_date.Text + "', bill_tot_amount ='" + float.Parse(lbl_tot_bill.Text) + "',bill_final_millage ='" + Convert.ToInt32(txt_bill_final_millage.Text) + "',bill_damage_amount ='" + float.Parse(txt_bill_damage_amount.Text) + "' WHERE bill_id = '" + txt_bill_id.Text + "' "; db.sqlQuery(query); db.nonQuery(); string query2 = "UPDATE rental_details SET rnt_bill_is_issued = 'yes' Where rnt_id = '" + cmb_bill_rent_id.Text + "'"; db.sqlQuery(query2); db.nonQuery(); db.closeConnection(); loadData(); MyDialog.Show("Update Successful..", "Bill Record Successfully Updated"); } } catch (Exception ex) { MessageBox.Show(Convert.ToString(ex)); } }
private void btn_add_Click_1(object sender, EventArgs e) { try { Database db = new Database(); db.openConnection(); bool test = Validte_Data(); if (test == true) { string query = "INSERT INTO rental_bill_details VALUES ( '" + txt_bill_id.Text + "','" + cmb_bill_rent_id.Text + "' ,'" + datepicker_bill_date.Text + "', '" + float.Parse(lbl_tot_bill.Text) + "', '" + Convert.ToInt32(txt_bill_final_millage.Text) + "', '" + float.Parse(txt_bill_damage_amount.Text) + "')"; db.sqlQuery(query); db.nonQuery(); string query2 = "UPDATE rental_details SET rnt_bill_is_issued = 'yes' Where rnt_id = '" + cmb_bill_rent_id.Text + "'"; db.sqlQuery(query2); db.nonQuery(); db.closeConnection(); loadData(); MyDialog.Show("Insert Successful..", "Bill Was Successfully Added"); } } catch (Exception ex) { MessageBox.Show(Convert.ToString(ex)); } }
private void btn_update_Click(object sender, EventArgs e) { try { bool test = Validte_Data(); if (test == true) { Database db = new Database(); db.openConnection(); string query = "UPDATE rental_invoice SET in_rnt_id ='" + cmb_inv_rnt_id.Text + "',in_date ='" + datepicker_issueDate.Text + "', in_advanced_payment ='" + float.Parse(txt_inv_adv_payment.Text) + "' WHERE in_id = '" + txt_inv_id.Text + "' "; db.sqlQuery(query); db.nonQuery(); string query2 = "UPDATE rental_details SET rnt_invoice_is_issued = 'yes' Where rnt_id = '" + cmb_inv_rnt_id.Text + "'"; db.sqlQuery(query2); db.nonQuery(); db.closeConnection(); loadData(); MyDialog.Show("Update Successful..", "Invoice Record Successfully Updated"); } } catch (Exception ex) { MessageBox.Show(Convert.ToString(ex)); } }
private void GetInstallmentIDAndDeletePayment(int CurrentYear, int CurrentMonth) { Database db = new Database(); db.openConnection(); // Get Installment ID of the last loan payment string query = "select ins_id from installments "; query += "where ins_l_id = '" + lblID.Text + "' and ins_year = " + CurrentYear + " and ins_month = " + CurrentMonth + "; "; db.sqlQuery(query); DataTable temp_table = db.executeQuery(); string ins_id = ""; ins_id = temp_table.Rows[0][0].ToString(); query = "delete from loan_payments "; query += "where lp_ins_id = '" + ins_id + "'; "; db.sqlQuery(query); if (db.nonQuery()) { MyDialog.Show("Success", "Last Payment Deleted"); query = "select lp_ins_id as 'Installment ID', lp_l_id as 'Loan ID', lp_payment_date as 'Date', lp_payment_amount as 'Amount' "; query += "from loan_payments "; query += "where lp_l_id = '" + lblID.Text + "' ; ";; BindGridView(query); SearchAndUpdate(lblID.Text); } else { MyDialog.Show("Error...!", "Deleting Failed"); } db.closeConnection(); }
private void btnUpdate_Click(object sender, EventArgs e) { bool emptyFields = isEmptyFields(); if (emptyFields == false) { MyDialog.Show("Error...!", "Plese fill all fields"); } else { if (Validator.IsValidIntNumber(txtcurmilage.Text)) { if (Validator.IsValidIntNumber(txtinvoiceid.Text) && Validator.IsValidPrice(txtamount.Text)) { if (Validator.IsValidDescription(txtinfo.Text)) { int selectedrowindex = bunifuCustomDataGrid1.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = bunifuCustomDataGrid1.Rows[selectedrowindex]; string service_id = Convert.ToString(selectedRow.Cells[0].Value); string maintain_date = maintaindate.Value.ToString("yyyy-MM-dd"); string query = "UPDATE rental_vehicle_repair_service SET maintanance_type = '" + combotype.SelectedItem + "', info = '" + txtinfo.Text + "', invoice_id = '" + txtinvoiceid.Text + "', amount = '" + txtamount.Text + "', current_milage = '" + txtcurmilage.Text + "', maintanance_date = '" + maintain_date + "' WHERE maintanance_id = '" + service_id + "'"; Database db = new Database(); db.openConnection(); db.sqlQuery(query); if (db.nonQuery()) { MyDialog.Show("Success...!", "Service Details Updated."); db.closeConnection(); } } else { MyDialog.Show("Error...!", "Plese enter correct Service Infomation!"); } } else { MyDialog.Show("Error...!", "Plese enter correct InvoiceId , Amount!"); } } else { MyDialog.Show("Error...!", "Plese enter correct milage!"); } } combotype.SelectedIndex = -1; txtinfo.Text = string.Empty; txtinvoiceid.Text = string.Empty; txtamount.Text = string.Empty; maintaindate.Value = DateTime.Now; int selectedrowindex2 = bunifuCustomDataGrid2.SelectedCells[0].RowIndex; DataGridViewRow selectedRow2 = bunifuCustomDataGrid2.Rows[selectedrowindex2]; string vehiid = Convert.ToString(selectedRow2.Cells[0].Value); BindGridView1(vehiid); resetFields(); }
private void btnUpdate_Click_1(object sender, EventArgs e) { int selectedrowindex = bunifuCustomDataGrid1.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = bunifuCustomDataGrid1.Rows[selectedrowindex]; String item_code = Convert.ToString(selectedRow.Cells[0].Value); String type = cmbType.SelectedItem.ToString(); string sup_name = ((KeyValuePair <string, string>)cmbSup.SelectedItem).Key; if (String.IsNullOrWhiteSpace(txtName.Text) || String.IsNullOrWhiteSpace(txtBrand.Text) || String.IsNullOrWhiteSpace(txtPrice.Text) || String.IsNullOrWhiteSpace(txtQty.Text) || String.IsNullOrWhiteSpace(txtDescription.Text)) { MyDialog.Show("Error...!", "Please fill all fields"); } else { if (Validator.IsValidNumber(txtQty.Text)) { if (Validator.IsValidPrice(txtPrice.Text)) { Stock st_data = new Stock(); st_data.ItemCode = item_code; st_data.SupName = sup_name; st_data.ItemName = txtName.Text; st_data.Type = type; st_data.Brand = txtBrand.Text; st_data.Description = txtDescription.Text; st_data.Quantity = txtQty.Text; st_data.UnitPrice = txtPrice.Text; if (stc.updateItem(st_data)) { BindGridView(null); resetFields(); MyDialog.Show("Success...!", "Item updated"); } else { MyDialog.Show("Error...!", "Item not updated"); } } else { MyDialog.Show("Error...!", "Invalid Price"); } } else { MyDialog.Show("Error...!", "Invalid Quantity"); } } }