- private void btn_Save_Click(object sender, EventArgs e)
- {
- try
- {
- if (txtbill_no.Text.Trim() == string.Empty)
- {
- MessageBox.Show("Please Enter Bill Number");
- return;
- }
- double amount = 0.0;
- double V_TAX = 0.0;
- double SER_TAX = 0.0;
- S_Amount = 0;
- V_Amount = 0;
- string vBILL_Number = "";
- vBILL_Number = (txtbill_no.Text != "") ? txtbill_no.Text : "";
- Gbl_Cls.Write_LogFile("bILL nO : " + vBILL_Number);
- if (vBILL_Number == "")
- {
- MessageBox.Show("Insert Bill No ...");
- txtbill_no.Focus();
- return;
- }
- if (dataGridView1.Rows.Count > 0)
- {
- for (int count = 0; count < dataGridView1.Rows.Count - 1; count++)
- {
- DataGridViewRow Row = dataGridView1.Rows[count];
- int i = 0;
- //overload function
- i = Insert_Prd_Recoard(vBILL_Number, Row.Cells[0].Value.ToString(), Row.Cells[1].Value.ToString(), Row.Cells[2].Value.ToString(), Row.Cells[3].Value.ToString(), Row.Cells[6].Value.ToString(), Row.Cells[8].Value.ToString());
- amount += double.Parse(Row.Cells[3].Value.ToString());
- if ((Row.Cells[8].Value.ToString().Trim()) != "0.00")
- {
- V_TAX += double.Parse(Row.Cells[8].Value.ToString());
- V_Amount += double.Parse(Row.Cells[3].Value.ToString());
- }
- if ((Row.Cells[6].Value.ToString().Trim()) != "0.00")
- {
- SER_TAX += double.Parse(Row.Cells[6].Value.ToString());
- S_Amount += double.Parse(Row.Cells[3].Value.ToString());
- }
- if (i >= 0)
- {
- }
- }
- double amount1 = amount + V_TAX + SER_TAX;
- amount1 = Math.Round(amount1);
- Insert_BillRecoard(vBILL_Number, dtp_date.Text, CO_CODE, CO_NAME, amount.ToString(), V_Amount.ToString(), V_TAX.ToString(), SER_TAX.ToString(), S_Amount.ToString(), amount1.ToString());
- } else
- {
- MessageBox.Show("Bill Amount Null..", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- btnadd.BackColor = System.Drawing.Color.Yellow;
- }
- Reset();
- } catch (Exception ex)
- {
- Gbl_Cls.Write_LogFile(ex.Message);
- MessageBox.Show(ex.ToString());
- }
- }
- private int Insert_Prd_Recoard(string vBILL_Number, string vNarat, string vQuantity, string vRate, string vAmount, string StaxAmt, string vvatAmt)
- {
- OleDbConnection con = conection();
- OleDbCommand cmd;
- int i = 0;
- try
- {
- long ID = 0;
- string str = "insert into bilt ([BILL_Number],[year],[BilDate],[CPART],[CQTY],[CRATE],[Amount],[SER_TAX],[V_Amount],[ED_CESS],[HSE_CESS]) " + " values ('" + vBILL_Number + "','" + "/" + cmb_year.SelectedItem.ToString() + "',cdate('" + dtp_date.Text + "'),'" + vNarat + "'," + vQuantity + "," + vRate + "," + Convert.ToDouble(vAmount).ToString("###0.00") + "," + Convert.ToDouble(StaxAmt).ToString("###0.00") + "," + Convert.ToDouble(vvatAmt).ToString("###0.00") + "," + (Convert.ToDouble(StaxAmt) * 0.02).ToString("###0.00") + "," + (Convert.ToDouble(StaxAmt) * 0.01).ToString("###0.00") + ");";
- Gbl_Cls.Write_LogFile("INSERT RECOARD : " + str);
- cmd = new OleDbCommand(str, con);
- i = cmd.ExecuteNonQuery();
- } catch (Exception ex)
- {
- Gbl_Cls.Write_LogFile(ex.Message);
- MessageBox.Show(ex.ToString());
- }
- return i;
- }
- private int Insert_BillRecoard(string vBILL_Number, string Bill_Date, string CO_Code, string CO_Name, string vTotal_price, string V_AMOUNT, string V_TAX, string SER_TAX, string S_AMOUNT, string include_tax_amount)
- {
- OleDbConnection con = conection();
- OleDbCommand cmd;
- int cont_recoard = 0;
- try
- {
- string sstr = "insert into BilMST([BILLNO],[Year],[BIL_DATE],[CO_CODE],[CO_NAME],[AMOUNT],[S_AMOUNT],[SER_TAX],[V_AMOUT],[V_TAX],[Address],[ADD2],[ADD3],[ADD4],[PO_Number],[PO_Date],[ED_CESS],[HSE_CESS],[AMT_WORD],[IncludeTax_AMT]) VALUES ('" + vBILL_Number + "','" + "/" + cmb_year.SelectedItem.ToString() + "','" + Bill_Date + "'," + CO_Code + ",'" + CO_Name + "'," + vTotal_price + "," + Convert.ToDouble(S_AMOUNT).ToString("###0.00") + "," + Convert.ToDouble(SER_TAX).ToString("###0.00") + "," + Convert.ToDouble(V_AMOUNT).ToString("###0.00") + "," + V_TAX + ",'" + richTextBox1.Text + "','" + ricadd2.Text + "','" + add3.Text.Trim() + "','" + txtpin.Text.Trim() + "','" + txtponumber.Text.Trim() + "',('" + ddlpodate.Text + "')," + (Convert.ToDouble(SER_TAX) * 0.02).ToString("###0.00") + "," + (Convert.ToDouble(SER_TAX) * 0.01).ToString("###0.00") + ",'" + ConvertNumbertoWords(Convert.ToInt64(include_tax_amount)) + " ONLY" + "'," + include_tax_amount + ")";
- cmd = new OleDbCommand(sstr, con);
- Gbl_Cls.Write_LogFile("INSERT RECOARD bilmst : " + sstr);
- cont_recoard = cmd.ExecuteNonQuery();
- if (cont_recoard > 0)
- {
- MessageBox.Show("Bill NO : '" + vBILL_Number + "' genrate Sucessfully ", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- rtb_narat.Focus();
- }
- } catch (Exception ex)
- {
- Gbl_Cls.Write_LogFile(ex.Message);
- MessageBox.Show(ex.ToString());
- }
- return cont_recoard;
- }
In this code we will learn the function overloading in c#.
