Esempio n. 1
0
 private void txtBarcode_TextChanged(object sender, EventArgs e)
 {
     try
     {
         DataSet current = new DataSet();
         //cn.da = new System.Data.SqlClient.SqlDataAdapter("Select *from sell_check_Product where Barcode='"+txtBarcode.Text+"'",cn.cn);
         //cn.da.Fill(current);
         current = cntrl_sell.check_Barcode(txtBarcode.Text);
         if (current.Tables[0].Rows.Count > 0)
         {
             String  id       = current.Tables[0].Rows[0]["ProductID"].ToString();
             String  proname  = current.Tables[0].Rows[0]["ProductName"].ToString();
             String  category = current.Tables[0].Rows[0]["ProductTypeName"].ToString();
             decimal Price    = Convert.ToDecimal(current.Tables[0].Rows[0]["Sell"]);
             int     qty      = 0;
             qty = Convert.ToInt32(current.Tables[0].Rows[0]["Qty"].ToString());
             String Unit = current.Tables[0].Rows[0]["UnitName"].ToString();
             if (qty <= 1)
             {
                 MessageBox.Show("product is 0");
                 return;
             }
             for (int sr = 0; sr < dgvProductsList.Rows.Count; sr++)
             {
                 if (id == dgvProductsList.Rows[sr].Cells[1].Value.ToString())
                 {
                     ms.Check_DataSameProduct();
                     return;
                 }
             }
             dgvProductsList.Rows.Add("", id, proname, category, Price, "1", Unit);
             txtCount.Text = dgvProductsList.Rows.Count.ToString();
             foreach (DataGridViewRow r in dgvProductsList.Rows)
             {
                 int n = r.Index;
                 dgvProductsList.Rows[n].Cells[7].Value = double.Parse(dgvProductsList.Rows[n].Cells[4].Value.ToString()) * double.Parse(dgvProductsList.Rows[n].Cells[5].Value.ToString());
                 double PricePro = 0, Result = 0;
                 foreach (DataGridViewRow cr in dgvProductsList.Rows)
                 {
                     PricePro         = Convert.ToDouble(cr.Cells[7].Value);
                     Result           = Result + PricePro;
                     txtSumPrice.Text = Result.ToString("#,###");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }