private void on_invoice_count() { decimal carat = 0.00M; decimal inv_amount = 0.00M; decimal out_amount = 0.00M; decimal pay_amount = 0.00M; decimal rem_amount = 0.00M; decimal cur_amount = 0.00M; for (int i = 0; i < dgv_on_invoice.Rows.Count; i++) { Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, i, "carat"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, i, "invcurr"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, i, "outamt"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, i, "remamt"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, i, "payamt"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, i, "cursoramt"); carat = carat + Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["carat"].Value.ToString()); inv_amount = inv_amount + Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["invcurr"].Value.ToString()); out_amount = out_amount + Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["outamt"].Value.ToString()); pay_amount = pay_amount + Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["payamt"].Value.ToString()); rem_amount = rem_amount + Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["remamt"].Value.ToString()); cur_amount = cur_amount + Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["cursoramt"].Value.ToString()); } txt_carat.Text = carat.ToString(); txt_inv_amount.Text = inv_amount.ToString(); txt_out_amt.Text = out_amount.ToString(); txt_pay_amt.Text = pay_amount.ToString(); txt_rem_amt.Text = rem_amount.ToString(); txt_cursor_amt.Text = cur_amount.ToString(); }
private void count_gst_final() { Set_Comboas_Null.Set_Zero_If_Null_Textbox(txt_amount); Set_Comboas_Null.Set_Zero_If_Null_Textbox(txt_cgst_per); Set_Comboas_Null.Set_Zero_If_Null_Textbox(txt_sgst_per); Set_Comboas_Null.Set_Zero_If_Null_Textbox(txt_igst_per); decimal total_amount = 0.00M; decimal cgst_per = 0.00M; decimal cgst_amt = 0.00M; decimal sgst_per = 0.00M; decimal sgst_amt = 0.00M; decimal igst_per = 0.00M; decimal igst_amt = 0.00M; total_amount = Convert.ToDecimal(txt_amount.Text); cgst_per = Convert.ToDecimal(txt_cgst_per.Text); sgst_per = Convert.ToDecimal(txt_sgst_per.Text); igst_per = Convert.ToDecimal(txt_igst_per.Text); if (total_amount > 0.00M) { cgst_amt = (total_amount * cgst_per) / 100; sgst_amt = (total_amount * sgst_per) / 100; igst_amt = (total_amount * igst_per) / 100; } if (cgst_per > 0.000M && cgst_amt > 0.000M) { txt_cgst_amount.Text = cgst_amt.ToString("0.00"); } else { txt_cgst_amount.Text = "0.00"; } if (sgst_per > 0.000M && sgst_amt > 0.000M) { txt_sgst_amount.Text = sgst_amt.ToString("0.00"); } else { txt_sgst_amount.Text = "0.00"; } if (igst_per > 0.000M && igst_amt > 0.000M) { txt_igst_amount.Text = igst_amt.ToString("0.00"); } else { txt_igst_amount.Text = "0.00"; } Set_Comboas_Null.Set_Zero_If_Null_Textbox(txt_cgst_amount); Set_Comboas_Null.Set_Zero_If_Null_Textbox(txt_sgst_amount); Set_Comboas_Null.Set_Zero_If_Null_Textbox(txt_igst_amount); txt_final_amount.Text = (total_amount + cgst_amt + sgst_amt + igst_amt).ToString("0.00"); }
private void count_amount() { decimal total_amount = 0.00M; for (int i = 0; i < dgv_detail.RowCount - 1; i++) { Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_detail, i, "amount"); if (Convert.ToDecimal(dgv_detail.Rows[i].Cells["amount"].Value.ToString()) > 0.00M) { total_amount = total_amount + Convert.ToDecimal(dgv_detail.Rows[i].Cells["amount"].Value.ToString()); } } txt_amount.Text = total_amount.ToString("0.00"); count_gst_final(); }
private void btn_invoice_Click(object sender, EventArgs e) { check_on_inv = 1; Set_Comboas_Null.Set_Zero_If_Null_Textedit(txt_credit); Set_Comboas_Null.Set_Zero_If_Null_Textedit(txt_debit); if (Convert.ToDecimal(txt_credit.Text) > 0 || Convert.ToDecimal(txt_debit.Text) > 0) { //if (dgv_on_invoice.Visible == false) { //if (dt_on_invoice.Rows.Count == 0) { if (Convert.ToDecimal(txt_credit.Text) > 0 && Convert.ToDecimal(txt_debit.Text) > 0) { MessageBox.Show("Enter Only 1 Amount Credit/Debit.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); txt_credit.Focus(); return; } if (Convert.ToDecimal(txt_credit.Text) > 0) { dt_on_invoice = sp_sqlconnection.get_sp("pur_sale_detail", "qtype=payment_remain_invoice|c_id=" + UserDetail.c_id + "|type=SALE|party=" + cmb_party.Text + ""); } else if (Convert.ToDecimal(txt_debit.Text) > 0) { dt_on_invoice = sp_sqlconnection.get_sp("pur_sale_detail", "qtype=payment_remain_invoice|c_id=" + UserDetail.c_id + "|type=PUR|party=" + cmb_party.Text + ""); } dgv_on_invoice.DataSource = dt_on_invoice; decimal pay_amount = Convert.ToDecimal(txt_credit.Text); if (Convert.ToDecimal(txt_credit.Text) > 0) { pay_amount = Convert.ToDecimal(txt_credit.Text); } else if (Convert.ToDecimal(txt_debit.Text) > 0) { pay_amount = Convert.ToDecimal(txt_debit.Text); } if (dgv_on_invoice.Rows.Count > 0) { for (int i = 0; i < dgv_on_invoice.Rows.Count; i++) { Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, i, "payamt"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, i, "outamt"); if (pay_amount > 0) { if (pay_amount > Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["outamt"].Value.ToString())) { pay_amount = pay_amount - Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["outamt"].Value.ToString()); dgv_on_invoice.Rows[i].Cells["payamt"].Value = dgv_on_invoice.Rows[i].Cells["outamt"].Value.ToString(); } else { dgv_on_invoice.Rows[i].Cells["payamt"].Value = pay_amount; dgv_on_invoice.Rows[i].Cells["remamt"].Value = Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["outamt"].Value.ToString()) - pay_amount; pay_amount = 0.00M; } } else { dgv_on_invoice.Rows[i].Cells["remamt"].Value = Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["outamt"].Value.ToString()); } } } if (pay_amount > 0) { if (dgv_on_invoice.Rows.Count > 0) { for (int i = 0; i < dgv_on_invoice.Rows.Count; i++) { if (Convert.ToDecimal(dgv_on_invoice.Rows[0].Cells["payamt"].Value.ToString()) > 0) { dgv_on_invoice.Rows[i].Cells["cursoramt"].Value = 0 - pay_amount; break; } } } //MessageBox.Show("Invoice Outstanding Is Lower than Enter Amount.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); //return; } } } //if (dgv_on_invoice.Visible == true) //{ dgv_payment.Visible = false; dgv_on_invoice.Visible = true; //} //else //{ // dgv_on_invoice.Visible = true; // dgv_payment.Visible = false; //} } on_invoice_count(); }
private void cmb_days_SelectedIndexChanged(object sender, EventArgs e) { Set_Comboas_Null.Check_Item_Exist_In_Combo(cmb_days); if (cmb_days.Text != "") { if (cmb_days.Text.ToUpper() == "TODAY") { dtp_from.Value = DateTime.Today; dtp_to.Value = DateTime.Today; } else if (cmb_days.Text.ToUpper() == "YESTERDAY") { dtp_from.Value = DateTime.Today.AddDays(-1); dtp_to.Value = DateTime.Today.AddDays(-1); } else if (cmb_days.Text.ToUpper() == "THIS WEEK") { System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture; DayOfWeek fdow = ci.DateTimeFormat.FirstDayOfWeek; dtp_from.Value = DateTime.Now.AddDays(-(DateTime.Now.DayOfWeek - fdow)).Date; dtp_to.Value = DateTime.Today; } else if (cmb_days.Text.ToUpper() == "LAST WEEK") { System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture; DayOfWeek fdow = ci.DateTimeFormat.FirstDayOfWeek; dtp_from.Value = DateTime.Now.AddDays(-(DateTime.Now.DayOfWeek - fdow) - 7).Date; dtp_to.Value = DateTime.Now.AddDays(-(DateTime.Now.DayOfWeek - fdow) - 1).Date; } else if (cmb_days.Text.ToUpper() == "LAST 2 WEEK") { System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture; DayOfWeek fdow = ci.DateTimeFormat.FirstDayOfWeek; dtp_from.Value = DateTime.Now.AddDays(-(DateTime.Now.DayOfWeek - fdow) - 7).Date; dtp_to.Value = DateTime.Today; } else if (cmb_days.Text.ToUpper() == "LAST TO LAST WEEK") { System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture; DayOfWeek fdow = ci.DateTimeFormat.FirstDayOfWeek; dtp_from.Value = DateTime.Now.AddDays(-(DateTime.Now.DayOfWeek - fdow) - 14).Date; dtp_to.Value = DateTime.Now.AddDays(-(DateTime.Now.DayOfWeek - fdow) - 8).Date; } else if (cmb_days.Text.ToUpper() == "THIS MONTH") { dtp_from.Value = DateTime.Today.AddDays(-(DateTime.Today.Day - 1)); dtp_to.Value = DateTime.Today; } else if (cmb_days.Text.ToUpper() == "LAST MONTH") { DateTime LastMonthLastDate = DateTime.Today.AddDays(0 - DateTime.Today.Day); DateTime LastMonthFirstDate = LastMonthLastDate.AddDays(1 - LastMonthLastDate.Day); dtp_from.Value = LastMonthFirstDate; dtp_to.Value = LastMonthLastDate; } else if (cmb_days.Text.ToUpper() == "LAST TO LAST MONTH") { DateTime LastMonthLastDate = DateTime.Today.AddDays(0 - DateTime.Today.Day); DateTime LastMonthFirstDate = LastMonthLastDate.AddDays(1 - LastMonthLastDate.Day); dtp_from.Value = new DateTime(DateTime.Today.Year, DateTime.Today.Month - 2, 1); dtp_to.Value = new DateTime(DateTime.Today.Year, DateTime.Today.Month - 1, 1).AddDays(-1); } else if (cmb_days.Text.ToUpper() == "ALL") { dtp_from.Value = new DateTime(2016, 8, 1); dtp_to.Value = DateTime.Today; } btn_load.PerformClick(); } }
private void dgv_on_invoice_CellEndEdit(object sender, DataGridViewCellEventArgs e) { if (dgv_on_invoice.Rows.Count > 0) { if (dgv_on_invoice.Columns[dgv_on_invoice.CurrentCell.ColumnIndex].HeaderText.ToUpper() != "CURSORAMT") { Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, dgv_on_invoice.CurrentRow.Index, "payamt"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, dgv_on_invoice.CurrentRow.Index, "outamt"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, dgv_on_invoice.CurrentRow.Index, "remamt"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, dgv_on_invoice.CurrentRow.Index, "cursoramt"); if (dgv_on_invoice.Columns[dgv_on_invoice.CurrentCell.ColumnIndex].HeaderText.ToUpper() == "REMAMT") { //if (Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["remamt"].Value.ToString()) == 0) { dgv_on_invoice.CurrentRow.Cells["cursoramt"].Value = Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["outamt"].Value.ToString()) - Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["payamt"].Value.ToString()) - Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["remamt"].Value.ToString()); } } if (Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["payamt"].Value.ToString()) > Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["outamt"].Value.ToString())) { dgv_on_invoice.CurrentRow.Cells["payamt"].Value = dgv_on_invoice.CurrentRow.Cells["outamt"].Value.ToString(); } else { dgv_on_invoice.CurrentRow.Cells["remamt"].Value = Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["outamt"].Value.ToString()) - Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["payamt"].Value.ToString()) - Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["cursoramt"].Value.ToString()); } decimal pay_amount = 0.00M; decimal set_amount = 0.00M; for (int i = 0; i <= dgv_on_invoice.CurrentRow.Index; i++) { set_amount = set_amount + Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["payamt"].Value.ToString()); } if (Convert.ToDecimal(txt_credit.Text) > 0) { pay_amount = Convert.ToDecimal(txt_credit.Text) - set_amount; } if (Convert.ToDecimal(txt_debit.Text) > 0) { pay_amount = Convert.ToDecimal(txt_debit.Text) - set_amount; } if (pay_amount < 0) { dgv_on_invoice.CurrentRow.Cells["payamt"].Value = Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["payamt"].Value.ToString()) + pay_amount; pay_amount = 0; if (dgv_on_invoice.Columns[dgv_on_invoice.CurrentCell.ColumnIndex].HeaderText.ToUpper() == "REMAMT") { //if (Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["remamt"].Value.ToString()) == 0) { dgv_on_invoice.CurrentRow.Cells["cursoramt"].Value = Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["outamt"].Value.ToString()) - Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["payamt"].Value.ToString()) - Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["remamt"].Value.ToString()); } } if (Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["payamt"].Value.ToString()) > Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["outamt"].Value.ToString())) { dgv_on_invoice.CurrentRow.Cells["payamt"].Value = dgv_on_invoice.CurrentRow.Cells["outamt"].Value.ToString(); } else { dgv_on_invoice.CurrentRow.Cells["remamt"].Value = Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["outamt"].Value.ToString()) - Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["payamt"].Value.ToString()) - Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["cursoramt"].Value.ToString()); } } //pay_amount = Convert.ToDecimal(dgv_on_invoice.CurrentRow.Cells["payamt"].Value.ToString()); for (int i = dgv_on_invoice.CurrentRow.Index + 1; i < dgv_on_invoice.Rows.Count; i++) { //if (pay_amount > 0) { if (pay_amount > Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["outamt"].Value.ToString())) { pay_amount = pay_amount - Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["outamt"].Value.ToString()); dgv_on_invoice.Rows[i].Cells["payamt"].Value = dgv_on_invoice.Rows[i].Cells["outamt"].Value.ToString(); dgv_on_invoice.Rows[i].Cells["remamt"].Value = "0"; dgv_on_invoice.Rows[i].Cells["cursoramt"].Value = "0"; } else { dgv_on_invoice.Rows[i].Cells["payamt"].Value = pay_amount; dgv_on_invoice.Rows[i].Cells["remamt"].Value = Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["outamt"].Value.ToString()) - Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["payamt"].Value.ToString()) - Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["cursoramt"].Value.ToString()); pay_amount = 0.00M; } } } if (pay_amount > 0) { if (dgv_on_invoice.Rows.Count > 0) { for (int i = 0; i < dgv_on_invoice.Rows.Count; i++) { if (Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["payamt"].Value.ToString()) > 0) { dgv_on_invoice.Rows[i].Cells["cursoramt"].Value = Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["cursoramt"].Value.ToString()) - pay_amount; break; } } } //MessageBox.Show("Invoice Outstanding Is Lower than Enter Amount.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); //return; } } on_invoice_count(); } }
private void cmb_ser_account_Leave(object sender, EventArgs e) { Set_Comboas_Null.Check_Item_Exist_In_Combo(cmb_ser_account); }
private void cmb_party_Leave(object sender, EventArgs e) { Set_Comboas_Null.Check_Item_Exist_In_Combo(cmb_party); }
private void btn_save_Click(object sender, EventArgs e) { if (cmb_main.Text == "") { MessageBox.Show("Please Select Account.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cmb_main.Focus(); return; } if (cmb_party.Text == "") { MessageBox.Show("Please Select Party.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cmb_party.Focus(); return; } if (cmb_main.Text == cmb_party.Text) { MessageBox.Show("Please Select Another Party.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cmb_party.Focus(); return; } if (cmb_payment.Text == "") { MessageBox.Show("Please Select Payment.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cmb_payment.Focus(); return; } decimal pay_amount = 0.00M; for (int i = 0; i < dgv_on_invoice.RowCount; i++) { if (Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["payamt"].Value.ToString()) > 0) { pay_amount = pay_amount + Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["payamt"].Value.ToString()); if (Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["cursoramt"].Value.ToString()) < 0) { pay_amount = pay_amount - Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["cursoramt"].Value.ToString()); } } } generate_voucher(); Set_Comboas_Null.Set_Zero_If_Null_Textedit(txt_credit); Set_Comboas_Null.Set_Zero_If_Null_Textedit(txt_debit); string cr_dr = ""; decimal us = 0.00M; if (Convert.ToDecimal(txt_credit.Text) > 0) { cr_dr = "CREDIT"; us = Convert.ToDecimal(txt_credit.Text); } else { cr_dr = "DEBIT"; us = Convert.ToDecimal(txt_debit.Text); } if (check_on_inv == 1) { //if (us != pay_amount) //{ // MessageBox.Show("Invoice Amount and Total Amount Not Match.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} } if (p_id == "") { p_id = sp_sqlconnection.dml_sp_id("payment_detail", "qtype=insert|account=" + cmb_main.Text + "|voucher=" + txt_voucher.Text + "|party=" + cmb_party.Text + "|date=" + Convert.ToDateTime(dtp_date.Text).ToString("MM-dd-yyyy") + "|payment_type=" + cmb_payment.Text + "|credit_debit=" + cr_dr + "|currency=USD|usd=" + us + "|rate=1|amount=" + us + "|description=" + txt_description.Text + "|status=0|u_id=" + UserDetail.user_id + "|c_id=" + UserDetail.c_id + ""); if (p_id != "" && cmb_payment.SelectedIndex == 0) { for (int i = 0; i < dgv_on_invoice.RowCount; i++) { Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, i, "payamt"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, i, "remamt"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_on_invoice, i, "cursoramt"); string inv_no = ""; if (Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["payamt"].Value.ToString()) > 0 || Convert.ToDecimal(dgv_on_invoice.Rows[i].Cells["cursoramt"].Value.ToString()) > 0) { string[] inv_ = dgv_on_invoice.Rows[i].Cells["invbillno"].Value.ToString().Split('['); string[] bill_ = inv_[1].Split(']'); sp_sqlconnection.dml_sp_id("payment_tran_detail", "qtype=insert|inv_type=" + dgv_on_invoice.Rows[i].Cells["type"].Value.ToString() + "|voucher=" + txt_voucher.Text + "|account=" + cmb_main.Text + "|invoice=" + inv_[0] + "|billno=" + bill_[0] + "|credit_debit=" + cr_dr + "|party=" + cmb_party.Text + "|currency=USD|usd=" + dgv_on_invoice.Rows[i].Cells["payamt"].Value.ToString() + "|rate=1|amount=" + dgv_on_invoice.Rows[i].Cells["payamt"].Value.ToString() + "|status=0|u_id=" + UserDetail.user_id + "|c_id=" + UserDetail.c_id + ""); sp_sqlconnection.dml_sp("pur_sale_detail", "qtype=update_payment|c_id=" + UserDetail.c_id + "|inv_type=" + dgv_on_invoice.Rows[i].Cells["type"].Value.ToString() + "|inv_no=" + inv_[0] + "|remain_amount_$=" + dgv_on_invoice.Rows[i].Cells["remamt"].Value.ToString() + "|cursor_amount_$=" + dgv_on_invoice.Rows[i].Cells["cursoramt"].Value.ToString() + ""); } } } check_on_inv = 0; MessageBox.Show("Data Successfully Save", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } reset(); }
private void btn_save_Click(object sender, EventArgs e) { try { #region validation Set_Comboas_Null.Set_Zero_If_Null_Textbox(txt_due_days); Set_Comboas_Null.Check_Item_Exist_In_Combo(cmb_party); if (cmb_party.Text.Trim() == "") { MessageBox.Show("Please Select Party", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cmb_party.Focus(); return; } Set_Comboas_Null.Check_Item_Exist_In_Combo(cmb_category); if (cmb_category.Text.Trim() == "") { MessageBox.Show("Please Select category", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cmb_category.Focus(); return; } Set_Comboas_Null.Check_Item_Exist_In_Combo(cmb_type); if (cmb_type.Text.Trim() == "") { MessageBox.Show("Please Select category", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cmb_type.Focus(); return; } //Set_Comboas_Null.Check_Item_Exist_In_Combo(cmb_broker); //if (cmb_broker.Text.Trim() == "") //{ // MessageBox.Show("Please Select Broker", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); // cmb_party.Focus(); // return; //} #endregion #region insert & update txt_inv_no.Text = gen_inv_voucher.gen_invoice_no_pur_sale("SALE").ToString(); string date = Convert.ToDateTime(dtp_date.Value.Date).ToString("MM-dd-yyyy"); string due_date = Convert.ToDateTime(dtp_date.Value.Date).ToString("MM-dd-yyyy"); if (pur_id == "") { pur_id = sp_sqlconnection.dml_sp_id("pur_sale_detail", "qtype=insert|inv_type=SALE|date=" + date + "|inv_no=" + txt_inv_no.Text + "|voucher=" + txt_voucher.Text.Trim().ToUpper() + "|party=" + cmb_party.Text.ToUpper().Trim() + "|type=" + cmb_type.Text.ToUpper().Trim() + "|category=" + cmb_category.Text.ToUpper().Trim() + "|broker=" + cmb_broker.Text.ToUpper().Trim() + "|due_days=0|due_date=" + due_date + "|remark=" + txt_remark.Text + "|amount=" + txt_amount.Text + "|cgst_per=" + txt_cgst_per.Text + "|cgst_amt=" + txt_cgst_amount.Text + "|sgst_per=" + txt_sgst_per.Text + "|sgst_amt=" + txt_sgst_amount.Text + "|igst_per=" + txt_igst_per.Text + "|igst_amt=" + txt_igst_amount.Text + "|final_amt=" + txt_final_amount.Text + "|remain_amt=" + txt_final_amount.Text + "|cursor_amt=0.00|c_id=" + UserDetail.c_id + "|y_id=" + UserDetail.y_id + "|u_id=" + UserDetail.user_id + "|w_id=" + UserDetail.w_id + ""); string ins_detail = ""; for (int i = 0; i < dgv_detail.RowCount - 1; i++) { ins_detail = ins_detail + "insert into pur_sale_tran_tbl (ps_id, date, inv_type, type, item, bag, qty, rate, measure, brokerage, amount, c_id, y_id, u_id, w_id) output inserted.pst_id values (" + pur_id + ",'" + date + "','SALE','" + cmb_type.Text.ToUpper() + "','" + dgv_detail.Rows[i].Cells["item"].Value.ToString() + "'," + dgv_detail.Rows[i].Cells["bag"].Value.ToString() + "," + dgv_detail.Rows[i].Cells["qty"].Value.ToString() + "," + dgv_detail.Rows[i].Cells["rate"].Value.ToString() + ",'" + dgv_detail.Rows[i].Cells["measure"].Value.ToString() + "'," + dgv_detail.Rows[i].Cells["brokerage"].Value.ToString() + "," + dgv_detail.Rows[i].Cells["amount"].Value.ToString() + "," + UserDetail.c_id + "," + UserDetail.y_id + "," + UserDetail.user_id + "," + UserDetail.w_id + "); "; } sqlconnection.insertdata_id(ins_detail); } else { sp_sqlconnection.dml_sp("pur_sale_detail", "qtype=update|ps_id=" + pur_id + "|inv_type=SALE|date=" + date + "|inv_no=" + txt_inv_no.Text + "|voucher=" + txt_voucher.Text.Trim().ToUpper() + "|party=" + cmb_party.Text.ToUpper().Trim() + "|type=" + cmb_type.Text.ToUpper().Trim() + "|category=" + cmb_category.Text.ToUpper().Trim() + "|broker=" + cmb_broker.Text.ToUpper().Trim() + "|due_days=|due_date=" + due_date + "|remark=" + txt_remark.Text + "|amount=" + txt_amount.Text + "|cgst_per=" + txt_cgst_per.Text + "|cgst_amt=" + txt_cgst_amount.Text + "|sgst_per=" + txt_sgst_per.Text + "|sgst_amt=" + txt_sgst_amount.Text + "|igst_per=" + txt_igst_per.Text + "|igst_amt=" + txt_igst_amount.Text + "|final_amt=" + txt_final_amount.Text + "|remain_amt=" + txt_final_amount.Text + "|cursor_amt=0.00|c_id=" + UserDetail.c_id + "|y_id=" + UserDetail.y_id + "|u_id=" + UserDetail.user_id + "|w_id=" + UserDetail.w_id + ""); string ins_detail = ""; sp_sqlconnection.dml_sp("pur_sale_tran_detail", "qtype=delete|ps_id=" + pur_id + ""); for (int i = 0; i < dgv_detail.RowCount - 1; i++) { ins_detail = ins_detail + "insert into pur_sale_tran_tbl (ps_id, date, inv_type, type, item, bag, qty, rate, measure, brokerage, amount, c_id, y_id, u_id, w_id) output inserted.pst_id values (" + pur_id + ",'" + date + "','SALE','" + cmb_type.Text.ToUpper() + "','" + dgv_detail.Rows[i].Cells["item"].Value.ToString() + "'," + dgv_detail.Rows[i].Cells["bag"].Value.ToString() + "," + dgv_detail.Rows[i].Cells["qty"].Value.ToString() + "," + dgv_detail.Rows[i].Cells["rate"].Value.ToString() + ",'" + dgv_detail.Rows[i].Cells["measure"].Value.ToString() + "'," + dgv_detail.Rows[i].Cells["brokerage"].Value.ToString() + "," + dgv_detail.Rows[i].Cells["amount"].Value.ToString() + "," + UserDetail.c_id + "," + UserDetail.y_id + "," + UserDetail.user_id + "," + UserDetail.w_id + "); "; } sqlconnection.insertdata_id(ins_detail); } #endregion MessageBox.Show("Data Save Successfully.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); reset(); } catch (Exception) { } }
private void dgv_detail_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { if (dgv_detail.Columns[e.ColumnIndex].HeaderText.ToUpper() == "ITEM") { Set_Comboas_Null.Set_null_If_Null_GridCell(dgv_detail, dgv_detail.CurrentRow.Index, "item"); Set_Comboas_Null.Set_null_If_Null_GridCell(dgv_detail, dgv_detail.CurrentRow.Index, "measure"); dgv_detail.CurrentRow.Cells["measure"].Value = stock.get_measurement(dgv_detail.CurrentRow.Cells["item"].Value.ToString().ToUpper()); if (dgv_detail.CurrentRow.Cells["lotno"].Value.ToString() == "") { dgv_detail.CurrentCell = dgv_detail.CurrentRow.Cells["item"]; } } if (dgv_detail.Columns[e.ColumnIndex].HeaderText.ToUpper() == "QTY") { Set_Comboas_Null.Set_null_If_Null_GridCell(dgv_detail, dgv_detail.CurrentRow.Index, "item"); Set_Comboas_Null.Set_null_If_Null_GridCell(dgv_detail, dgv_detail.CurrentRow.Index, "measure"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_detail, dgv_detail.CurrentRow.Index, "rate"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_detail, dgv_detail.CurrentRow.Index, "qty"); Set_Comboas_Null.Set_Zero_If_Null_GridCell(dgv_detail, dgv_detail.CurrentRow.Index, "brokerage"); if (dgv_detail.Rows[dgv_detail.CurrentRow.Index].Cells["measure"].Value.ToString() == "MT") { int bag_count = 0; decimal bag_weight = 0.00M; bag_weight = stock.get_bag_weight(dgv_detail.CurrentRow.Cells["item"].Value.ToString().ToUpper()); decimal qty = 0.00M; qty = Convert.ToDecimal(dgv_detail.CurrentRow.Cells["qty"].Value.ToString()); if (qty > 0 && bag_weight > 0) { bag_count = Convert.ToInt32((qty * 1000) / bag_weight); } dgv_detail.CurrentRow.Cells["bag"].Value = bag_count.ToString(); } if (dgv_detail.Rows[dgv_detail.CurrentRow.Index].Cells["measure"].Value.ToString() != "MT") { int bag_count = 0; decimal bag_weight = 0.00M; bag_weight = stock.get_bag_weight(dgv_detail.CurrentRow.Cells["item"].Value.ToString().ToUpper()); decimal qty = 0.00M; qty = Convert.ToDecimal(dgv_detail.CurrentRow.Cells["qty"].Value.ToString()); if (qty > 0 && bag_weight > 0) { bag_count = Convert.ToInt32(Math.Floor((qty) / bag_weight)); } dgv_detail.CurrentRow.Cells["bag"].Value = bag_count.ToString(); } if (Convert.ToDecimal(dgv_detail.CurrentRow.Cells["rate"].Value.ToString()) > 0.00M) { decimal qty_rate = 0.00M; qty_rate = Convert.ToDecimal(dgv_detail.CurrentRow.Cells["rate"].Value.ToString().ToUpper()); decimal qty = 0.00M; qty = Convert.ToDecimal(dgv_detail.CurrentRow.Cells["qty"].Value.ToString()); decimal qty_amount = qty * qty_rate; dgv_detail.CurrentRow.Cells["amount"].Value = qty_amount.ToString("0.00"); count_amount(); } //dgv_detail.CurrentRow.Cells["lotno"].Value = stock.get_lotno(dgv_detail.CurrentRow.Cells["refno"].Value.ToString().ToUpper()); ////if (dgv_detail.CurrentRow.Cells["kapan"].Value.ToString() == "") //{ // dgv_detail.CurrentRow.Cells["kapan"].Value = stock.get_kapan(dgv_detail.CurrentRow.Cells["refno"].Value.ToString().ToUpper()); //} //if (dgv_detail.CurrentRow.Cells["lotno"].Value.ToString() == "") //{ // dgv_detail.CurrentCell = dgv_detail.CurrentRow.Cells["refno"]; //} } if (dgv_detail.Columns[e.ColumnIndex].HeaderText.ToUpper() == "RATE") { decimal qty_rate = 0.00M; qty_rate = Convert.ToDecimal(dgv_detail.CurrentRow.Cells["rate"].Value.ToString().ToUpper()); decimal qty = 0.00M; qty = Convert.ToDecimal(dgv_detail.CurrentRow.Cells["qty"].Value.ToString()); decimal qty_amount = qty * qty_rate; dgv_detail.CurrentRow.Cells["amount"].Value = qty_amount.ToString("0.00"); count_amount(); } } catch (Exception) { } }
private void btn_save_Click(object sender, EventArgs e) { try { #region Validation if (txt_party_name.Text.Trim() == "") { MessageBox.Show("Please Enter Party Name.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); txt_party_name.Focus(); return; } Set_Comboas_Null.Check_Item_Exist_In_Combo(cmb_category); if (cmb_category.Text == "") { MessageBox.Show("Please Enter Category.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cmb_category.Focus(); return; } #endregion if (txt_broker.Text != "") { DataRow[] checkentry = dt_category.Select("p_name='" + txt_broker.Text.Trim().ToUpper() + "'"); if (checkentry.Length == 0) { MessageBox.Show("Broker Not Found", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); txt_broker.Focus(); txt_broker.Text = ""; return; } } string ins_id = ""; #region Insert & Update if (p_id == "") { ins_id = sp_sqlconnection.dml_sp_id("party_detail", "qtype=insert|p_name=" + txt_party_name.Text.Trim().ToUpper() + "|address=" + txt_address.Text.Trim().ToUpper() + "|category=" + cmb_category.Text.Trim().ToUpper() + "|acc_no=" + txt_bank_acc_no.Text.Trim().ToUpper() + "|pan_no=" + txt_pan_no.Text.Trim().ToUpper() + "|city=" + txt_city.Text.Trim().ToUpper() + "|state=" + txt_state.Text.Trim().ToUpper() + "|ifsc_code=" + txt_bank_ifsc.Text.Trim().ToUpper() + "|bank_name=" + txt_bank_name.Text.Trim().ToUpper() + "|bank_address=" + txt_bank_address.Text.Trim().ToUpper() + "|gst=" + txt_gst.Text.Trim().ToUpper() + "|email=" + txt_email.Text.Trim().ToUpper() + "|phone=" + txt_phone.Text.Trim().ToUpper() + "|mob_no=" + txt_mob_no.Text.Trim().ToUpper() + "|broker=" + txt_broker.Text.Trim().ToUpper() + "|remark=" + txt_remark.Text.Trim().ToUpper() + "|c_id=" + UserDetail.c_id + "|u_id=" + UserDetail.user_id + "|w_id=0"); } else { //Update Section if (Inserted_Value != txt_party_name.Text) { DataRow[] checkentry = dt_party.Select("p_name='" + txt_party_name.Text.Trim().ToUpper() + "'"); if (checkentry.Length > 0) { MessageBox.Show("Already Exist", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); txt_party_name.Focus(); return; } } ins_id = sp_sqlconnection.dml_sp("party_detail", "qtype=update|p_name=" + txt_party_name.Text.Trim().ToUpper() + "|address=" + txt_address.Text.Trim().ToUpper() + "|category=" + cmb_category.Text.Trim().ToUpper() + "|acc_no=" + txt_bank_acc_no.Text.Trim().ToUpper() + "|pan_no=" + txt_pan_no.Text.Trim().ToUpper() + "|city=" + txt_city.Text.Trim().ToUpper() + "|state=" + txt_state.Text.Trim().ToUpper() + "|ifsc_code=" + txt_bank_ifsc.Text.Trim().ToUpper() + "|bank_name=" + txt_bank_name.Text.Trim().ToUpper() + "|bank_address=" + txt_bank_address.Text.Trim().ToUpper() + "|gst=" + txt_gst.Text.Trim().ToUpper() + "|email=" + txt_email.Text.Trim().ToUpper() + "|phone=" + txt_phone.Text.Trim().ToUpper() + "|mob_no=" + txt_mob_no.Text.Trim().ToUpper() + "|broker=" + txt_broker.Text.Trim().ToUpper() + "|remark=" + txt_remark.Text.Trim().ToUpper() + "|u_id=" + UserDetail.user_id + "|p_id=" + p_id + ""); } #endregion if (ins_id != "") { MessageBox.Show("Data Successfully Save.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); reset(); } } catch (Exception) { } }