private void txtitemname_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Enter)
                {
                    SqlCommand     cmd5 = new SqlCommand("select p.Product_Name,p.Unit,p.Packing,b.* from productmaster p inner join ProductPriceMaster b on p.ProductID=b.ProductID where p.product_name='" + txtitemname.Text + "'", con);
                    SqlDataAdapter sda  = new SqlDataAdapter(cmd5);
                    DataTable      dt   = new DataTable();
                    sda.Fill(dt);
                    txtpacking.Text = dt.Rows[0]["Packing"].ToString();
                    txtrate.Text    = dt.Rows[0]["PurchasePrice"].ToString();
                    txtper.Text     = dt.Rows[0]["Unit"].ToString();

                    SqlCommand     cmd6 = new SqlCommand("select * from itemtaxmaster i inner join productmaster p on i.productid=p.productid where p.product_name like'%" + txtitemname.Text + "%' and i.saletypeid like '%" + cmbsaletype.Text + "'", con);
                    SqlDataAdapter sda6 = new SqlDataAdapter(cmd6);
                    DataTable      dt1  = new DataTable();
                    sda6.Fill(dt1);
                    string istax = conn.ExecuteScalar("Select taxtypename from purchasetypemaster where type='P' and isactive=1 and purchasetypename='" + cmbsaletype.Text + "'");
                    if (dt1.Rows.Count > 0)
                    {
                        txttax.Text    = "0";
                        txtaddtax.Text = "0";
                        if (istax != "Tax Free")
                        {
                            lbltax1.Text    = "[" + Math.Round(Convert.ToDouble(dt1.Rows[0]["Vat"].ToString()), 2).ToString() + "]";
                            lbladdtax1.Text = "[" + Math.Round(Convert.ToDouble(dt1.Rows[0]["AddVat"].ToString()), 2).ToString() + "]";
                        }
                        else
                        {
                            lbltax1.Text    = "[0]";
                            lbladdtax1.Text = "[0]";
                        }

                        txtbags.Focus();
                        taxid    = Math.Round(Convert.ToDouble(dt1.Rows[0]["Vat"].ToString()), 2);
                        addtaxid = Math.Round(Convert.ToDouble(dt1.Rows[0]["AddVat"].ToString()), 2);
                    }
                    else
                    {
                        MessageBox.Show("Not any Tax Available For This Sale Type");
                        txttax.Text     = "0";
                        txtaddtax.Text  = "0";
                        lbltax1.Text    = "[0]";
                        lbladdtax1.Text = "[0]";
                        taxid           = 0;
                        addtaxid        = 0;
                        txtbags.Focus();
                    }
                }
                if (e.KeyCode == Keys.F3)
                {
                    Itementry client = new Itementry(this);

                    client.Passed(1);
                    client.Show();
                }
                if (e.KeyCode == Keys.F2)
                {
                    if (txtitemname.Text != "")
                    {
                        Itementry client = new Itementry(this);
                        client.Updatefromsale(txtitemname.Text);
                        client.Show();
                    }
                }
            }
            catch
            {
            }
        }
        private void txtitemname_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                getcon();
                if (e.KeyCode == Keys.Enter)
                {
                    SqlCommand cmd5 = new SqlCommand("select p.Product_Name, p.Unit, b.* from productmaster p inner join ProductPriceMaster b on p.ProductID=b.ProductID where p.product_name='" + txtItemName.Text + "' and p.CompanyID=" + Master.companyId + "", con);

                    SqlDataAdapter sda = new SqlDataAdapter(cmd5);
                    DataTable      dt  = new DataTable();
                    sda.Fill(dt);
                    if (dt.Rows.Count > 0)
                    {
                        txtRate.Text = dt.Rows[0]["PurchasePrice"].ToString();
                        txtPer.Text  = dt.Rows[0]["Unit"].ToString();
                    }
                    else
                    {
                        txtRate.Text = "0";
                        txtPer.Text  = "QTY";
                    }
                    flag                = 1;
                    txtDiscount.Text    = "0.00";
                    txtDiscountPer.Text = "0.00";
                    flag                = 0;
                    txtQty.Text         = "1";

                    SqlCommand     cmd6 = new SqlCommand("select i.Vat,i.addvat from itemtaxmaster i inner join productmaster p on i.productid=p.productid where p.product_name like'%" + txtItemName.Text + "%' and i.saletypeid like '%" + cmbPurchaseType.Text + "'", con);
                    SqlDataAdapter sda6 = new SqlDataAdapter(cmd6);
                    DataTable      dt1  = new DataTable();
                    sda6.Fill(dt1);
                    if (dt1.Rows.Count > 0)
                    {
                        txtVat.Text    = dt1.Rows[0]["Vat"].ToString();
                        txtAddVat.Text = dt1.Rows[0]["addVat"].ToString();
                        txtQty.Focus();
                        itemcalculation(txtQty.Text);
                    }
                    else
                    {
                        MessageBox.Show("Not any Tax Available For This Sale Type");
                        txtVat.Text    = "0";
                        txtAddVat.Text = "0";
                        txtQty.Focus();
                    }
                }
                if (e.KeyCode == Keys.F3)
                {
                    Itementry client = new Itementry(this);
                    client.Passed(1);
                    client.Show();
                }
                if (e.KeyCode == Keys.F2)
                {
                    if (txtItemName.Text != "")
                    {
                        Itementry client = new Itementry(this);
                        client.Updatefromsale(txtItemName.Text);
                        client.Show();
                    }
                }
            }
            catch
            {
            }
        }