问题描述
我有一张有发票的访问表,没有主键和自动递增的值(在代码中我只写了cloumn和Inctrement +1)我希望每个金融年都应该开始发票(来自4月1日至3月31日是金融年份)
字段名称数据类型:
INVOICENO数字
状态文本
CUSTOMERNAME文字
ADDRESS1文字
ADDRESS2文字
TINNO文字
PONO文字
运输文字
BILLDATE DTAe /时间
InvoiceType文字
PODATE日期/时间
totalGrossAmt text
totalVatAmt文件
BILLAMT文本
TRANSPORTAMT文本
OTHERAMT textr
FINALAMT文本
ROUNDOFF文字
GRANDTOTAL文字
状态文字
税务文本
我尝试过:
i have one access table having invoice no it has a primary key and auto incremented value(Taking Max no in cloumn and Inctrement +1 in code only i am write) i want invoice no should be started for every finacial year (from april 1st to march 31 is finacial year )
Field Name Datatype:
INVOICENO Number
STATE Text
CUSTOMERNAME Text
ADDRESS1 TEXT
ADDRESS2 text
TINNO Text
PONO Text
TRANSPORT text
BILLDATE Dtae/Time
InvoiceType Text
PODATE date/time
totalGrossAmt text
totalVatAmt Text
BILLAMT Text
TRANSPORTAMT text
OTHERAMT textr
FINALAMT Text
ROUNDOFF text
GRANDTOTAL Text
STATUS Text
TAX Text
What I have tried:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Configuration;
using System.Globalization;
using System.Collections;
using System.Threading;
namespace Victory_Printing
{
public partial class TAXINVOICE : Form
{
public TAXINVOICE()
{
InitializeComponent();
ddlTransaction.SelectedIndex = 1;
FillInvoiceID();
this.ActiveControl = txtCustName;
}
int Ocredit;
int invoice = 1;
int rupees;
string text;
public static string numb;
DataTable Products = new DataTable();
DataTable productdt = new DataTable();
public static int productnum;
AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection();
AutoCompleteStringCollection descriptionCollection = new AutoCompleteStringCollection();
private void btnSave_Click(object sender, EventArgs e)
{
//PopupForm popup = new PopupForm();
// DialogResult dialogresult = popup.ShowDialog();
// if (dialogresult == DialogResult.OK)
// {
// Console.WriteLine("You clicked OK");
// }
// else if (dialogresult == DialogResult.Cancel)
// {
// Console.WriteLine("You clicked either Cancel or X button in the top right corner");
// }
// popup.Dispose();
//DataTable dt = new DataTable();
DataTable dtb = new DataTable();
DataRow dr0 = dtb.NewRow();
DataRow dr1 = dtb.NewRow();
DataRow dr2 = dtb.NewRow();
DataRow dr3 = dtb.NewRow();
DataRow dr4 = dtb.NewRow();
DataRow dr5 = dtb.NewRow();
DataRow dr6 = dtb.NewRow();
DataRow dr7 = dtb.NewRow();
DataRow dr8 = dtb.NewRow();
DataRow dr9 = dtb.NewRow();
DataRow dr10 = dtb.NewRow();
DataRow dr11 = dtb.NewRow();
DataRow dr12 = dtb.NewRow();
DataRow dr13 = dtb.NewRow();
DataRow dr14 = dtb.NewRow();
DataRow dr15 = dtb.NewRow();
DataRow dr16 = dtb.NewRow();
DataRow dr17 = dtb.NewRow();
DataRow dr18 = dtb.NewRow();
// DataRow dr16 = dt.NewRow();
/* Row 1 */
dtb.Columns.Add("SNo");
dtb.Columns.Add("DESCRIPTION");
dtb.Columns.Add("QTY");
dtb.Columns.Add("UOM");
dtb.Columns.Add("PRICE");
dtb.Columns.Add("GROSS AMT");
dtb.Columns.Add("VAT%");
dtb.Columns.Add("VAT AMT");
dtb.Columns.Add("TOTAL");
dr0[0] = txtSno1.Text;
dr0[1] = txtDescription1.Text;
dr0[2] = txtqty1.Text;
dr0[3] = cbUOM1.SelectedItem;
dr0[4] = txtPrice1.Text;
dr0[5] = txtGrossAmt1.Text;
dr0[6] = txtVAT1.Text;
dr0[7] = txtVatAmt1.Text;
dr0[8] = txtTotal1.Text;
dr1[0] = txtSno2.Text;
dr1[1] = txtDescription2.Text;
dr1[2] = txtqty2.Text;
dr1[3] = cbUOM2.SelectedItem;
dr1[4] = txtPrice2.Text;
dr1[5] = txtGrossAmt2.Text;
dr1[6] = txtVAT2.Text;
dr1[7] = txtVatAmt2.Text;
dr1[8] = txtTotal2.Text;
dr2[0] = txtSno3.Text;
dr2[1] = txtDescription3.Text;
dr2[2] = txtqty3.Text;
dr2[3] = cbUOM3.SelectedItem;
dr2[4] = txtPrice3.Text;
dr2[5] = txtGrossAmt3.Text;
dr2[6] = txtVAT3.Text;
dr2[7] = txtVatAmt3.Text;
dr2[8] = txtTotal3.Text;
dr3[0] = txtSno4.Text;
dr3[1] = txtDescription4.Text;
dr3[2] = txtqty4.Text;
dr3[3] = cbUOM4.SelectedItem;
dr3[4] = txtPrice4.Text;
dr3[5] = txtGrossAmt4.Text;
dr3[6] = txtVAT4.Text;
dr3[7] = txtVatAmt4.Text;
dr3[8] = txtTotal4.Text;
dr4[0] = txtSno5.Text;
dr4[1] = txtDescription5.Text;
dr4[2] = txtqty5.Text;
dr4[3] = cbUOM5.SelectedItem;
dr4[4] = txtPrice5.Text;
dr4[5] = txtGrossAmt5.Text;
dr4[6] = txtVAT5.Text;
dr4[7] = txtVatAmt5.Text;
dr4[8] = txtTotal5.Text;
dr5[0] = txtSno6.Text;
dr5[1] = txtDescription6.Text;
dr5[2] = txtqty6.Text;
dr5[3] = cbUOM6.SelectedItem;
dr5[4] = txtPrice6.Text;
dr5[5] = txtGrossAmt6.Text;
dr5[6] = txtVAT6.Text;
dr5[7] = txtVatAmt6.Text;
dr5[8] = txtTotal6.Text;
dr6[0] = txtSno7.Text;
dr6[1] = txtDescription7.Text;
dr6[2] = txtqty7.Text;
dr6[3] = cbUOM7.SelectedItem;
dr6[4] = txtPrice7.Text;
dr6[5] = txtGrossAmt7.Text;
dr6[6] = txtVAT7.Text;
dr6[7] = txtVatAmt7.Text;
dr6[8] = txtTotal7.Text;
dr7[0] = txtSno8.Text;
dr7[1] = txtDescription8.Text;
dr7[2] = txtqty8.Text;
dr7[3] = cbUOM8.SelectedItem;
dr7[4] = txtPrice8.Text;
dr7[5] = txtGrossAmt8.Text;
dr7[6] = txtVAT8.Text;
dr7[7] = txtVatAmt8.Text;
dr7[8] = txtTotal8.Text;
dr8[0] = txtSno9.Text;
dr8[1] = txtDescription9.Text;
dr8[2] = txtqty9.Text;
dr8[3] = cbUOM9.SelectedItem;
dr8[4] = txtPrice9.Text;
dr8[5] = txtGrossAmt9.Text;
dr8[6] = txtVAT9.Text;
dr8[7] = txtVatAmt9.Text;
dr8[8] = txtTotal9.Text;
dr9[0] = txtSno10.Text;
dr9[1] = txtDescription10.Text;
dr9[2] = txtqty10.Text;
dr9[3] = cbUOM10.SelectedItem;
dr9[4] = txtPrice10.Text;
dr9[5] = txtGrossAmt10.Text;
dr9[6] = txtVAT10.Text;
dr9[7] = txtVatAmt10.Text;
dr9[8] = txtTotal10.Text;
dr10[0] = txtSno11.Text;
dr10[1] = txtDescription11.Text;
dr10[2] = txtqty11.Text;
dr10[3] = cbUOM11.SelectedItem;
dr10[4] = txtPrice11.Text;
dr10[5] = txtGrossAmt11.Text;
dr10[6] = txtVAT11.Text;
dr10[7] = txtVatAmt11.Text;
dr10[8] = txtTotal11.Text;
dr11[0] = txtSno12.Text;
dr11[1] = txtDescription12.Text;
dr11[2] = txtqty12.Text;
dr11[3] = cbUOM12.SelectedItem;
dr11[4] = txtPrice12.Text;
dr11[5] = txtGrossAmt12.Text;
dr11[6] = txtVAT12.Text;
dr11[7] = txtVatAmt12.Text;
dr11[8] = txtTotal12.Text;
dr12[0] = txtSno13.Text;
dr12[1] = txtDescription13.Text;
dr12[2] = txtqty13.Text;
dr12[3] = cbUOM13.SelectedItem;
dr12[4] = txtPrice13.Text;
dr12[5] = txtGrossAmt13.Text;
dr12[6] = txtVAT13.Text;
dr12[7] = txtVatAmt13.Text;
dr12[8] = txtTotal13.Text;
dr13[0] = txtSno14.Text;
dr13[1] = txtDescription14.Text;
dr13[2] = txtqty14.Text;
dr13[3] = cbUOM14.SelectedItem;
dr13[4] = txtPrice14.Text;
dr13[5] = txtGrossAmt14.Text;
dr13[6] = txtVAT14.Text;
dr13[7] = txtVatAmt14.Text;
dr13[8] = txtTotal14.Text;
dr14[0] = txtSno15.Text;
dr14[1] = txtDescription15.Text;
dr14[2] = txtqty15.Text;
dr14[3] = cbUOM15.SelectedItem;
dr14[4] = txtPrice15.Text;
dr14[5] = txtGrossAmt15.Text;
dr14[6] = txtVAT15.Text;
dr14[7] = txtVatAmt15.Text;
dr14[8] = txtTotal15.Text;
dr15[0] = txtSno16.Text;
dr15[1] = txtDescription16.Text;
dr15[2] = txtqty16.Text;
dr15[3] = cbUOM16.SelectedItem;
dr15[4] = txtPrice16.Text;
dr15[5] = txtGrossAmt16.Text;
dr15[6] = txtVAT16.Text;
dr15[7] = txtVatAmt16.Text;
dr15[8] = txtTotal16.Text;
dr16[0] = txtSno17.Text;
dr16[1] = txtDescription17.Text;
dr16[2] = txtqty17.Text;
dr16[3] = cbUOM17.SelectedItem;
dr16[4] = txtPrice17.Text;
dr16[5] = txtGrossAmt17.Text;
dr16[6] = txtVAT17.Text;
dr16[7] = txtVatAmt17.Text;
dr16[8] = txtTotal17.Text;
dr17[0] = txtSno18.Text;
dr17[1] = txtDescription18.Text;
dr17[2] = txtqty18.Text;
dr17[3] = cbUOM18.SelectedItem;
dr17[4] = txtPrice18.Text;
dr17[5] = txtGrossAmt18.Text;
dr17[6] = txtVAT18.Text;
dr17[7] = txtVatAmt18.Text;
dr17[8] = txtTotal18.Text;
dr18[0] = txtSno19.Text;
dr18[1] = txtDescription19.Text;
dr18[2] = txtqty19.Text;
dr18[3] = cbUOM19.SelectedItem;
dr18[4] = txtPrice19.Text;
dr18[5] = txtGrossAmt19.Text;
dr18[6] = txtVAT19.Text;
dr18[7] = txtVatAmt19.Text;
dr18[8] = txtTotal19.Text;
if (cbUOM1.SelectedValue != "Select")
{
dtb.Rows.Add(dr0);
}
if (cbUOM2.SelectedValue != "Select")
{
dtb.Rows.Add(dr1);
}
if (cbUOM3.SelectedValue != "Select")
{
dtb.Rows.Add(dr2);
}
if (cbUOM4.SelectedValue != "Select")
{
dtb.Rows.Add(dr3);
}
if (cbUOM5.SelectedValue != "Select")
{
dtb.Rows.Add(dr4);
}
if (cbUOM6.SelectedValue != "Select")
{
dtb.Rows.Add(dr5);
}
if (cbUOM7.SelectedValue != "Select")
{
dtb.Rows.Add(dr6);
}
if (cbUOM8.SelectedValue != "Select")
{
dtb.Rows.Add(dr7);
}
if (cbUOM9.SelectedValue != "Select")
{
dtb.Rows.Add(dr8);
}
if (cbUOM10.SelectedValue != "Select")
{
dtb.Rows.Add(dr9);
}
if (cbUOM11.SelectedValue != "Select")
{
dtb.Rows.Add(dr10);
}
if (cbUOM12.SelectedValue != "Select")
{
dtb.Rows.Add(dr11);
}
if (cbUOM13.SelectedValue != "Select")
{
dtb.Rows.Add(dr12);
}
if (cbUOM14.SelectedValue != "Select")
{
dtb.Rows.Add(dr13);
}
if (cbUOM15.SelectedValue != "Select")
{
dtb.Rows.Add(dr14);
}
if (cbUOM16.SelectedValue != "Select")
{
dtb.Rows.Add(dr15);
}
if (cbUOM17.SelectedValue != "Select")
{
dtb.Rows.Add(dr16);
}
if (cbUOM18.SelectedValue != "Select")
{
dtb.Rows.Add(dr17);
}
if (cbUOM19.SelectedValue != "Select")
{
dtb.Rows.Add(dr18);
}
//if (printDlg.ShowDialog() == DialogResult.OK)
// printDoc.Print();
decimal a = 0, b = String.IsNullOrEmpty(txtFinalAmt.Text) ? 0 : decimal.Parse(txtFinalAmt.Text.Trim());
rupees = Convert.ToInt32(b);
DialogResult dialogResult = MessageBox.Show("Are You Sure??", "Do you want to save?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
//do something
int num = Convert.ToInt32(txtInvoice.Text);
string counterSales_InsertRow = "INSERT INTO TAXINVOICE(INVOICENO,STATE ,CUSTOMERNAME ,ADDRESS1,ADDRESS2,TINNO,PONO,TRANSPORT,InvoiceType,BILLDATE,PODATE,totalGrossAmt,totalVatAmt,BILLAMT,TRANSPORTAMT,OTHERAMT,FINALAMT,ROUNDOFF,GRANDTOTAL,TAX,CurrentYear,CreatedOn)VALUES (@INVOICENO,@STATE,@CUSTOMERNAME,@ADDRESS1,@ADDRESS2,@TINNO,@PONO,@TRANSPORT,@InvoiceType,@BILLDATE,@PODATE,@totalGrossAmt,@totalVatAmt,@BILLAMT,@TRANSPORTAMT,@OTHERAMT,@FINALAMT,@ROUNDOFF,@GRANDTOTAL,@TAX,@CurrentYear,@CreatedOn);";
OleDbParameter[] parameters = new OleDbParameter[22];
parameters[0] = new OleDbParameter("@INVOICENO", num);
//parameters[0] = new OleDbParameter("@INVOICENO", OleDbType.Integer).Value = num;
parameters[1] = new OleDbParameter("@STATE", comboBox1.Text);
parameters[2] = new OleDbParameter("@CUSTOMERNAME", txtCustName.Text.ToUpper());
parameters[3] = new OleDbParameter("@ADDRESS1", txtAddress1.Text);
parameters[4] = new OleDbParameter("@ADDRESS2", txtAddress2.Text);
parameters[5] = new OleDbParameter("@TINNO", txtTINnum.Text);
parameters[6] = new OleDbParameter("@PONO", txtPOnum.Text);
parameters[7] = new OleDbParameter("@TRANSPORT", tbTransportValue.Text.ToUpper());
parameters[8] = new OleDbParameter("@InvoiceType", ddlTransaction.SelectedItem);
parameters[9] = new OleDbParameter("@BILLDATE", Convert.ToDateTime(dtToday.Text));
parameters[10] = new OleDbParameter("@PODATE", CreatedDate.Text);
parameters[11] = new OleDbParameter("@totalGrossAmt", txtTotalGrossAmt.Text);
parameters[12] = new OleDbParameter("@totalVatAmt", txtTotalVATAMT.Text);
parameters[13] = new OleDbParameter("@BILLAMT", txtTotals.Text);
parameters[14] = new OleDbParameter("@TRANSPORTAMT", txtTransport.Text);
parameters[15] = new OleDbParameter("@OTHERAMT", txtOthers.Text);
parameters[16] = new OleDbParameter("@FINALAMT", txtTotals.Text);
parameters[17] = new OleDbParameter("@ROUNDOFF", txtRoundOff.Text);
parameters[18] = new OleDbParameter("@GRANDTOTAL", txtGrandTotal.Text);
parameters[19] = new OleDbParameter("@TAX", txtVAT1.Text);
parameters[20] = new OleDbParameter("@CurrentYear", DateTime.Now.Year);
parameters[21] = new OleDbParameter("@CreatedOn", Convert.ToDateTime(dtToday.Text));
ExecuteOtherGoodsDatabaseTransaction(counterSales_InsertRow, parameters);
InsertAllInvoiceItems();
// string Productscount = "select count()";
GlobalClass.dtHeaders = new DataTable();
Headers dsh = new Headers();
GlobalClass.dtHeaders = dsh.Tables[0];
//numb = ConvertNumbertoWords(number) + "Only";
//for (int i = 0; i < 5; i++)
numb = rupeestoword(rupees);
// rupees(rupees);
foreach (DataRow Datarow in dtb.Rows)
{
DataRow dr = GlobalClass.dtHeaders.NewRow();
dr["CustomerName"] = " " + txtCustName.Text.ToUpper();
dr["Address1"] = " " + txtAddress1.Text;
dr["Address2"] = " " + txtAddress2.Text;
dr["TIN"] = txtTINnum.Text.ToUpper();
dr["InvoiceNo"] = txtInvoice.Text.ToUpper();
dr["InvoiceDate"] = Convert.ToDateTime(dtToday.Text).ToString("dd/MM/yy");
dr["PONo"] = txtPOnum.Text.ToUpper();
dr["Dated"] = CreatedDate.Text;
dr["Transport"] = tbTransportValue.Text.Trim().ToUpper();
dr["SNO"] = Datarow.ItemArray[0];
dr["DESCRIPTION"] = Datarow.ItemArray[1].ToString().ToUpper();
dr["QTY"] = Datarow.ItemArray[2].ToString();
dr["UOM"] = Datarow.ItemArray[3].ToString();
dr["PRICE"] = Datarow.ItemArray[4].ToString();
dr["GROSSAMT"] = Datarow.ItemArray[5].ToString();
dr["VAT"] = Datarow.ItemArray[6].ToString();
dr["VATAMT"] = Datarow.ItemArray[7].ToString();
dr["TOTAL"] = Datarow.ItemArray[8].ToString();
dr["GROSSTOTAL"] = txtTotalGrossAmt.Text;
dr["VATTOTAL"] = txtTotalVATAMT.Text;
dr["TOTALAMT"] = txtTotals.Text;
dr["FINALAMOUNT"] = txtTotals.Text;
dr["AMTINWORDS"] = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(numb.ToLower());
dr["TRANSPORT"] = txtTransport.Text.ToUpper();
dr["OTHERS"] = txtOthers.Text;
dr["ROUNDOFF"] = txtRoundOff.Text;
dr["GRANDTOTAL"] = txtGrandTotal.Text + ".00";
dr["INVOICETYPE"] = ddlTransaction.Text.ToUpper();
GlobalClass.dtHeaders.Rows.Add(dr);
}
Form4 frm = new Form4();
frm.Show();
this.Hide();
clear();
}
else if (dialogResult == DialogResult.No)
{
//this.Close();
}
}
public void clear()
{
// textBox1.Text = "";
txtAddress1.Text = "";
txtAddress2.Text = "";
txtCustName.Text = "";
txtPOnum.Text = "";
txtTINnum.Text = "";
txtTransport.Text = "0.00";
txtOthers.Text = "0.00";
txtFinalAmt.Text = "0.00";
txtGrandTotal.Text = "0.00";
txtRoundOff.Text = "";
tbTransportValue.Text = "";
txtDescription1.Text = "";
txtDescription2.Text = "";
txtDescription3.Text = "";
txtDescription4.Text = "";
txtDescription5.Text = "";
txtDescription6.Text = "";
txtDescription7.Text = "";
txtDescription8.Text = "";
txtDescription9.Text = "";
txtDescription10.Text = "";
txtDescription11.Text = "";
txtDescription12.Text = "";
txtDescription13.Text = "";
txtDescription15.Text = "";
txtDescription14.Text = "";
txtDescription16.Text = "";
txtDescription18.Text = "";
txtDescription17.Text = "";
txtDescription19.Text = "";
txtqty1.Text = "";
txtqty2.Text = "";
txtqty3.Text = "";
txtqty4.Text = "";
txtqty5.Text = "";
txtqty6.Text = "";
txtqty7.Text = "";
txtqty8.Text = "";
txtqty9.Text = "";
txtqty10.Text = "";
txtqty11.Text = "";
txtqty12.Text = "";
txtqty13.Text = "";
txtqty14.Text = "";
txtqty15.Text = "";
txtqty16.Text = "";
txtqty17.Text = "";
txtqty18.Text = "";
txtqty19.Text = "";
txtPrice1.Text = "";
txtPrice2.Text = "";
txtPrice3.Text = "";
txtPrice4.Text = "";
txtPrice5.Text = "";
txtPrice6.Text = "";
txtPrice7.Text = "";
txtPrice8.Text = "";
txtPrice9.Text = "";
txtPrice10.Text = "";
txtPrice11.Text = "";
txtPrice12.Text = "";
txtPrice13.Text = "";
txtPrice14.Text = "";
txtPrice15.Text = "";
txtPrice16.Text = "";
txtPrice17.Text = "";
txtPrice18.Text = "";
txtPrice19.Text = "";
txtSno1.Text = "";
txtSno2.Text = "";
txtSno3.Text = "";
txtSno4.Text = "";
txtSno5.Text = "";
txtSno6.Text = "";
txtSno7.Text = "";
txtSno8.Text = "";
txtSno9.Text = "";
txtSno10.Text = "";
txtSno11.Text = "";
txtSno12.Text = "";
txtSno13.Text = "";
txtSno14.Text = "";
txtSno15.Text = "";
txtSno16.Text = "";
txtSno17.Text = "";
txtSno18.Text = "";
txtSno19.Text = "";
txtGrossAmt1.Text = "";
txtGrossAmt2.Text = "";
txtGrossAmt3.Text = "";
txtGrossAmt4.Text = "";
txtGrossAmt5.Text = "";
txtGrossAmt6.Text = "";
txtGrossAmt7.Text = "";
txtGrossAmt8.Text = "";
txtGrossAmt9.Text = "";
txtGrossAmt10.Text = "";
txtGrossAmt11.Text = "";
txtGrossAmt12.Text = "";
txtGrossAmt13.Text = "";
txtGrossAmt14.Text = "";
txtGrossAmt15.Text = "";
txtGrossAmt16.Text = "";
txtGrossAmt17.Text = "";
txtGrossAmt18.Text = "";
txtGrossAmt19.Text = "";
txtVatAmt1.Text = "";
txtVatAmt2.Text = "";
txtVatAmt3.Text = "";
txtVatAmt4.Text = "";
txtVatAmt5.Text = "";
txtVatAmt6.Text = "";
txtVatAmt7.Text = "";
txtVatAmt8.Text = "";
txtVatAmt9.Text = "";
txtVatAmt10.Text = "";
txtVatAmt11.Text = "";
txtVatAmt12.Text = "";
txtVatAmt13.Text = "";
txtVatAmt14.Text = "";
txtVatAmt15.Text = "";
txtVatAmt16.Text = "";
txtVatAmt17.Text = "";
txtVatAmt18.Text = "";
txtVatAmt19.Text = "";
txtTotal1.Text = "";
txtTotal2.Text = "";
txtTotal3.Text = "";
txtTotal4.Text = "";
txtTotal5.Text = "";
txtTotal6.Text = "";
txtTotal7.Text = "";
txtTotal8.Text = "";
txtTotal9.Text = "";
txtTotal10.Text = "";
txtTotal11.Text = "";
txtTotal12.Text = "";
txtTotal13.Text = "";
txtTotal14.Text = "";
txtTotal15.Text = "";
txtTotal16.Text = "";
txtTotal17.Text = "";
txtTotal18.Text = "";
txtTotal19.Text = "";
txtVAT1.Text = "";
txtVAT2.Text = "";
txtVAT3.Text = "";
txtVAT4.Text = "";
txtVAT5.Text = "";
txtVAT6.Text = "";
txtVAT7.Text = "";
txtVAT8.Text = "";
txtVAT9.Text = "";
txtVAT10.Text = "";
txtVAT11.Text = "";
txtVAT12.Text = "";
txtVAT13.Text = "";
txtVAT14.Text = "";
txtVAT15.Text = "";
txtVAT16.Text = "";
txtVAT17.Text = "";
txtVAT18.Text = "";
txtVAT19.Text = "";
cbUOM1.SelectedValue = "";
cbUOM2.SelectedValue = "";
cbUOM3.SelectedValue = "";
cbUOM4.SelectedValue = "";
cbUOM5.SelectedValue = "";
cbUOM6.SelectedValue = "";
cbUOM7.SelectedValue = "";
cbUOM8.SelectedValue = "";
cbUOM9.SelectedValue = "";
cbUOM10.SelectedValue = "";
cbUOM11.SelectedValue = "";
cbUOM12.SelectedValue = "";
cbUOM13.SelectedValue = "";
cbUOM14.SelectedValue = "";
cbUOM15.SelectedValue = "";
cbUOM16.SelectedValue = "";
cbUOM17.SelectedValue = "";
cbUOM18.SelectedValue = "";
cbUOM19.SelectedValue = "";
FillInvoiceID();
}
private void ExecuteOtherGoodsDatabaseTransaction(string command, OleDbParameter[] parameter)
{
string @filelocation = ConfigurationManager.AppSettings["FilePath"].ToString();
OleDbConnection conn = new OleDbConnection(@filelocation);
//OleDbConnection con = new OleDbConnection(@filelocation);
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
cmd.CommandText = command;
cmd.Parameters.AddRange(parameter);
cmd.CommandType = CommandType.Text;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
private void InsertAllInvoiceItems()
{
for (int controlIndex = 1; controlIndex <= 19; controlIndex++)
{
string name = "txtDescription" + controlIndex;
TextBox txtBox = this.Controls.Find(name, true)[0] as TextBox;
string insertedproductName = txtBox.Text;
name = "txtqty" + controlIndex;
txtBox = this.Controls.Find(name, true)[0] as TextBox;
string insertedquantity = txtBox.Text;
name = "cbUOM" + controlIndex;
ComboBox cmb = this.Controls.Find(name, true)[0] as ComboBox;
string uom = cmb.Text;
name = "txtPrice" + controlIndex;
txtBox = this.Controls.Find(name, true)[0] as TextBox;
string insertedprice = txtBox.Text;
name = "txtGrossAmt" + controlIndex;
txtBox = this.Controls.Find(name, true)[0] as TextBox;
string insertedGrossAmt = txtBox.Text;
name = "txtVAT" + controlIndex;
txtBox = this.Controls.Find(name, true)[0] as TextBox;
string insertedvat = txtBox.Text;
name = "txtVatAmt" + controlIndex;
txtBox = this.Controls.Find(name, true)[0] as TextBox;
string insertedVATamt = txtBox.Text;
name = "txtTotal" + controlIndex;
txtBox = this.Controls.Find(name, true)[0] as TextBox;
string insertedtotal = txtBox.Text;
if (!string.IsNullOrEmpty(insertedproductName))
{
int insertedProductId = GetProductId(insertedproductName);
//InsertIntoInvoiceItems(txtInvoice.Text.Trim(), insertedProductId, insertedquantity, insertedprice, insertedGrossAmt, insertedvat, insertedVATamt, insertedtotal);
InsertIntoInvoiceItems(txtInvoice.Text.Trim(), insertedProductId, insertedquantity, uom, insertedprice, insertedGrossAmt, insertedvat, insertedVATamt, insertedtotal);
}
}
}
private void InsertIntoInvoiceItems(string invoiceNumber, int productId, string quantity, string uom, string price, string GrossAmt, string vat, string vatamount, string total)
{
string InsertInvoiceItems = "INSERT INTO InvoiceItems(InvoiceNumber,ProductId ,Quantity,UOM ,UnitPrice,GrossAmount,VAT,VatAmount,Total)VALUES (@InvoiceNumber,@ProductId,@Quantity,@Uom,@UnitPrice,@GrossAmount,@VAT,@VatAmount,@Total);";
OleDbParameter[] paramet = new OleDbParameter[9];
paramet[0] = new OleDbParameter("@InvoiceNumber", invoiceNumber);
paramet[1] = new OleDbParameter("@ProductId", productId);
paramet[2] = new OleDbParameter("@Quantity", quantity);
paramet[3] = new OleDbParameter("@Uom", uom);
paramet[4] = new OleDbParameter("@UnitPrice", price);
paramet[5] = new OleDbParameter("@GrossAmount", GrossAmt);
paramet[6] = new OleDbParameter("@VAT", vat);
paramet[7] = new OleDbParameter("@VatAmount", vatamount);
paramet[8] = new OleDbParameter("@Total", total);
ExecuteOtherGoodsDatabaseTransaction(InsertInvoiceItems, paramet);
}
private void InsertIntoInvoiceItems(string invoiceNumber, int productId, string quantity, string price, string GrossAmt, string vat, string vatamount, string total)
{
string InsertInvoiceItems = "INSERT INTO InvoiceItems(InvoiceNumber,ProductId ,Quantity ,UnitPrice,GrossAmount,VAT,VatAmount,Total)VALUES (@InvoiceNumber,@ProductId,@Quantity,@UnitPrice,@GrossAmount,@VAT,@VatAmount,@Total);";
OleDbParameter[] paramet = new OleDbParameter[8];
paramet[0] = new OleDbParameter("@InvoiceNumber", invoiceNumber);
paramet[1] = new OleDbParameter("@ProductId", productId);
paramet[2] = new OleDbParameter("@Quantity", quantity);
paramet[3] = new OleDbParameter("@UnitPrice", price);
paramet[4] = new OleDbParameter("@GrossAmount", GrossAmt);
paramet[5] = new OleDbParameter("@VAT", vat);
paramet[6] = new OleDbParameter("@VatAmount", vatamount);
paramet[7] = new OleDbParameter("@Total", total);
ExecuteOtherGoodsDatabaseTransaction(InsertInvoiceItems, paramet);
}
private int GetProductId(string name)
{
int productId = 0;
try
{
productId = fetchProductId(name);
if (productId == 0)
{
if (insertProduct(name))
{
Thread.Sleep(750);
productId = fetchProductId(name);
}
}
}
catch (Exception ex)
{
}
return productId;
}
private bool insertProduct(string name)
{
bool isInsert = false;
string connectionstring = ConfigurationManager.AppSettings["FilePath"].ToString();
string getproductid = "INSERT INTO Products(ProductName) VALUES('" + name.ToString().ToUpper() + "')";
OleDbConnection oledproductidcon = new OleDbConnection(connectionstring);
//OleDbConnection c2 = new OleDbConnection(co);
if (oledproductidcon.State == ConnectionState.Open)
{
oledproductidcon.Close();
}
oledproductidcon.Open();
OleDbCommand oledbproductcmd = new OleDbCommand(getproductid, oledproductidcon);
int rows = oledbproductcmd.ExecuteNonQuery();
if (rows > 0)
{
isInsert = true;
}
return isInsert;
}
private int fetchProductId(string name)
{
int returnProductId = 0;
string connectionstring = ConfigurationManager.AppSettings["FilePath"].ToString();
string getproductid = "SELECT ProductId FROM Products where lcase(ProductName)='" + name.ToLower().ToString() + "'";
OleDbConnection oledproductidcon = new OleDbConnection(connectionstring);
//OleDbConnection c2 = new OleDbConnection(co);
if (oledproductidcon.State == ConnectionState.Open)
{
oledproductidcon.Close();
}
oledproductidcon.Open();
OleDbCommand oledbproductcmd = new OleDbCommand(getproductid, oledproductidcon);
object obj = oledbproductcmd.ExecuteScalar();
if (obj != null)
{
returnProductId = int.Parse(obj.ToString());
}
oledproductidcon.Close();
return returnProductId;
}
private DataTable getqtyandprice(string name)
{
// CommandText = @"SELECT i.Quantity,i.UnitPrice FROM InvoiceItems i INNER JOIN (Products INNER JOIN "
//+ " InvoiceItems ON Products.ProductId = InvoiceItems.ProductId) ON TAXINVOICE.INVOICENO = "
//+ " InvoiceItems.InvoiceNumber WHERE TAXINVOICE.CUSTOMERNAME = '" + customerName + "'";
string s = "SELECT top 1 InvoiceItems.Quantity, InvoiceItems.UnitPrice,InvoiceItems.UOM ,InvoiceItems.Total FROM TAXINVOICE INNER JOIN (InvoiceItems INNER JOIN Products ON InvoiceItems.ProductId = Products.ProductId) ON TAXINVOICE.INVOICENO = InvoiceItems.InvoiceNumber WHERE TAXINVOICE.customername ='" + txtCustName.Text.ToString() + "' AND Products.ProductName ='" + name.ToString() + " 'order by TAXINVOICE.invoiceno desc";
//string s = "SELECT i.UnitPrice FROM Products p INNER JOIN InvoiceItems i on p.ProductId = i.ProductId where ProductName='" + name.ToString() + "'";
string @filelocations = ConfigurationManager.AppSettings["FilePath"].ToString();
OleDbConnection connections = new OleDbConnection(@filelocations);
//OleDbConnection qpcon = new OleDbConnection();
OleDbCommand qpcmd = new OleDbCommand(s, connections);
OleDbDataAdapter qpdatadpter = new OleDbDataAdapter(qpcmd);
//DataSet datset = new DataSet();
DataTable qpdataset = new DataTable();
qpdatadpter.Fill(qpdataset);
return qpdataset;
}
private void Quantity_Changed(object sender, EventArgs e)
{
TextBox txtqty = (TextBox)sender;
string txtName = txtqty.Name.Replace("txtqty", "");
//GetAndCalculateTotal(txtqty.Name.Substring(txtqty.Name.Length - 1));
GetAndCalculateTotal(txtName);
}
private void Price_Changed(object sender, EventArgs e)
{
TextBox txtqty = (TextBox)sender;
string txtName = txtqty.Name.Replace("txtPrice", "");
//GetAndCalculateTotal(txtqty.Name.Substring(txtqty.Name.Length - 1));
GetAndCalculateTotal(txtName);
}
private decimal CalculateGrossAmt(decimal qty, decimal price)
{
decimal value = qty * price;
return value;
}
private void TextBoxAcceptOnlyNumbers(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
{
e.Handled = true;
}
if (e.KeyChar == '.' && (sender as TextBox).Text.IndexOf('.') > -1)
{
e.Handled = true;
}
}
private decimal CalculateVATAmt(decimal GrossAmt, decimal vat)
{
//int vat = 5;
decimal value = ((GrossAmt * vat) / 100);
return value;
}
private decimal CalculateTotal(decimal GrossAmt, decimal totalamount)
{
//int vat = 5;
decimal value = GrossAmt + totalamount;
return value;
}
private void GetAndCalculateTotal(string selectedNumber)
{
decimal qtyValue = 0;
decimal priceValue = 0;
//decimal discValue = 0;
string ItemVal = "";
decimal GrossAmt = 0;
decimal totalamount = 0;
decimal vatpercent = 0;
switch (selectedNumber)
{
case "1":
qtyValue = String.IsNullOrEmpty(txtqty1.Text) ? 0 : decimal.Parse(txtqty1.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice1.Text) ? 0 : decimal.Parse(txtPrice1.Text.Trim());
txtGrossAmt1.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt1.Text);
vatpercent = String.IsNullOrEmpty(txtVAT1.Text) ? 0 : decimal.Parse(txtVAT1.Text.Trim());
txtVatAmt1.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt1.Text);
txtTotal1.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
break;
case "2":
qtyValue = String.IsNullOrEmpty(txtqty2.Text) ? 0 : decimal.Parse(txtqty2.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice2.Text) ? 0 : decimal.Parse(txtPrice2.Text.Trim());
txtGrossAmt2.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt2.Text);
vatpercent = String.IsNullOrEmpty(txtVAT2.Text) ? 0 : decimal.Parse(txtVAT2.Text.Trim());
txtVatAmt2.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt2.Text);
txtTotal2.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = (decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal2.Text.Trim())).ToString();
break;
case "3":
qtyValue = String.IsNullOrEmpty(txtqty3.Text) ? 0 : decimal.Parse(txtqty3.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice3.Text) ? 0 : decimal.Parse(txtPrice3.Text.Trim());
txtGrossAmt3.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt3.Text);
vatpercent = String.IsNullOrEmpty(txtVAT3.Text) ? 0 : decimal.Parse(txtVAT3.Text.Trim());
txtVatAmt3.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt3.Text);
txtTotal3.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal3.Text.Trim()).ToString();
break;
case "4":
qtyValue = String.IsNullOrEmpty(txtqty4.Text) ? 0 : decimal.Parse(txtqty4.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice4.Text) ? 0 : decimal.Parse(txtPrice4.Text.Trim());
txtGrossAmt4.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt4.Text);
vatpercent = String.IsNullOrEmpty(txtVAT4.Text) ? 0 : decimal.Parse(txtVAT4.Text.Trim());
txtVatAmt4.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt4.Text);
txtTotal4.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
//tbFTotal4.Text = CalculateTotal(qtyValue, priceValue, discValue).ToString();
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal4.Text.Trim()).ToString();
break;
case "5":
qtyValue = String.IsNullOrEmpty(txtqty5.Text) ? 0 : decimal.Parse(txtqty5.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice5.Text) ? 0 : decimal.Parse(txtPrice5.Text.Trim());
txtGrossAmt5.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt5.Text);
vatpercent = String.IsNullOrEmpty(txtVAT5.Text) ? 0 : decimal.Parse(txtVAT5.Text.Trim());
txtVatAmt5.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt5.Text);
txtTotal5.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal5.Text.Trim()).ToString();
break;
case "6":
qtyValue = String.IsNullOrEmpty(txtqty6.Text) ? 0 : decimal.Parse(txtqty6.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice6.Text) ? 0 : decimal.Parse(txtPrice6.Text.Trim());
txtGrossAmt6.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt6.Text);
vatpercent = String.IsNullOrEmpty(txtVAT6.Text) ? 0 : decimal.Parse(txtVAT6.Text.Trim());
txtVatAmt6.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt6.Text);
txtTotal6.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal6.Text.Trim()).ToString();
break;
case "7":
qtyValue = String.IsNullOrEmpty(txtqty7.Text) ? 0 : decimal.Parse(txtqty7.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice7.Text) ? 0 : decimal.Parse(txtPrice7.Text.Trim());
txtGrossAmt7.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt7.Text);
vatpercent = String.IsNullOrEmpty(txtVAT7.Text) ? 0 : decimal.Parse(txtVAT7.Text.Trim());
txtVatAmt7.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt7.Text);
txtTotal7.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
//lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal7.Text.Trim()).ToString();
break;
case "8":
qtyValue = String.IsNullOrEmpty(txtqty8.Text) ? 0 : decimal.Parse(txtqty8.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice8.Text) ? 0 : decimal.Parse(txtPrice8.Text.Trim());
txtGrossAmt8.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt8.Text);
vatpercent = String.IsNullOrEmpty(txtVAT8.Text) ? 0 : decimal.Parse(txtVAT8.Text.Trim());
txtVatAmt8.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt8.Text);
txtTotal8.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal8.Text.Trim()).ToString();
break;
case "9":
qtyValue = String.IsNullOrEmpty(txtqty9.Text) ? 0 : decimal.Parse(txtqty9.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice9.Text) ? 0 : decimal.Parse(txtPrice9.Text.Trim());
txtGrossAmt9.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt9.Text);
vatpercent = String.IsNullOrEmpty(txtVAT9.Text) ? 0 : decimal.Parse(txtVAT9.Text.Trim());
txtVatAmt9.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt9.Text);
txtTotal9.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
//lblTotal.Text = (decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal1.Text.Trim())).ToString();
break;
case "10":
qtyValue = String.IsNullOrEmpty(txtqty10.Text) ? 0 : decimal.Parse(txtqty10.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice10.Text) ? 0 : decimal.Parse(txtPrice10.Text.Trim());
txtGrossAmt10.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt10.Text);
vatpercent = String.IsNullOrEmpty(txtVAT10.Text) ? 0 : decimal.Parse(txtVAT10.Text.Trim());
txtVatAmt10.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt10.Text);
txtTotal10.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = (decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal2.Text.Trim())).ToString();
break;
case "11":
qtyValue = String.IsNullOrEmpty(txtqty11.Text) ? 0 : decimal.Parse(txtqty11.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice11.Text) ? 0 : decimal.Parse(txtPrice11.Text.Trim());
txtGrossAmt11.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt11.Text);
vatpercent = String.IsNullOrEmpty(txtVAT11.Text) ? 0 : decimal.Parse(txtVAT11.Text.Trim());
txtVatAmt11.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt11.Text);
txtTotal11.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal3.Text.Trim()).ToString();
break;
case "12":
qtyValue = String.IsNullOrEmpty(txtqty12.Text) ? 0 : decimal.Parse(txtqty12.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice12.Text) ? 0 : decimal.Parse(txtPrice12.Text.Trim());
txtGrossAmt12.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt12.Text);
vatpercent = String.IsNullOrEmpty(txtVAT12.Text) ? 0 : decimal.Parse(txtVAT12.Text.Trim());
txtVatAmt12.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt12.Text);
txtTotal12.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
//tbFTotal4.Text = CalculateTotal(qtyValue, priceValue, discValue).ToString();
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal4.Text.Trim()).ToString();
break;
case "13":
qtyValue = String.IsNullOrEmpty(txtqty13.Text) ? 0 : decimal.Parse(txtqty13.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice13.Text) ? 0 : decimal.Parse(txtPrice13.Text.Trim());
txtGrossAmt13.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt13.Text);
vatpercent = String.IsNullOrEmpty(txtVAT13.Text) ? 0 : decimal.Parse(txtVAT13.Text.Trim());
txtVatAmt13.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt13.Text);
txtTotal13.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal5.Text.Trim()).ToString();
break;
case "14":
qtyValue = String.IsNullOrEmpty(txtqty14.Text) ? 0 : decimal.Parse(txtqty14.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice14.Text) ? 0 : decimal.Parse(txtPrice14.Text.Trim());
txtGrossAmt14.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt14.Text);
vatpercent = String.IsNullOrEmpty(txtVAT14.Text) ? 0 : decimal.Parse(txtVAT14.Text.Trim());
txtVatAmt14.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt14.Text);
txtTotal14.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal6.Text.Trim()).ToString();
break;
case "15":
qtyValue = String.IsNullOrEmpty(txtqty15.Text) ? 0 : decimal.Parse(txtqty15.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice15.Text) ? 0 : decimal.Parse(txtPrice15.Text.Trim());
txtGrossAmt15.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt15.Text);
vatpercent = String.IsNullOrEmpty(txtVAT15.Text) ? 0 : decimal.Parse(txtVAT15.Text.Trim());
txtVatAmt15.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt15.Text);
txtTotal15.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
//lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal7.Text.Trim()).ToString();
break;
case "16":
qtyValue = String.IsNullOrEmpty(txtqty16.Text) ? 0 : decimal.Parse(txtqty16.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice16.Text) ? 0 : decimal.Parse(txtPrice16.Text.Trim());
txtGrossAmt16.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt16.Text);
vatpercent = String.IsNullOrEmpty(txtVAT16.Text) ? 0 : decimal.Parse(txtVAT16.Text.Trim());
txtVatAmt16.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt16.Text);
txtTotal16.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal8.Text.Trim()).ToString();
break;
case "17":
qtyValue = String.IsNullOrEmpty(txtqty17.Text) ? 0 : decimal.Parse(txtqty17.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice17.Text) ? 0 : decimal.Parse(txtPrice17.Text.Trim());
txtGrossAmt17.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt17.Text);
vatpercent = String.IsNullOrEmpty(txtVAT17.Text) ? 0 : decimal.Parse(txtVAT17.Text.Trim());
txtVatAmt17.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt17.Text);
txtTotal17.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal8.Text.Trim()).ToString();
break;
case "18":
qtyValue = String.IsNullOrEmpty(txtqty18.Text) ? 0 : decimal.Parse(txtqty18.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice18.Text) ? 0 : decimal.Parse(txtPrice18.Text.Trim());
txtGrossAmt18.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt18.Text);
vatpercent = String.IsNullOrEmpty(txtVAT18.Text) ? 0 : decimal.Parse(txtVAT18.Text.Trim());
txtVatAmt18.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt18.Text);
txtTotal18.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal8.Text.Trim()).ToString();
break;
case "19":
qtyValue = String.IsNullOrEmpty(txtqty19.Text) ? 0 : decimal.Parse(txtqty19.Text.Trim());
priceValue = String.IsNullOrEmpty(txtPrice19.Text) ? 0 : decimal.Parse(txtPrice19.Text.Trim());
txtGrossAmt19.Text = ((float)CalculateGrossAmt(qtyValue, priceValue)).ToString("0.00");
GrossAmt = Convert.ToDecimal(txtGrossAmt19.Text);
vatpercent = String.IsNullOrEmpty(txtVAT19.Text) ? 0 : decimal.Parse(txtVAT19.Text.Trim());
txtVatAmt19.Text = ((float)CalculateVATAmt(GrossAmt, vatpercent)).ToString("0.00");
totalamount = Convert.ToDecimal(txtVatAmt19.Text);
txtTotal19.Text = ((float)CalculateTotal(GrossAmt, totalamount)).ToString("0.00");
// lblTotal.Text = decimal.Parse(lblTotal.Text) + decimal.Parse(tbFTotal8.Text.Trim()).ToString();
break;
}
txtTotalGrossAmt.Text = ((string.IsNullOrEmpty(txtGrossAmt1.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt1.Text.Trim())) + (string.IsNullOrEmpty(txtGrossAmt2.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt2.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt3.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt3.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt4.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt4.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt5.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt5.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt6.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt6.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt7.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt7.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt8.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt8.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt9.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt9.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt10.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt10.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt11.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt11.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt12.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt12.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt13.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt13.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt14.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt14.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt15.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt15.Text.Trim())) + (string.IsNullOrEmpty(txtGrossAmt16.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt16.Text.Trim())) +
(string.IsNullOrEmpty(txtGrossAmt17.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt17.Text.Trim())) + (string.IsNullOrEmpty(txtGrossAmt18.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt18.Text.Trim())) + (string.IsNullOrEmpty(txtGrossAmt19.Text.Trim()) ? 0 : decimal.Parse(txtGrossAmt19.Text.Trim()))).ToString();
txtTotalVATAMT.Text = ((string.IsNullOrEmpty(txtVatAmt1.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt1.Text.Trim())) + (string.IsNullOrEmpty(txtVatAmt2.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt2.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt3.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt3.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt4.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt4.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt5.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt5.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt6.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt6.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt7.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt7.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt8.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt8.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt9.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt9.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt10.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt10.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt11.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt11.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt12.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt12.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt13.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt13.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt14.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt14.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt15.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt15.Text.Trim())) + (string.IsNullOrEmpty(txtVatAmt16.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt16.Text.Trim())) +
(string.IsNullOrEmpty(txtVatAmt17.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt17.Text.Trim())) + (string.IsNullOrEmpty(txtVatAmt18.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt18.Text.Trim())) + (string.IsNullOrEmpty(txtVatAmt19.Text.Trim()) ? 0 : decimal.Parse(txtVatAmt19.Text.Trim()))).ToString();
txtTotals.Text = ((string.IsNullOrEmpty(txtTotal1.Text.Trim()) ? 0 : decimal.Parse(txtTotal1.Text.Trim())) + (string.IsNullOrEmpty(txtTotal2.Text.Trim()) ? 0 : decimal.Parse(txtTotal2.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal3.Text.Trim()) ? 0 : decimal.Parse(txtTotal3.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal4.Text.Trim()) ? 0 : decimal.Parse(txtTotal4.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal5.Text.Trim()) ? 0 : decimal.Parse(txtTotal5.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal6.Text.Trim()) ? 0 : decimal.Parse(txtTotal6.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal7.Text.Trim()) ? 0 : decimal.Parse(txtTotal7.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal8.Text.Trim()) ? 0 : decimal.Parse(txtTotal8.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal9.Text.Trim()) ? 0 : decimal.Parse(txtTotal9.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal10.Text.Trim()) ? 0 : decimal.Parse(txtTotal10.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal11.Text.Trim()) ? 0 : decimal.Parse(txtTotal11.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal12.Text.Trim()) ? 0 : decimal.Parse(txtTotal12.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal13.Text.Trim()) ? 0 : decimal.Parse(txtTotal13.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal14.Text.Trim()) ? 0 : decimal.Parse(txtTotal14.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal15.Text.Trim()) ? 0 : decimal.Parse(txtTotal15.Text.Trim())) + (string.IsNullOrEmpty(txtTotal16.Text.Trim()) ? 0 : decimal.Parse(txtTotal16.Text.Trim())) +
(string.IsNullOrEmpty(txtTotal17.Text.Trim()) ? 0 : decimal.Parse(txtTotal17.Text.Trim())) + (string.IsNullOrEmpty(txtTotal18.Text.Trim()) ? 0 : decimal.Parse(txtTotal18.Text.Trim())) + (string.IsNullOrEmpty(txtTotal19.Text.Trim()) ? 0 : decimal.Parse(txtTotal19.Text.Trim()))).ToString();
txtGrandTotal.Text = txtFinalAmt.Text;
txtFinalAmt.Text = txtTotals.Text;
//lbltotalamount.Text = txtTotals.Text;
//decimal b = String.IsNullOrEmpty(txtTotals.Text) ? 0 : decimal.Parse(txtTotals.Text.Trim());
//decimal a = String.IsNullOrEmpty(lblOldBal.Text) ? 0 : decimal.Parse(lblOldBal.Text.Trim());
//txtFinalAmt.Text = (a+b).ToString();
//txtGrandTotal.Text = (a + b).ToString();
//finalcalculation();
//finalbill();
roundoff();
}
public void roundoff()
{
string outPut = "0";
text = txtFinalAmt.Text;
decimal value;
if (decimal.TryParse(text, out value))
{
if (value.ToString().Split('.').Length == 2)
{
outPut = value.ToString().Split('.')[1].Substring(0, value.ToString().Split('.')[1].Length);
}
if (Convert.ToInt32(outPut) >= 50)
{
value = Convert.ToInt32(value.ToString().Split('.')[0].Substring(0, value.ToString().Split('.')[0].Length)) + 1;
}
//else if (Convert.ToInt32(outPut) == 0)
//{
// value = 0;
//}
else
{
value = Convert.ToInt32(value.ToString().Split('.')[0].Substring(0, value.ToString().Split('.')[0].Length));
}
//value = Math.Round(value);
decimal x = String.IsNullOrEmpty(txtFinalAmt.Text) ? 0 : decimal.Parse(txtFinalAmt.Text.Trim());
decimal y = (x - value);
if (x <= value)
{
string var = y.ToString();
var = var.Replace("-", "");
txtRoundOff.Text = "+ " + var;
//decimal add1 = Convert.ToDecimal(var);
////decimal add2 = String.IsNullOrEmpty(txtGrandTotal.Text) ? 0 : decimal.Parse(txtGrandTotal.Text.Trim());
//decimal add3 = String.IsNullOrEmpty(txtFinalAmt.Text) ? 0 : decimal.Parse(txtFinalAmt.Text.Trim());
//decimal sum = add3 + add1;
text = value.ToString();
txtGrandTotal.Text = text.ToString();
}
else
{
string var = y.ToString();
var = var.Replace("+", "");
txtRoundOff.Text = "- " + var;
//decimal add1 = Convert.ToDecimal(var);
////decimal add2 = String.IsNullOrEmpty(txtGrandTotal.Text) ? 0 : decimal.Parse(txtGrandTotal.Text.Trim());
//decimal add3 = String.IsNullOrEmpty(txtFinalAmt.Text) ? 0 : decimal.Parse(txtFinalAmt.Text.Trim());
//decimal sum = add3 - add1;
text = value.ToString();
txtGrandTotal.Text = text.ToString();
}
//text = value.ToString();
}
}
private void txtTransport_TextChanged(object sender, EventArgs e)
{
//int a = Convert.ToInt32(txtTransport.Text);
decimal a = String.IsNullOrEmpty(txtTransport.Text) ? 0 : decimal.Parse(txtTransport.Text.Trim());
decimal b = String.IsNullOrEmpty(txtOthers.Text) ? 0 : decimal.Parse(txtOthers.Text.Trim());
decimal c = String.IsNullOrEmpty(txtTotals.Text) ? 0 : decimal.Parse(txtTotals.Text.Trim());
// decimal d = String.IsNullOrEmpty(lblOldBal.Text) ? 0 : decimal.Parse(lblOldBal.Text.Trim());
txtFinalAmt.Text = (a + b + c).ToString();
//txtGrandTotal.Text = (a + b + c).ToString();
roundoff();
}
private void txtOthers_TextChanged(object sender, EventArgs e)
{
decimal a = String.IsNullOrEmpty(txtTransport.Text) ? 0 : decimal.Parse(txtTransport.Text.Trim());
decimal b = String.IsNullOrEmpty(txtOthers.Text) ? 0 : decimal.Parse(txtOthers.Text.Trim());
decimal c = String.IsNullOrEmpty(txtTotals.Text) ? 0 : decimal.Parse(txtTotals.Text.Trim());
//decimal d = String.IsNullOrEmpty(lblOldBal.Text) ? 0 : decimal.Parse(lblOldBal.Text.Trim());
txtFinalAmt.Text = (a + b + c).ToString();
//txtGrandTotal.Text = (a + b + c).ToString();
roundoff();
}
public string rupeestoword(Int64 rupee)
{
string result = "";
Int64 res;
if ((rupees / 10000000) > 0)
{
res = rupees / 10000000;
rupees = rupees % 10000000;
result = result + ' ' + rupeestowords(res) + " Crore";
}
if ((rupees / 100000) > 0)
{
res = rupees / 100000;
rupees = rupees % 100000;
result = result + ' ' + rupeestowords(res) + " Lack";
}
if ((rupees / 1000) > 0)
{
res = rupees / 1000;
rupees = rupees % 1000;
result = result + ' ' + rupeestowords(res) + " Thousand";
}
if ((rupees / 100) > 0)
{
res = rupees / 100;
rupees = rupees % 100;
result = result + ' ' + rupeestowords(res) + " Hundred";
}
if ((rupees % 10) >= 0)
{
res = rupees % 100;
result = result + " " + rupeestowords(res);
}
result = result + ' ' + " Rupees only";
return result;
}
public string rupeestowords(Int64 rupees)
{
string result = "";
if ((rupees >= 1) && (rupees <= 10))
{
if ((rupees % 10) == 1) result = "One";
if ((rupees % 10) == 2) result = "Two";
if ((rupees % 10) == 3) result = "Three";
if ((rupees % 10) == 4) result = "Four";
if ((rupees % 10) == 5) result = "Five";
if ((rupees % 10) == 6) result = "Six";
if ((rupees % 10) == 7) result = "Seven";
if ((rupees % 10) == 8) result = "Eight";
if ((rupees % 10) == 9) result = "Nine";
if ((rupees % 10) == 0) result = "Ten";
}
if (rupees > 9 && rupees < 20)
{
if (rupees == 11) result = "Eleven";
if (rupees == 12) result = "Twelve";
if (rupees == 13) result = "Thirteen";
if (rupees == 14) result = "Forteen";
if (rupees == 15) result = "Fifteen";
if (rupees == 16) result = "Sixteen";
if (rupees == 17) result = "Seventeen";
if (rupees == 18) result = "Eighteen";
if (rupees == 19) result = "Nineteen";
}
if (rupees > 20 && (rupees / 10) == 2 && (rupees % 10) == 0) result = "Twenty";
if (rupees > 20 && (rupees / 10) == 3 && (rupees % 10) == 0) result = "Thirty";
if (rupees > 20 && (rupees / 10) == 4 && (rupees % 10) == 0) result = "Forty";
if (rupees > 20 && (rupees / 10) == 5 && (rupees % 10) == 0) result = "Fifty";
if (rupees > 20 && (rupees / 10) == 6 && (rupees % 10) == 0) result = "Sixty";
if (rupees > 20 && (rupees / 10) == 7 && (rupees % 10) == 0) result = "Seventy";
if (rupees > 20 && (rupees / 10) == 8 && (rupees % 10) == 0) result = "Eighty";
if (rupees > 20 && (rupees / 10) == 9 && (rupees % 10) == 0) result = "Ninty";
if (rupees > 20 && (rupees / 10) == 2 && (rupees % 10) != 0)
{
if ((rupees % 10) == 1) result = "Twenty One";
if ((rupees % 10) == 2) result = "Twenty Two";
if ((rupees % 10) == 3) result = "Twenty Three";
if ((rupees % 10) == 4) result = "Twenty Four";
if ((rupees % 10) == 5) result = "Twenty Five";
if ((rupees % 10) == 6) result = "Twenty Six";
if ((rupees % 10) == 7) result = "Twenty Seven";
if ((rupees % 10) == 8) result = "Twenty Eight";
if ((rupees % 10) == 9) result = "Twenty Nine";
}
if (rupees > 20 && (rupees / 10) == 3 && (rupees % 10) != 0)
{
if ((rupees % 10) == 1) result = "Thirty One";
if ((rupees % 10) == 2) result = "Thirty Two";
if ((rupees % 10) == 3) result = "Thirty Three";
if ((rupees % 10) == 4) result = "Thirty Four";
if ((rupees % 10) == 5) result = "Thirty Five";
if ((rupees % 10) == 6) result = "Thirty Six";
if ((rupees % 10) == 7) result = "Thirty Seven";
if ((rupees % 10) == 8) result = "Thirty Eight";
if ((rupees % 10) == 9) result = "Thirty Nine";
}
if (rupees > 20 && (rupees / 10) == 4 && (rupees % 10) != 0)
{
if ((rupees % 10) == 1) result = "Forty One";
if ((rupees % 10) == 2) result = "Forty Two";
if ((rupees % 10) == 3) result = "Forty Three";
if ((rupees % 10) == 4) result = "Forty Four";
if ((rupees % 10) == 5) result = "Forty Five";
if ((rupees % 10) == 6) result = "Forty Six";
if ((rupees % 10) == 7) result = "Forty Seven";
if ((rupees % 10) == 8) result = "Forty Eight";
if ((rupees % 10) == 9) result = "Forty Nine";
}
if (rupees > 20 && (rupees / 10) == 5 && (rupees % 10) != 0)
{
if ((rupees % 10) == 1) result = "Fifty One";
if ((rupees % 10) == 2) result = "Fifty Two";
if ((rupees % 10) == 3) result = "Fifty Three";
if ((rupees % 10) == 4) result = "Fifty Four";
if ((rupees % 10) == 5) result = "Fifty Five";
if ((rupees % 10) == 6) result = "Fifty Six";
if ((rupees % 10) == 7) result = "Fifty Seven";
if ((rupees % 10) == 8) result = "Fifty Eight";
if ((rupees % 10) == 9) result = "Fifty Nine";
}
if (rupees > 20 && (rupees / 10) == 6 && (rupees % 10) != 0)
{
if ((rupees % 10) == 1) result = "Sixty One";
if ((rupees % 10) == 2) result = "Sixty Two";
if ((rupees % 10) == 3) result = "Sixty Three";
if ((rupees % 10) == 4) result = "Sixty Four";
if ((rupees % 10) == 5) result = "Sixty Five";
if ((rupees % 10) == 6) result = "Sixty Six";
if ((rupees % 10) == 7) result = "Sixty Seven";
if ((rupees % 10) == 8) result = "Sixty Eight";
if ((rupees % 10) == 9) result = "Sixty Nine";
}
if (rupees > 20 && (rupees / 10) == 7 && (rupees % 10) != 0)
{
if ((rupees % 10) == 1) result = "Seventy One";
if ((rupees % 10) == 2) result = "Seventy Two";
if ((rupees % 10) == 3) result = "Seventy Three";
if ((rupees % 10) == 4) result = "Seventy Four";
if ((rupees % 10) == 5) result = "Seventy Five";
if ((rupees % 10) == 6) result = "Seventy Six";
if ((rupees % 10) == 7) result = "Seventy Seven";
if ((rupees % 10) == 8) result = "Seventy Eight";
if ((rupees % 10) == 9) result = "Seventy Nine";
}
if (rupees > 20 && (rupees / 10) == 8 && (rupees % 10) != 0)
{
if ((rupees % 10) == 1) result = "Eighty One";
if ((rupees % 10) == 2) result = "Eighty Two";
if ((rupees % 10) == 3) result = "Eighty Three";
if ((rupees % 10) == 4) result = "Eighty Four";
if ((rupees % 10) == 5) result = "Eighty Five";
if ((rupees % 10) == 6) result = "Eighty Six";
if ((rupees % 10) == 7) result = "Eighty Seven";
if ((rupees % 10) == 8) result = "Eighty Eight";
if ((rupees % 10) == 9) result = "Eighty Nine";
}
if (rupees > 20 && (rupees / 10) == 9 && (rupees % 10) != 0)
{
if ((rupees % 10) == 1) result = "Ninty One";
if ((rupees % 10) == 2) result = "Ninty Two";
if ((rupees % 10) == 3) result = "Ninty Three";
if ((rupees % 10) == 4) result = "Ninty Four";
if ((rupees % 10) == 5) result = "Ninty Five";
if ((rupees % 10) == 6) result = "Ninty Six";
if ((rupees % 10) == 7) result = "Ninty Seven";
if ((rupees % 10) == 8) result = "Ninty Eight";
if ((rupees % 10) == 9) result = "Ninty Nine";
}
return result;
}
private void FillInvoiceID()
{
string con = ConfigurationManager.AppSettings["FilePath"].ToString();
OleDbConnection c1 = new OleDbConnection(con);
if (c1.State == ConnectionState.Open)
{
c1.Close();
}
c1.Open();
//string retInvoiceIDQuery = "SELECT Max(INVOICENO) as INVOICENO FROM TAXINVOICE";
string retInvoiceIDQuery = "SELECT Max(INVOICENO) as INVOICENO, Max(CurrentYear) as CurrentYear, Max(CreatedOn) as CreatedOn FROM TAXINVOICE";
//string retInvoiceIDQuery = "SELECT Max(CreatedOn) as CreatedOn FROM TAXINVOICE";
OleDbCommand commd = new OleDbCommand(retInvoiceIDQuery, c1);
OleDbDataAdapter datadp = new OleDbDataAdapter(commd);
DataTable datset = new DataTable();
datadp.Fill(datset);
if (datset.Rows[0][0] != null && string.IsNullOrEmpty(datset.Rows[0][0].ToString()))
{
datset.Rows[0][0] = "0";
}
OleDbDataAdapter cmdNew = new OleDbDataAdapter("SELECT CreatedOn FROM TAXINVOICE where createdon=#" + datset.Rows[0]["CreatedOn"].ToString() + "#", c1);
DataTable dtCreatedOn = new DataTable();
cmdNew.Fill(dtCreatedOn);
int existedYear = Convert.ToInt32(datset.Rows[0]["CurrentYear"].ToString());
int currentYear = DateTime.Now.Year;
int currentMonth = DateTime.Now.Month;
if (dtCreatedOn.Rows.Count == 1 && existedYear == currentYear && currentMonth == 4)
{
//DateTime cnvCreated = Convert.ToDateTime(dtCreatedOn.Rows[0]["CreatedOn"].ToString());
//if (cnvCreated.Day == 1)
//{
//}
//else
//{
// invoice = 1;
//}
invoice = 1;
}
//if (existedYear == currentYear && currentMonth == 4)
//{
// invoice = 1;
//}
else
{
if (dtCreatedOn.Rows.Count == 0)
{
invoice = 1;
}
else
{
invoice = Convert.ToInt32(datset.Rows[0]["INVOICENO"].ToString()) + 1;
}
}
txtInvoice.Text = invoice.ToString();
c1.Close();
}
private void txtDescription1_Leave(object sender, EventArgs e)
{
DataTable qpdataset1 = new DataTable();
if (!txtDescription1.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT1.Text = "5";
txtSno1.Text = "1";
}
else if (!txtDescription1.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
//txtVAT1.Text = "";
//txtSno1.Text = "";
//txtVatAmt1.Text = "";
//txtVAT1.Text = "";
//txtTotal1.Text = "";
//txtqty1.Text = "";
//txtPrice1.Text = "";
//txtGrossAmt1.Text = "";
txtVAT1.Text = "2";
txtSno1.Text = "1";
}
else
{
txtVAT1.Text = "";
txtSno1.Text = "";
txtVatAmt1.Text = "";
txtVAT1.Text = "";
txtTotal1.Text = "";
txtqty1.Text = "";
txtPrice1.Text = "";
txtGrossAmt1.Text = "";
}
string desname = txtDescription1.Text.ToString();
qpdataset1 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset1.Rows.Count > 0)
{
////txtqty1.Text = qpdataset1.Rows[0]["Quantity"].ToString();
//if (qpdataset1.Rows[0]["UnitPrice"].ToString().Contains("."))
//{
// txtPrice1.Text = qpdataset1.Rows[0]["UnitPrice"].ToString();
//}
//else
//{
// txtPrice1.Text = qpdataset1.Rows[0]["UnitPrice"].ToString() + ".00";
//}
txtPrice1.Text = qpdataset1.Rows[0]["UnitPrice"].ToString();
cbUOM1.Text = qpdataset1.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription2_Leave(object sender, EventArgs e)
{
DataTable qpdataset2 = new DataTable();
if (!txtDescription2.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT2.Text = "5";
txtSno2.Text = "2";
}
else if (!txtDescription2.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT2.Text = "2";
txtSno2.Text = "2";
}
else
{
txtVAT2.Text = "";
txtSno2.Text = "";
txtVatAmt2.Text = "";
txtVAT2.Text = "";
txtTotal2.Text = "";
txtqty2.Text = "";
txtPrice2.Text = "";
txtGrossAmt2.Text = "";
}
string desname = txtDescription2.Text.ToString();
qpdataset2 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset2.Rows.Count > 0)
{
//txtqty2.Text = qpdataset2.Rows[0]["Quantity"].ToString();
txtPrice2.Text = qpdataset2.Rows[0]["UnitPrice"].ToString();
cbUOM2.Text = qpdataset2.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription3_Leave(object sender, EventArgs e)
{
DataTable qpdataset3 = new DataTable();
if (!txtDescription3.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT3.Text = "5";
txtSno3.Text = "3";
}
else if (!txtDescription3.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT3.Text = "2";
txtSno3.Text = "3";
//txtVAT3.Text = "";
//txtSno3.Text = "";
//txtVatAmt3.Text = "";
//txtVAT3.Text = "";
//txtTotal3.Text = "";
//txtqty3.Text = "";
//txtPrice3.Text = "";
//txtGrossAmt3.Text = "";
}
else
{
txtVAT3.Text = "";
txtSno3.Text = "";
txtVatAmt3.Text = "";
txtVAT3.Text = "";
txtTotal3.Text = "";
txtqty3.Text = "";
txtPrice3.Text = "";
txtGrossAmt3.Text = "";
}
string desname = txtDescription3.Text.ToString();
qpdataset3 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset3.Rows.Count > 0)
{
// txtqty3.Text = qpdataset3.Rows[0]["Quantity"].ToString();
txtPrice3.Text = qpdataset3.Rows[0]["UnitPrice"].ToString();
cbUOM3.Text = qpdataset3.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription4_Leave(object sender, EventArgs e)
{
DataTable qpdataset4 = new DataTable();
if (!txtDescription4.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT4.Text = "5";
txtSno4.Text = "4";
}
else if (!txtDescription4.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT4.Text = "2";
txtSno4.Text = "4";
//txtVAT4.Text = "";
//txtSno4.Text = "";
//txtVatAmt4.Text = "";
//txtVAT4.Text = "";
//txtTotal4.Text = "";
//txtqty4.Text = "";
//txtPrice4.Text = "";
//txtGrossAmt4.Text = "";
}
else
{
txtVAT4.Text = "";
txtSno4.Text = "";
txtVatAmt4.Text = "";
txtVAT4.Text = "";
txtTotal4.Text = "";
txtqty4.Text = "";
txtPrice4.Text = "";
txtGrossAmt4.Text = "";
}
string desname = txtDescription4.Text.ToString();
qpdataset4 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset4.Rows.Count > 0)
{
//txtqty4.Text = qpdataset4.Rows[0]["Quantity"].ToString();
txtPrice4.Text = qpdataset4.Rows[0]["UnitPrice"].ToString();
cbUOM4.Text = qpdataset4.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription5_Leave(object sender, EventArgs e)
{
DataTable qpdataset5 = new DataTable();
if (!txtDescription5.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT5.Text = "5";
txtSno5.Text = "5";
}
else if (!txtDescription5.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT5.Text = "2";
txtSno5.Text = "5";
//txtVAT5.Text = "";
//txtSno5.Text = "";
//txtVatAmt5.Text = "";
//txtVAT5.Text = "";
//txtTotal5.Text = "";
//txtqty5.Text = "";
//txtPrice5.Text = "";
//txtGrossAmt5.Text = "";
}
else
{
txtVAT5.Text = "";
txtSno5.Text = "";
txtVatAmt5.Text = "";
txtVAT5.Text = "";
txtTotal5.Text = "";
txtqty5.Text = "";
txtPrice5.Text = "";
txtGrossAmt5.Text = "";
}
string desname = txtDescription5.Text.ToString();
qpdataset5 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset5.Rows.Count > 0)
{
//txtqty5.Text = qpdataset5.Rows[0]["Quantity"].ToString();
txtPrice5.Text = qpdataset5.Rows[0]["UnitPrice"].ToString();
cbUOM5.Text = qpdataset5.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription6_Leave(object sender, EventArgs e)
{
DataTable qpdataset6 = new DataTable();
if (!txtDescription6.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT6.Text = "5";
txtSno6.Text = "6";
}
else if (!txtDescription6.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT6.Text = "2";
txtSno6.Text = "6";
//txtVAT6.Text = "";
//txtSno6.Text = "";
//txtVatAmt6.Text = "";
//txtVAT6.Text = "";
//txtTotal6.Text = "";
//txtqty6.Text = "";
//txtPrice6.Text = "";
//txtGrossAmt6.Text = "";
}
else
{
txtVAT6.Text = "";
txtSno6.Text = "";
txtVatAmt6.Text = "";
txtVAT6.Text = "";
txtTotal6.Text = "";
txtqty6.Text = "";
txtPrice6.Text = "";
txtGrossAmt6.Text = "";
}
string desname = txtDescription6.Text.ToString();
qpdataset6 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset6.Rows.Count > 0)
{
// txtqty6.Text = qpdataset6.Rows[0]["Quantity"].ToString();
txtPrice6.Text = qpdataset6.Rows[0]["UnitPrice"].ToString();
cbUOM6.Text = qpdataset6.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription7_Leave(object sender, EventArgs e)
{
DataTable qpdataset7 = new DataTable();
if (!txtDescription7.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT7.Text = "5";
txtSno7.Text = "7";
}
else if (!txtDescription7.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT7.Text = "2";
txtSno7.Text = "7";
//txtVAT7.Text = "";
//txtSno7.Text = "";
//txtVatAmt7.Text = "";
//txtVAT7.Text = "";
//txtTotal7.Text = "";
//txtqty7.Text = "";
//txtPrice7.Text = "";
//txtGrossAmt7.Text = "";
}
else
{
txtVAT7.Text = "";
txtSno7.Text = "";
txtVatAmt7.Text = "";
txtVAT7.Text = "";
txtTotal7.Text = "";
txtqty7.Text = "";
txtPrice7.Text = "";
txtGrossAmt7.Text = "";
}
string desname = txtDescription7.Text.ToString();
qpdataset7 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset7.Rows.Count > 0)
{
// txtqty7.Text = qpdataset7.Rows[0]["Quantity"].ToString();
txtPrice7.Text = qpdataset7.Rows[0]["UnitPrice"].ToString();
cbUOM7.Text = qpdataset7.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription8_Leave(object sender, EventArgs e)
{
DataTable qpdataset8 = new DataTable();
if (!txtDescription8.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT8.Text = "5";
txtSno8.Text = "8";
}
else if (!txtDescription8.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT8.Text = "2";
txtSno8.Text = "8";
//txtVAT8.Text = "";
//txtSno8.Text = "";
//txtVatAmt8.Text = "";
//txtVAT8.Text = "";
//txtTotal8.Text = "";
//txtqty8.Text = "";
//txtPrice8.Text = "";
//txtGrossAmt8.Text = "";
}
else
{
txtVAT8.Text = "";
txtSno8.Text = "";
txtVatAmt8.Text = "";
txtVAT8.Text = "";
txtTotal8.Text = "";
txtqty8.Text = "";
txtPrice8.Text = "";
txtGrossAmt8.Text = "";
}
string desname = txtDescription8.Text.ToString();
qpdataset8 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset8.Rows.Count > 0)
{
// txtqty8.Text = qpdataset8.Rows[0]["Quantity"].ToString();
txtPrice8.Text = qpdataset8.Rows[0]["UnitPrice"].ToString();
cbUOM8.Text = qpdataset8.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription9_Leave(object sender, EventArgs e)
{
DataTable qpdataset9 = new DataTable();
if (!txtDescription9.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT9.Text = "5";
txtSno9.Text = "9";
}
else if (!txtDescription9.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT9.Text = "2";
txtSno9.Text = "9";
//txtVAT9.Text = "";
//txtSno9.Text = "";
//txtVatAmt9.Text = "";
//txtVAT9.Text = "";
//txtTotal9.Text = "";
//txtqty9.Text = "";
//txtPrice9.Text = "";
//txtGrossAmt9.Text = "";
}
else
{
txtVAT9.Text = "";
txtSno9.Text = "";
txtVatAmt9.Text = "";
txtVAT9.Text = "";
txtTotal9.Text = "";
txtqty9.Text = "";
txtPrice9.Text = "";
txtGrossAmt9.Text = "";
}
string desname = txtDescription9.Text.ToString();
qpdataset9 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset9.Rows.Count > 0)
{
// txtqty9.Text = qpdataset9.Rows[0]["Quantity"].ToString();
txtPrice9.Text = qpdataset9.Rows[0]["UnitPrice"].ToString();
cbUOM9.Text = qpdataset9.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription10_Leave(object sender, EventArgs e)
{
DataTable qpdataset10 = new DataTable();
if (!txtDescription10.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT10.Text = "5";
txtSno10.Text = "10";
}
else if (!txtDescription10.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT10.Text = "2";
txtSno10.Text = "10";
//txtVAT10.Text = "";
//txtSno10.Text = "";
//txtVatAmt10.Text = "";
//txtVAT10.Text = "";
//txtTotal10.Text = "";
//txtqty10.Text = "";
//txtPrice10.Text = "";
//txtGrossAmt10.Text = "";
}
else
{
txtVAT10.Text = "";
txtSno10.Text = "";
txtVatAmt10.Text = "";
txtVAT10.Text = "";
txtTotal10.Text = "";
txtqty10.Text = "";
txtPrice10.Text = "";
txtGrossAmt10.Text = "";
}
string desname = txtDescription10.Text.ToString();
qpdataset10 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset10.Rows.Count > 0)
{
//txtqty10.Text = qpdataset10.Rows[0]["Quantity"].ToString();
txtPrice10.Text = qpdataset10.Rows[0]["UnitPrice"].ToString();
cbUOM10.Text = qpdataset10.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription11_Leave(object sender, EventArgs e)
{
DataTable qpdataset11 = new DataTable();
if (!txtDescription11.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT11.Text = "5";
txtSno11.Text = "11";
}
else if (!txtDescription11.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT11.Text = "2";
txtSno11.Text = "11";
//txtVAT11.Text = "";
//txtSno11.Text = "";
//txtVatAmt11.Text = "";
//txtVAT11.Text = "";
//txtTotal11.Text = "";
//txtqty11.Text = "";
//txtPrice11.Text = "";
//txtGrossAmt11.Text = "";
}
else
{
txtVAT11.Text = "";
txtSno11.Text = "";
txtVatAmt11.Text = "";
txtVAT11.Text = "";
txtTotal11.Text = "";
txtqty11.Text = "";
txtPrice11.Text = "";
txtGrossAmt11.Text = "";
}
string desname = txtDescription11.Text.ToString();
qpdataset11 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset11.Rows.Count > 0)
{
// txtqty11.Text = qpdataset11.Rows[0]["Quantity"].ToString();
txtPrice11.Text = qpdataset11.Rows[0]["UnitPrice"].ToString();
cbUOM11.Text = qpdataset11.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription12_Leave(object sender, EventArgs e)
{
DataTable qpdataset12 = new DataTable();
if (!txtDescription12.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT12.Text = "5";
txtSno12.Text = "12";
}
else if (!txtDescription12.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT12.Text = "2";
txtSno12.Text = "12";
//txtVAT12.Text = "";
//txtSno12.Text = "";
//txtVatAmt12.Text = "";
//txtVAT12.Text = "";
//txtTotal12.Text = "";
//txtqty12.Text = "";
//txtPrice12.Text = "";
//txtGrossAmt12.Text = "";
}
else
{
txtVAT12.Text = "";
txtSno12.Text = "";
txtVatAmt12.Text = "";
txtVAT12.Text = "";
txtTotal12.Text = "";
txtqty12.Text = "";
txtPrice12.Text = "";
txtGrossAmt12.Text = "";
}
string desname = txtDescription12.Text.ToString();
qpdataset12 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset12.Rows.Count > 0)
{
// txtqty12.Text = qpdataset12.Rows[0]["Quantity"].ToString();
txtPrice12.Text = qpdataset12.Rows[0]["UnitPrice"].ToString();
cbUOM12.Text = qpdataset12.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription13_Leave(object sender, EventArgs e)
{
DataTable qpdataset13 = new DataTable();
if (!txtDescription13.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT13.Text = "5";
txtSno13.Text = "13";
}
else if (!txtDescription13.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT13.Text = "2";
txtSno13.Text = "13";
//txtVAT13.Text = "";
//txtSno13.Text = "";
//txtVatAmt13.Text = "";
//txtVAT13.Text = "";
//txtTotal13.Text = "";
//txtqty13.Text = "";
//txtPrice13.Text = "";
//txtGrossAmt13.Text = "";
}
else
{
txtVAT13.Text = "";
txtSno13.Text = "";
txtVatAmt13.Text = "";
txtVAT13.Text = "";
txtTotal13.Text = "";
txtqty13.Text = "";
txtPrice13.Text = "";
txtGrossAmt13.Text = "";
}
string desname = txtDescription13.Text.ToString();
qpdataset13 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset13.Rows.Count > 0)
{
// txtqty13.Text = qpdataset13.Rows[0]["Quantity"].ToString();
txtPrice13.Text = qpdataset13.Rows[0]["UnitPrice"].ToString();
cbUOM13.Text = qpdataset13.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription14_Leave(object sender, EventArgs e)
{
DataTable qpdataset14 = new DataTable();
if (!txtDescription14.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT14.Text = "5";
txtSno14.Text = "14";
}
else if (!txtDescription14.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
//txtVAT14.Text = "";
//txtSno14.Text = "";
//txtVatAmt14.Text = "";
//txtVAT14.Text = "";
//txtTotal14.Text = "";
//txtqty14.Text = "";
//txtPrice14.Text = "";
//txtGrossAmt14.Text = "";
txtVAT14.Text = "2";
txtSno14.Text = "14";
}
else
{
txtVAT14.Text = "";
txtSno14.Text = "";
txtVatAmt14.Text = "";
txtVAT14.Text = "";
txtTotal14.Text = "";
txtqty14.Text = "";
txtPrice14.Text = "";
txtGrossAmt14.Text = "";
}
string desname = txtDescription14.Text.ToString();
qpdataset14 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset14.Rows.Count > 0)
{
// txtqty14.Text = qpdataset14.Rows[0]["Quantity"].ToString();
txtPrice14.Text = qpdataset14.Rows[0]["UnitPrice"].ToString();
cbUOM14.Text = qpdataset14.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription15_Leave(object sender, EventArgs e)
{
DataTable qpdataset15 = new DataTable();
if (!txtDescription15.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT15.Text = "5";
txtSno15.Text = "15";
}
else if (!txtDescription15.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT15.Text = "2";
txtSno15.Text = "15";
//txtVAT15.Text = "";
//txtSno15.Text = "";
//txtVatAmt15.Text = "";
//txtVAT15.Text = "";
//txtTotal15.Text = "";
//txtqty15.Text = "";
//txtPrice15.Text = "";
//txtGrossAmt15.Text = "";
}
else
{
txtVAT15.Text = "";
txtSno15.Text = "";
txtVatAmt15.Text = "";
txtVAT15.Text = "";
txtTotal15.Text = "";
txtqty15.Text = "";
txtPrice15.Text = "";
txtGrossAmt15.Text = "";
}
string desname = txtDescription15.Text.ToString();
qpdataset15 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset15.Rows.Count > 0)
{
// txtqty15.Text = qpdataset15.Rows[0]["Quantity"].ToString();
txtPrice15.Text = qpdataset15.Rows[0]["UnitPrice"].ToString();
cbUOM15.Text = qpdataset15.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription16_Leave(object sender, EventArgs e)
{
DataTable qpdataset16 = new DataTable();
if (!txtDescription16.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT16.Text = "5";
txtSno16.Text = "16";
}
else if (!txtDescription16.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT16.Text = "2";
txtSno16.Text = "16";
//txtVAT16.Text = "";
//txtSno16.Text = "";
//txtVatAmt16.Text = "";
//txtVAT16.Text = "";
//txtTotal16.Text = "";
//txtqty16.Text = "";
//txtPrice16.Text = "";
//txtGrossAmt16.Text = "";
}
else
{
txtVAT16.Text = "";
txtSno16.Text = "";
txtVatAmt16.Text = "";
txtVAT16.Text = "";
txtTotal16.Text = "";
txtqty16.Text = "";
txtPrice16.Text = "";
txtGrossAmt16.Text = "";
}
string desname = txtDescription16.Text.ToString();
qpdataset16 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset16.Rows.Count > 0)
{
// txtqty16.Text = qpdataset16.Rows[0]["Quantity"].ToString();
txtPrice16.Text = qpdataset16.Rows[0]["UnitPrice"].ToString();
cbUOM16.Text = qpdataset16.Rows[0]["UOM"].ToString();
}
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
//string co = ConfigurationManager.AppSettings["FilePath"].ToString();
//OleDbConnection c2 = new OleDbConnection(co);
////OleDbConnection c2 = new OleDbConnection(co);
//if (c2.State == ConnectionState.Open)
//{
// c2.Close();
//}
//c2.Open();
//string MOBILE = textBox1.Text;
//string s1 = "SELECT * FROM TAXINVOICE where MOBILENUMBER = '" + MOBILE.ToString() + "'";
//OleDbCommand commad = new OleDbCommand(s1, c2);
//OleDbDataAdapter datadpter = new OleDbDataAdapter(commad);
////DataSet datset = new DataSet();
//DataSet ds2 = new DataSet();
//datadpter.Fill(ds2);
//if (ds2.Tables[0].Rows.Count > 0)
//{
// txtCustName.Text = ds2.Tables[0].Rows[0]["CUSTOMERNAME"].ToString();
// txtAddress.Text = ds2.Tables[0].Rows[0]["ADDRESS"].ToString();
// txtTINnum.Text = ds2.Tables[0].Rows[0]["TINNO"].ToString();
// txtPOnum.Text = ds2.Tables[0].Rows[0]["PONO"].ToString();
// CreatedDate.Text = ds2.Tables[0].Rows[0]["CREATEDDATE"].ToString();
// // IsUserExisted = 0;
//}
////dataAdapter1.Dispose();
////cmd1.Dispose();
////con.Close();
}
private void txtDescription17_Leave(object sender, EventArgs e)
{
DataTable qpdataset17 = new DataTable();
if (!txtDescription17.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT17.Text = "5";
txtSno17.Text = "17";
}
else if (!txtDescription17.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT17.Text = "2";
txtSno17.Text = "17";
//txtVAT17.Text = "";
//txtSno17.Text = "";
//txtVatAmt17.Text = "";
//txtVAT17.Text = "";
//txtTotal17.Text = "";
//txtqty17.Text = "";
//txtPrice17.Text = "";
//txtGrossAmt17.Text = "";
}
else
{
txtVAT17.Text = "";
txtSno17.Text = "";
txtVatAmt17.Text = "";
txtVAT17.Text = "";
txtTotal17.Text = "";
txtqty17.Text = "";
txtPrice17.Text = "";
txtGrossAmt17.Text = "";
}
string desname = txtDescription17.Text.ToString();
qpdataset17 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset17.Rows.Count > 0)
{
// txtqty17.Text = qpdataset17.Rows[0]["Quantity"].ToString();
txtPrice17.Text = qpdataset17.Rows[0]["UnitPrice"].ToString();
cbUOM17.Text = qpdataset17.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription18_Leave(object sender, EventArgs e)
{
DataTable qpdataset18 = new DataTable();
if (!txtDescription18.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT18.Text = "5";
txtSno18.Text = "18";
}
else if (!txtDescription18.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT18.Text = "2";
txtSno18.Text = "18";
//txtVAT18.Text = "";
//txtSno18.Text = "";
//txtVatAmt18.Text = "";
//txtVAT18.Text = "";
//txtTotal18.Text = "";
//txtqty18.Text = "";
//txtPrice18.Text = "";
//txtGrossAmt18.Text = "";
}
else
{
txtVAT18.Text = "";
txtSno18.Text = "";
txtVatAmt18.Text = "";
txtVAT18.Text = "";
txtTotal18.Text = "";
txtqty18.Text = "";
txtPrice18.Text = "";
txtGrossAmt18.Text = "";
}
string desname = txtDescription18.Text.ToString();
qpdataset18 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset18.Rows.Count > 0)
{
// txtqty18.Text = qpdataset18.Rows[0]["Quantity"].ToString();
txtPrice18.Text = qpdataset18.Rows[0]["UnitPrice"].ToString();
cbUOM18.Text = qpdataset18.Rows[0]["UOM"].ToString();
}
}
}
private void txtDescription19_Leave(object sender, EventArgs e)
{
DataTable qpdataset19 = new DataTable();
if (!txtDescription19.Text.Equals(String.Empty) && (comboBox1.Text.Equals("VAT SALES")))
{
txtVAT19.Text = "5";
txtSno19.Text = "19";
}
else if (!txtDescription19.Text.Equals(String.Empty) && (comboBox1.Text.Equals("CST SALES")))
{
txtVAT19.Text = "2";
txtSno19.Text = "19";
}
else
{
txtVAT19.Text = "";
txtSno19.Text = "";
txtVatAmt19.Text = "";
txtVAT19.Text = "";
txtTotal19.Text = "";
txtqty19.Text = "";
txtPrice19.Text = "";
txtGrossAmt19.Text = "";
}
string desname = txtDescription19.Text.ToString();
qpdataset19 = getqtyandprice(desname);
DataSet dsCustomerChecking = GetRequiredDataTable("SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + txtCustName.Text.Trim() + "'");
if (dsCustomerChecking.Tables[0].Rows.Count > 0)
{
if (qpdataset19.Rows.Count > 0)
{
// txtqty19.Text = qpdataset19.Rows[0]["Quantity"].ToString();
txtPrice19.Text = qpdataset19.Rows[0]["UnitPrice"].ToString();
cbUOM19.Text = qpdataset19.Rows[0]["UOM"].ToString();
}
}
}
public bool isNumber(char ch, string text)
{
bool res = true;
char decimalChar = Convert.ToChar(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
//check if it´s a decimal separator and if doesn´t already have one in the text string
if (ch == decimalChar && text.IndexOf(decimalChar) != -1)
{
res = false;
return res;
}
//check if it´s a digit, decimal separator and backspace
if (!Char.IsDigit(ch) && ch != decimalChar && ch != (char)Keys.Back)
res = false;
return res;
}
private void txtTransport_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtTransport.Text) ? 0 : decimal.Parse(txtTransport.Text.Trim());
if (!txtTransport.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtTransport.Text = value.ToString();
}
else
{
txtTransport.Text = value.ToString() + ".00";
}
}
}
private void txtOthers_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtOthers.Text) ? 0 : decimal.Parse(txtOthers.Text.Trim());
if (!txtOthers.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtOthers.Text = value.ToString();
}
else
{
txtOthers.Text = value.ToString() + ".00";
}
}
}
private void txtPrice1_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice1.Text) ? 0 : decimal.Parse(txtPrice1.Text.Trim());
if (!txtPrice1.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice1.Text = value.ToString();
}
else
{
txtPrice1.Text = value.ToString() + ".00";
}
}
}
private void txtPrice2_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice2.Text) ? 0 : decimal.Parse(txtPrice2.Text.Trim());
if (!txtPrice2.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice2.Text = value.ToString();
}
else
{
txtPrice2.Text = value.ToString() + ".00";
}
}
}
private void txtPrice3_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice3.Text) ? 0 : decimal.Parse(txtPrice3.Text.Trim());
if (!txtPrice3.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice3.Text = value.ToString();
}
else
{
txtPrice3.Text = value.ToString() + ".00";
}
}
}
private void txtPrice4_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice4.Text) ? 0 : decimal.Parse(txtPrice4.Text.Trim());
if (!txtPrice4.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice4.Text = value.ToString();
}
else
{
txtPrice4.Text = value.ToString() + ".00";
}
}
}
private void txtPrice5_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice5.Text) ? 0 : decimal.Parse(txtPrice5.Text.Trim());
if (!txtPrice5.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice5.Text = value.ToString();
}
else
{
txtPrice5.Text = value.ToString() + ".00";
}
}
}
private void txtPrice6_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice6.Text) ? 0 : decimal.Parse(txtPrice6.Text.Trim());
if (!txtPrice6.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice6.Text = value.ToString();
}
else
{
txtPrice6.Text = value.ToString() + ".00";
}
}
}
private void txtPrice7_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice7.Text) ? 0 : decimal.Parse(txtPrice7.Text.Trim());
if (!txtPrice7.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice7.Text = value.ToString();
}
else
{
txtPrice7.Text = value.ToString() + ".00";
}
}
}
private void txtPrice8_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice8.Text) ? 0 : decimal.Parse(txtPrice8.Text.Trim());
if (!txtPrice8.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice8.Text = value.ToString();
}
else
{
txtPrice8.Text = value.ToString() + ".00";
}
}
}
private void txtPrice9_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice9.Text) ? 0 : decimal.Parse(txtPrice9.Text.Trim());
if (!txtPrice9.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice9.Text = value.ToString();
}
else
{
txtPrice9.Text = value.ToString() + ".00";
}
}
}
private void txtPrice10_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice10.Text) ? 0 : decimal.Parse(txtPrice10.Text.Trim());
if (!txtPrice10.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice10.Text = value.ToString();
}
else
{
txtPrice10.Text = value.ToString() + ".00";
}
}
}
private void txtPrice11_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice11.Text) ? 0 : decimal.Parse(txtPrice11.Text.Trim());
if (!txtPrice11.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice11.Text = value.ToString();
}
else
{
txtPrice11.Text = value.ToString() + ".00";
}
}
}
private void txtPrice12_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice12.Text) ? 0 : decimal.Parse(txtPrice12.Text.Trim());
if (!txtPrice12.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice12.Text = value.ToString();
}
else
{
txtPrice12.Text = value.ToString() + ".00";
}
}
}
private void txtPrice13_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice13.Text) ? 0 : decimal.Parse(txtPrice13.Text.Trim());
if (!txtPrice13.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice13.Text = value.ToString();
}
else
{
txtPrice13.Text = value.ToString() + ".00";
}
}
}
private void txtPrice14_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice14.Text) ? 0 : decimal.Parse(txtPrice14.Text.Trim());
if (!txtPrice14.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice14.Text = value.ToString();
}
else
{
txtPrice14.Text = value.ToString() + ".00";
}
}
}
private void txtPrice15_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice15.Text) ? 0 : decimal.Parse(txtPrice15.Text.Trim());
if (!txtPrice15.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice15.Text = value.ToString();
}
else
{
txtPrice15.Text = value.ToString() + ".00";
}
}
}
private void txtPrice16_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice16.Text) ? 0 : decimal.Parse(txtPrice16.Text.Trim());
if (!txtPrice16.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice16.Text = value.ToString();
}
else
{
txtPrice16.Text = value.ToString() + ".00";
}
}
}
private void txtPrice17_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice17.Text) ? 0 : decimal.Parse(txtPrice17.Text.Trim());
if (!txtPrice17.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice17.Text = value.ToString();
}
else
{
txtPrice17.Text = value.ToString() + ".00";
}
}
}
private void txtPrice18_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice18.Text) ? 0 : decimal.Parse(txtPrice18.Text.Trim());
if (!txtPrice18.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice18.Text = value.ToString();
}
else
{
txtPrice18.Text = value.ToString() + ".00";
}
}
}
private void txtPrice19_Leave(object sender, EventArgs e)
{
decimal value = String.IsNullOrEmpty(txtPrice19.Text) ? 0 : decimal.Parse(txtPrice19.Text.Trim());
if (!txtPrice19.Text.Equals(String.Empty))
{
if (value.ToString().Contains("."))
{
txtPrice19.Text = value.ToString();
}
else
{
txtPrice19.Text = value.ToString() + ".00";
}
}
}
private void TAXINVOICE_Load_1(object sender, EventArgs e)
{
FillCustomerNames();
txtCustName.AutoCompleteMode = AutoCompleteMode.Suggest;
txtCustName.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtCustName.AutoCompleteCustomSource = namesCollection;
}
private void FillCustomerNames()
{
namesCollection = new AutoCompleteStringCollection();
string filelocation = ConfigurationManager.AppSettings["FilePath"].ToString();
OleDbDataReader dReader;
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = filelocation;
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = @"SELECT Distinct[CUSTOMERNAME] FROM TAXINVOICE";
// Array namesCollection=
//ArrayList namesCollection = new ArrayList();
conn.Open();
dReader = cmd.ExecuteReader();
if (dReader.HasRows == true)
{
while (dReader.Read())
namesCollection.Add(dReader["CUSTOMERNAME"].ToString());
}
}
private void FillDescriptions(string customerName)
{
descriptionCollection = new AutoCompleteStringCollection();
string filelocation = ConfigurationManager.AppSettings["FilePath"].ToString();
OleDbDataReader dReader;
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = filelocation;
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = @"SELECT Products.ProductName FROM TAXINVOICE INNER JOIN (Products INNER JOIN "
+ " InvoiceItems ON Products.ProductId = InvoiceItems.ProductId) ON TAXINVOICE.INVOICENO = "
+ " InvoiceItems.InvoiceNumber WHERE TAXINVOICE.CUSTOMERNAME = '" + customerName + "'";
// Array namesCollection=
//ArrayList namesCollection = new ArrayList();
conn.Open();
dReader = cmd.ExecuteReader();
if (dReader.HasRows == true)
{
while (dReader.Read())
descriptionCollection.Add(dReader["ProductName"].ToString());
}
// cmd.CommandText = @"SELECT DISTINCT InvoiceItems.Quantity,InvocieItems.UnitPrice,InvoiceItems.VAT FROM TAXINVOICE INNER JOIN (Products INNER JOIN "
//+ " InvoiceItems ON Products.ProductId = InvoiceItems.ProductId) ON TAXINVOICE.INVOICENO = "
//+ " InvoiceItems.InvoiceNumber WHERE TAXINVOICE.CUSTOMERNAME = '" + customerName + "'";
}
private DataSet GetRequiredDataTable(string query)
{
string connection = ConfigurationManager.AppSettings["FilePath"].ToString();
OleDbConnection c3 = new OleDbConnection(connection);
if (c3.State == ConnectionState.Open)
{
c3.Close();
}
c3.Open();
OleDbDataAdapter da = new OleDbDataAdapter(query, c3);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
private void txtCustName_Leave(object sender, EventArgs e)
{
//string connection = ConfigurationManager.AppSettings["FilePath"].ToString();
//OleDbConnection c3 = new OleDbConnection(connection);
//OleDbConnection c2 = new OleDbConnection(co);
//if (c3.State == ConnectionState.Open)
//{
// c3.Close();
//}
//c3.Open();
string custname = txtCustName.Text;
string string1 = "SELECT * FROM TAXINVOICE where CUSTOMERNAME = '" + custname.ToString() + "'";
//OleDbCommand custcommand = new OleDbCommand(string1, c3);
//OleDbDataAdapter custdatadpter = new OleDbDataAdapter(custcommand);
//DataSet datset = new DataSet();
//DataSet custdataset = new DataSet();
//custdatadpter.Fill(custdataset);
DataSet custdataset = GetRequiredDataTable("select * from TAXINVOICE where INVOICENO=(SELECT Max(INVOICENO) FROM TAXINVOICE WHERE CUSTOMERNAME='" + custname.ToString() + "')");
if (custdataset.Tables[0].Rows.Count > 0)
{
txtCustName.Text = custdataset.Tables[0].Rows[0]["CUSTOMERNAME"].ToString();
txtAddress1.Text = custdataset.Tables[0].Rows[0]["ADDRESS1"].ToString();
txtAddress2.Text = custdataset.Tables[0].Rows[0]["ADDRESS2"].ToString();
txtTINnum.Text = custdataset.Tables[0].Rows[0]["TINNO"].ToString();
//txtPOnum.Text = custdataset.Tables[0].Rows[0]["PONO"].ToString();
// CreatedDate.Text = custdataset.Tables[0].Rows[0]["CREATEDDATE"].ToString();
comboBox1.Text = custdataset.Tables[0].Rows[0]["STATE"].ToString();
//txtInvoice.Text = custdataset.Tables[0].Rows[0]["INVOICENO"].ToString();
//ddlTransaction.Text = custdataset.Tables[0].Rows[0]["InvoiceType"].ToString();
// tbTransportValue.Text = custdataset.Tables[0].Rows[0]["TRANSPORT"].ToString();
}
FillDescriptionsWithContent(custname);
//dataAdapter1.Dispose();
//cmd1.Dispose();
//con.Close();
}
private void FillDescriptionsWithContent(string custname)
{
FillDescriptions(custname);
txtDescription1.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription1.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription1.AutoCompleteCustomSource = descriptionCollection;
txtDescription2.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription2.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription2.AutoCompleteCustomSource = descriptionCollection;
txtDescription3.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription3.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription3.AutoCompleteCustomSource = descriptionCollection;
txtDescription4.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription4.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription4.AutoCompleteCustomSource = descriptionCollection;
txtDescription5.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription5.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription5.AutoCompleteCustomSource = descriptionCollection;
txtDescription6.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription6.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription6.AutoCompleteCustomSource = descriptionCollection;
txtDescription7.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription7.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription7.AutoCompleteCustomSource = descriptionCollection;
txtDescription8.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription8.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription8.AutoCompleteCustomSource = descriptionCollection;
txtDescription9.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription9.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription9.AutoCompleteCustomSource = descriptionCollection;
txtDescription10.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription10.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription10.AutoCompleteCustomSource = descriptionCollection;
txtDescription11.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription11.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription11.AutoCompleteCustomSource = descriptionCollection;
txtDescription12.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription12.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription12.AutoCompleteCustomSource = descriptionCollection;
txtDescription13.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription13.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription13.AutoCompleteCustomSource = descriptionCollection;
txtDescription14.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription14.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription14.AutoCompleteCustomSource = descriptionCollection;
txtDescription15.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription15.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription15.AutoCompleteCustomSource = descriptionCollection;
txtDescription16.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription16.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription16.AutoCompleteCustomSource = descriptionCollection;
txtDescription17.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription17.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription17.AutoCompleteCustomSource = descriptionCollection;
txtDescription18.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription18.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription18.AutoCompleteCustomSource = descriptionCollection;
txtDescription19.AutoCompleteMode = AutoCompleteMode.Suggest;
txtDescription19.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDescription19.AutoCompleteCustomSource = descriptionCollection;
}
private void txtDescription1_KeyPress(object sender, KeyPressEventArgs e)
{
string custname = txtCustName.Text;
}
private void txtVAT_TextChanged(object sender, EventArgs e)
{
TextBox txtVAT = (TextBox)sender;
string txtName = txtVAT.Name.Replace("txtVAT", "");
GetAndCalculateTotal(txtName);
}
private void txtInvoice_TextChanged(object sender, EventArgs e)
{
//int returnProductId = 0;
//string connstring = ConfigurationManager.AppSettings["FilePath"].ToString();
//string invoicenum = "SELECT CUSTOMERNAME FROM TAXINVOICE where INVOICENO=" + txtInvoice.Text.ToString() + "";
//OleDbConnection oledinvoicenum = new OleDbConnection(connstring);
////OleDbConnection c2 = new OleDbConnection(co);
//if (oledinvoicenum.State == ConnectionState.Open)
//{
// oledinvoicenum.Close();
//}
//oledinvoicenum.Open();
//OleDbCommand oledbproductcmd = new OleDbCommand(invoicenum, oledinvoicenum);
//object obj = oledbproductcmd.ExecuteScalar();
//if (obj != null)
//{
// if(!String.IsNullOrEmpty(obj.ToString()))
// {
// MessageBox.Show("InvoiceNo Already Exists");
// txtInvoice.Text = "";
// }
//}
}
private void txtInvoice_Leave(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(txtInvoice.Text.Trim()))
{
string connstring = ConfigurationManager.AppSettings["FilePath"].ToString();
string invoicenum = "SELECT CUSTOMERNAME FROM TAXINVOICE where INVOICENO=" + txtInvoice.Text.ToString() + "";
OleDbConnection oledinvoicenum = new OleDbConnection(connstring);
//OleDbConnection c2 = new OleDbConnection(co);
if (oledinvoicenum.State == ConnectionState.Open)
{
oledinvoicenum.Close();
}
oledinvoicenum.Open();
OleDbCommand oledbproductcmd = new OleDbCommand(invoicenum, oledinvoicenum);
object obj = oledbproductcmd.ExecuteScalar();
if (obj != null)
{
if (!String.IsNullOrEmpty(obj.ToString()))
{
MessageBox.Show("InvoiceNo Already Exists");
txtInvoice.Text = "";
}
}
}
}
private void TAXINVOICE_FormClosing(object sender, FormClosingEventArgs e)
{
Application.Exit();
}
private void txtCustName_TextChanged(object sender, EventArgs e)
{
}
private void txtAddress1_TextChanged(object sender, EventArgs e)
{
}
private void txtGrossAmt1_TextChanged(object sender, EventArgs e)
{
}
private void txtTotalGrossAmt_TextChanged(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedItem == "VAT SALES")
{
ddlTransaction.Text = "CREDIT INVOICE";
}
else
{
ddlTransaction.Text = "CREDIT INVOICE / CST SALES";
}
}
}
}
推荐答案
这篇关于每个财政年度,发票号码应以1开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!