Пример #1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            //NNM
            int id          = int.Parse(this.hdnSelectedID.Value);
            int indexid     = int.Parse(this.hdnIndexID.Value);
            int orderdetail = int.Parse(this.hdnOrderDetail.Value);

            try
            {
                if (id > 0)
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        InvoiceOrderBO objInvoiceOrder = new InvoiceOrderBO(this.ObjContext);
                        objInvoiceOrder.ID = id;
                        objInvoiceOrder.GetObject();

                        objInvoiceOrder.Delete();

                        this.ObjContext.SaveChanges();
                        ts.Complete();
                    }
                    this.populateInvoiceOrders(this.QueryID, this.DistributorClientAddress, false, this.ShipmentModeID, false);
                }
                else
                {
                    if (indexid > -1)
                    {
                        List <ReturnInvoiceOrderDetailViewBO> lstInvoiceOrderDetailView = (List <ReturnInvoiceOrderDetailViewBO>)Session["InvoiceOrderDetails"];

                        lstInvoiceOrderDetailView.RemoveAt(indexid);

                        Session["InvoiceOrderDetails"] = lstInvoiceOrderDetailView;

                        this.RadInvoice.DataSource = lstInvoiceOrderDetailView;
                        this.RadInvoice.DataBind();
                    }
                }

                // changing the orderdetail shipment date and scheduled date and delete the packing list details
                //this.ChangeOrderDetails(orderdetail, id);
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while deleting or removing order details from the AddEditInvoicePage.aspx", ex);
            }
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int invoiceID = int.Parse(hdnSelectedID.Value.Trim());

            if (invoiceID > 0)
            {
                try
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        InvoiceBO objInvoice = new InvoiceBO(this.ObjContext);
                        objInvoice.ID = invoiceID;
                        objInvoice.GetObject();

                        List <InvoiceOrderBO> lstInvoiceOrder = (new InvoiceOrderBO()).GetAllObject().Where(o => o.Invoice == objInvoice.ID).ToList();
                        foreach (InvoiceOrderBO objDelInvoiceOrder in lstInvoiceOrder)
                        {
                            InvoiceOrderBO objInvoiceOrder = new InvoiceOrderBO(this.ObjContext);
                            objInvoiceOrder.ID = objDelInvoiceOrder.ID;
                            objInvoiceOrder.GetObject();

                            objInvoiceOrder.Delete();
                        }

                        objInvoice.Delete();
                        this.ObjContext.SaveChanges();
                        ts.Complete();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                this.PopulateDataGrid();
            }
        }