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

                    int ID = Convert.ToInt32(e.CommandArgument);
                    // Delete the record

                    FBFoodInventoryController controller = new FBFoodInventoryController();
                    controller.FBInvoice_Delete(ID);
                    //  DeleteRecordByID(ID);
                    // Implement this on your own :)

                    txtInvoiceID.Value = "0";

                    FillInvoiceGrid();
                }


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

                    //  int invoiceID = (int)gvInvoices.DataKeys[e.NewEditIndex].Value;

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

                    if (item != null)
                    {
                        panelAddLineItems.Visible = true;
                        FillSupplierDropDown();
                        FillReportTypeDropDown();
                        btnSave.Text                  = "Update Record";
                        panelGrid.Visible             = false;
                        panelEdit.Visible             = true;
                        txtInvoiceNumber.Text         = item.InvoiceNumber.ToString();
                        txtInvoiceDate.Text           = item.InvoiceDate.ToShortDateString();
                        ddlOrganization.SelectedValue = item.Organization.ToString();
                        ListItem lstitem = ddlSupplier.Items.FindByValue(item.SupplierID.ToString());
                        if (lstitem != null)
                        {
                            ddlSupplier.SelectedValue = item.SupplierID.ToString();
                        }
                        else
                        {
                            AddInActiveSupplier(item.SupplierID);
                        }


                        txtInvoiceID.Value = item.InvoiceID.ToString();
                        //GroupIt();
                        //GetLineItems(item.InvoiceID);
                        GroupIt();
                        GetLineItems(Int32.Parse(txtInvoiceID.Value.ToString()));
                    }
                    else
                    {
                        txtInvoiceID.Value = "0";
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }