示例#1
0
 private void Usp_BindGrid_product()
 {
     try
     {
         DataTable dt = new DataTable();
         BLProduct objBL = new BLProduct();
         dt = objBL.BindFullGrid();
         if (dt.Rows.Count > 0)
         {
             dgvProducts.DataSource = dt;
             dgvProducts.Columns["IsActive"].Visible = false;
             dgvProducts.Columns["IsDelete"].Visible = false;
         }
         else
         {
             dgvProducts.DataSource = null;
         }
         dgvProducts.Refresh();
         dgvProducts.Show();
         {
             dgvProducts.DataSource = dt;
             dgvProducts.AllowUserToAddRows = false;
             dgvProducts.AllowUserToDeleteRows = false;
             dgvProducts.Refresh();
             dgvProducts.Show();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
示例#2
0
 private void dgvProducts_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
       {
           //cbProductType.Text = Convert.ToString(dgvProducts.SelectedRows[0].Cells[0].Value);
           if (dgvProducts.SelectedRows.Count > 0)
           {
               txtName.Text = Convert.ToString(dgvProducts.SelectedRows[0].Cells[0].Value);
               string ProductName = txtName.Text;
               BLProduct objProduct = new BLProduct();
               DataTable dt = objProduct.GetID(ProductName);
               if (dt.Rows.Count != 0)
               {
                   lblProductid.Text = dt.Rows[0]["ProductID"].ToString();
               }
               txtCode.Text = Convert.ToString(dgvProducts.SelectedRows[0].Cells["Code"].Value);
               txtbatchno.Text = Convert.ToString(dgvProducts.SelectedRows[0].Cells["Batch No"].Value);
               cbProductType.Text = Convert.ToString(dgvProducts.SelectedRows[0].Cells["Product Type"].Value);
               txtPurchase.Text = Convert.ToString(dgvProducts.SelectedRows[0].Cells["Purchase Price"].Value);
               txtsellingprice.Text = Convert.ToString(dgvProducts.SelectedRows[0].Cells["Selling Price"].Value);
               string Active = Convert.ToString(dgvProducts.SelectedRows[0].Cells[4].Value);
               if (Active == "Yes")
               {
                   cbActive.Checked = true;
               }
               else
               {
                   cbActive.Checked = false;
               }
               btnSave.Text = "Update";
               UnEditable();
           }
       }
       catch (Exception ex)
       {
           MessageBox.Show(ex.Message.ToString());
       }
 }