Exemplo n.º 1
0
        protected void gvProducts_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "Delete")
                {
                    // get the ID of the clicked row
                    int ID = Convert.ToInt32(e.CommandArgument);

                    FBFoodInventoryController controller = new FBFoodInventoryController();
                    // Delete the record
                    controller.FBProducts_Delete(ID);

                    FillProductsGrid();
                }


                if (e.CommandName == "Edit")
                {
                    int ID = Convert.ToInt32(e.CommandArgument);


                    FBFoodInventoryController controller = new FBFoodInventoryController();
                    FBFoodInventoryInfo       item       = controller.FBProducts_GetByID(this.ModuleId, ID);

                    if (item != null)
                    {
                        panelGrid.Visible   = false;
                        panelEdit.Visible   = true;
                        txtProductName.Text = item.ProductName.ToString();
                        txtCasePrice.Text   = string.Format("{0:0.00}", item.CasePrice.ToString());
                        //txtCasePrice.Text = item.CasePrice.ToString();
                        txtCaseCount.Text = item.CaseCount.ToString();
                        ddlProductCategory.SelectedValue = item.ProductCategoryID.ToString();
                        txtCaseWeight.Text        = item.CaseWeight.ToString();
                        rblIsActive.SelectedValue = item.IsActive.ToString();
                        txtProductID.Value        = item.ProductID.ToString();
                    }
                    else
                    {
                        txtProductID.Value = "";
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Exemplo n.º 2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                int ID = Convert.ToInt32(txtProductID.Value.ToString());

                FBFoodInventoryController controller = new FBFoodInventoryController();
                // Delete the record
                controller.FBProducts_Delete(ID);

                txtProductID.Value = "";

                FillProductsGrid();
                panelGrid.Visible = true;
                panelEdit.Visible = false;
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }