private void btnsave_Click(object sender, EventArgs e) { if (cboreceived_by.Text == "Choose One" || cboreceived_by.Text == "") { MessageBox.Show("Receiver Name is Required", "Receiver Name Alert !!"); } else if (dataGridView1.Rows.Count > 0 || txttotal.Text != "" || txtgrandtotal.Text != "") { stock(); purchase_add(); // supplier_name(); MessageBox.Show("Data has been saved"); DataTable dt = bls.GetSupplier_Amount(txtcustomername.Text); decimal amount = Convert.ToDecimal(dt.Rows[0]["grand_total"].ToString()); PurchasePay pp = new PurchasePay(txtcustomername.Text, amount); supplier_names = txtcustomername.Text; pp.Show(); ClearallTextbox(panelEx1); clear(); bill_no = ""; txtcustomername.SelectedIndex = 0; } else { MessageBox.Show("Add Data to Table First.", "Grid Row Empty error::"); } invoice_no(); }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["col_details"].Index && e.RowIndex >= 0) { Control ctl = this.Parent; supplier_name = Convert.ToString(dataGridView1.Rows[e.RowIndex].Cells["col_supplier"].Value); SupplierPayment sp = new SupplierPayment(); ctl.Controls.Clear(); ctl.Controls.Add(sp); } else if (e.ColumnIndex == dataGridView1.Columns["col_payment"].Index && e.RowIndex >= 0) { Control ctrl = this.Parent; grand_total = Convert.ToDecimal(dataGridView1.Rows[e.RowIndex].Cells["col_grand_total"].Value); supplier_name = Convert.ToString(dataGridView1.Rows[e.RowIndex].Cells["col_supplier"].Value); PurchasePay sp = new PurchasePay(supplier_name, grand_total); sp.Show(); } else if (e.ColumnIndex == dataGridView1.Columns["col_view"].Index && e.RowIndex >= 0) { Control ctrl = this.Parent; sup_id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["col_sup_id"].Value); supplier_name = Convert.ToString(dataGridView1.Rows[e.RowIndex].Cells["col_supplier"].Value); ViewPayment sp = new ViewPayment(); ctrl.Controls.Clear(); ctrl.Controls.Add(sp); } }