private void btn_Update_Click(object sender, EventArgs e)
        {
            //Get the values from User UI
            p.id          = int.Parse(txt_ProductID.Text);
            p.name        = txt_Name.Text;
            p.category    = cmb_Category.Text;
            p.description = txt_Description.Text;
            p.rate        = decimal.Parse(txt_Rate.Text);
            p.added_date  = DateTime.Now;

            //getting username of the logged in user

            string   loggedUser = frm_Login.loggedIn;
            BLL_User usr        = udal.GetIdFromUsername(loggedUser);

            p.added_by = usr.id;


            //Updating data into database
            bool success = pdal.Update(p);

            if (success == true)
            {
                MessageBox.Show("Product successfully updated");
                clear();

                //Refreshing data grid view
                DataTable dt = pdal.Select();
                dgv_Products.DataSource = dt;
            }
            else
            {
                MessageBox.Show("Failed to update product");
            }
        }
示例#2
0
 private static void Update(Product model)
 {
     try
     {
         DAL_Products.Update(model);
     }
     catch (Exception)
     {
         throw;
     }
 }