Ejemplo n.º 1
0
        protected void rptPackingList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            HiddenField hdnCartonNo = (HiddenField)e.Item.FindControl("hdnCartonNo");
            int         cartonNo    = int.Parse(hdnCartonNo.Value.ToString());

            if (Source != null)
            {
                List <PackingList> PackingList = Source.Where(m => m.CartonNo == cartonNo).ToList();

                if (e.CommandName == "PrintLabel")
                {
                    this.GenerateLabels(PackingList);
                }
                else if (e.CommandName == "StartPacking")
                {
                    Response.Redirect("FillCarton.aspx?cartonNo=" + cartonNo + "&&weekendDate=" + WeekEndDate.ToShortDateString());
                }
                else if (e.CommandName == "AutoFill")
                {
                    //HiddenField hdnPackingListID = (HiddenField)e.Item.FindControl("hdnPackingListID");
                    // Auto filling the carton
                    this.AutoFillCarton(PackingList);
                    this.PopulateDataGrid();
                }
                else if (e.CommandName == "ResetCarton")
                {
                    HiddenField hdnWeeklyID = (HiddenField)e.Item.FindControl("hdnWeeklyID");
                    int         weeklyid    = int.Parse(hdnWeeklyID.Value);

                    try
                    {
                        if (cartonNo > 0 && weeklyid > 0)
                        {
                            //List<PackingListBO> lstPackingLists = GetPolyBagData();
                            PackingListBO objPackBO = new PackingListBO();
                            objPackBO.WeeklyProductionCapacity = weeklyid;
                            objPackBO.CartonNo = cartonNo;

                            List <PackingListBO> lstPackingLists = objPackBO.SearchObjects().ToList();

                            using (TransactionScope ts = new TransactionScope())
                            {
                                foreach (PackingListBO objPack in lstPackingLists)
                                {
                                    List <int> lstPackListCartonItemQtys = objPack.PackingListCartonItemsWhereThisIsPackingList.Select(m => m.ID).ToList();

                                    foreach (int id in lstPackListCartonItemQtys)
                                    {
                                        PackingListCartonItemBO obj = new PackingListCartonItemBO(this.ObjContext);
                                        obj.ID = id;
                                        obj.GetObject();

                                        obj.Delete();
                                    }
                                }

                                this.ObjContext.SaveChanges();
                                ts.Complete();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        IndicoLogging.log.Error("Error occured while deleting PackingListCartonItems in ViewPackingLists.aspx", ex);
                    }

                    this.PopulateDataGrid();
                }
            }
            else
            {
                Response.Redirect(Request.RawUrl);
            }
        }