private void PopulateCartonData()
        {
            List <PackingListBO> lstPackingLists = GetPolyBagData();

            if (lstPackingLists.Any())
            {
                OrderDetailBO objOrderDetail = new OrderDetailBO();
                objOrderDetail.ID = lstPackingLists[0].OrderDetail;
                objOrderDetail.GetObject();

                /* OrderBO objOrder = new OrderBO();
                 * objOrder.ID = objOrderDetail.Order;
                 * objOrder.GetObject();
                 *
                 * DistributorClientAddressBO objAddress = new DistributorClientAddressBO();
                 * objAddress.ID = (int)objOrder.DespatchToExistingClient;
                 * objAddress.GetObject();*/

                InvoiceOrderBO objInvoiceOrder = new InvoiceOrderBO();
                objInvoiceOrder.OrderDetail = objOrderDetail.ID;

                //string state = (string.IsNullOrEmpty(objAddress.State)) ? string.Empty : objAddress.State;

                this.litAddress.Text = objInvoiceOrder.SearchObjects().Select(o => o.objInvoice.InvoiceNo).SingleOrDefault();

                this.dvScanCarton.Attributes.Add("style", "display:block;");
                this.dvScanPolyBag.Attributes.Add("style", "display:none;");

                this.dvDataContent.Attributes.Add("style", "display:block;");
                this.h3Carton.Attributes.Add("class", "text-info");

                rptCarton.DataSource = lstPackingLists;
                rptCarton.DataBind();

                if ((isCompleted == true) && (noRecords == lstPackingLists.Count))
                {
                    // when carton completed
                    this.h3PolyBags.Attributes.Add("class", "text-success");
                    this.litPolyBags.Text = "Filling Carton is completed. There are <span class=\"badge badge-success\">" + noPolybags.ToString() + "</span> polybags in the Carton.";
                }
            }
            else
            {
                this.dvScanCarton.Attributes.Add("style", "display:none;");
                this.dvScanPolyBag.Attributes.Add("style", "display:block;");
                this.h3PolyBags.Attributes.Add("class", "text-error");
                this.litPolyBags.Text = "Scanned polybag details can not find in the System.";
            }
        }
Beispiel #2
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();
            }
        }
Beispiel #4
0
        private void GenerateLabels(List <PackingList> lstPackingList, int shipto, string shipmentmode)
        {
            string imageLocation = IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\Barcode\\" + Guid.NewGuid() + "\\";

            Directory.CreateDirectory(imageLocation);
            string tempPath = imageLocation + "temp.jpg";

            foreach (PackingList obj in lstPackingList)
            {
                Bitmap lblBM = new Bitmap(400, 275);
                using (Graphics gfx = Graphics.FromImage(lblBM))
                    using (SolidBrush brush = new SolidBrush(Color.White))
                    {
                        gfx.FillRectangle(brush, 0, 0, 400, 275);
                    }
                lblBM.Save(tempPath);

                string labelText = string.Empty;
                string qty       = string.Empty;
                List <KeyValuePair <int, string> > listOrderDetails = new List <KeyValuePair <int, string> >();

                foreach (PackingListViewBO objPackingList in obj.ListPackingList)
                {
                    qty = string.Empty;
                    listOrderDetails.Add(new KeyValuePair <int, string>(objPackingList.PackingList.Value, objPackingList.OrderNumber.Value.ToString()));
                    listOrderDetails.Add(new KeyValuePair <int, string>(objPackingList.PackingList.Value, objPackingList.Client));
                    listOrderDetails.Add(new KeyValuePair <int, string>(objPackingList.PackingList.Value, objPackingList.VLName));

                    PackingListSizeQtyBO objSizeQty = new PackingListSizeQtyBO();
                    objSizeQty.PackingList = objPackingList.PackingList.Value;

                    foreach (PackingListSizeQtyBO objPackSize in objSizeQty.SearchObjects())
                    {
                        string delimeter = string.IsNullOrEmpty(qty) ? string.Empty : ", ";
                        qty = qty + delimeter + objPackSize.objSize.SizeName + "/" + objPackSize.Qty;
                    }

                    listOrderDetails.Add(new KeyValuePair <int, string>(objPackingList.PackingList.Value, qty));
                }

                labelText = obj.CartonNo + "-" + obj.ListPackingList[0].WeeklyProductionCapacity.ToString();

                /* DistributorClientAddressBO objDistributorClientAddress = new DistributorClientAddressBO();
                 * objDistributorClientAddress.ID = shipto;
                 * objDistributorClientAddress.GetObject();*/

                InvoiceOrderBO objInvoiceOrder = new InvoiceOrderBO();
                objInvoiceOrder.OrderDetail = (int)obj.ListPackingList[0].OrderDetail;

                string invoiceno = objInvoiceOrder.SearchObjects().Select(o => o.objInvoice.InvoiceNo).SingleOrDefault();


                GenerateBarcode.GenerateCartonLabel(lblBM, obj.CartonNo.ToString(), listOrderDetails, labelText, imageLocation, invoiceno /* objDistributorClientAddress, shipmentmode*/);

                lblBM.Dispose();
                File.Delete(tempPath);
            }

            // string excelFileName = "CartonLabels" + ".xlsx";

            // CreateExcelDocument excell_app = new CreateExcelDocument(imageLocation, excelFileName, 400, 255, 255, true); //(imageLocation, excelFileName, 400, 275, 275, true); NNM
            string pdfpath = GenerateOdsPdf.PrintCartonBarcode(imageLocation);

            foreach (string imagePath in Directory.GetFiles(imageLocation, "*.jpg"))
            {
                File.Delete(imagePath);
            }

            //this.DownloadExcelFile(imageLocation + excelFileName);//NNM
            if (File.Exists(pdfpath))
            {
                this.DownloadPDFFile(pdfpath);
            }
        }
Beispiel #5
0
        protected void rptPackingList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;

            if (item.ItemIndex > -1 && item.DataItem is PackingList)
            {
                PackingList objPacking = (PackingList)item.DataItem;

                Literal     litCartonNo           = (Literal)item.FindControl("litCartonNo");
                HiddenField hdnPackingListID      = (HiddenField)item.FindControl("hdnPackingListID");
                LinkButton  btnStartPackingCarton = (LinkButton)item.FindControl("btnStartPackingCarton");
                LinkButton  btnAutoFill           = (LinkButton)item.FindControl("btnAutoFill");
                Literal     litTotal        = (Literal)item.FindControl("litTotal");
                HiddenField hdnCartonNo     = (HiddenField)item.FindControl("hdnCartonNo");
                HiddenField hdnShipTo       = (HiddenField)item.FindControl("hdnShipTo");
                HiddenField hdnShipmentMode = (HiddenField)item.FindControl("hdnShipmentMode");
                HiddenField hdnWeeklyID     = (HiddenField)item.FindControl("hdnWeeklyID");
                LinkButton  btnPrintLabel   = (LinkButton)item.FindControl("btnPrintLabel");


                litCartonNo.Text  = "Carton #" + objPacking.CartonNo.ToString();
                hdnCartonNo.Value = objPacking.CartonNo.ToString();

                hdnShipTo.Value       = objPacking.ListPackingList[0].ShipTo.ToString();
                hdnShipmentMode.Value = objPacking.ListPackingList[0].ShipmentMode.ToString();
                hdnWeeklyID.Value     = objPacking.ListPackingList[0].WeeklyProductionCapacity.ToString();

                InvoiceOrderBO objInvoiceOrder = new InvoiceOrderBO();
                objInvoiceOrder.OrderDetail = (int)objPacking.ListPackingList[0].OrderDetail;



                btnPrintLabel.Visible = (objInvoiceOrder.SearchObjects().Count > 0) ? true : false;

                int cartonTotal       = 0;
                int cartonFilledTotal = 0;

                foreach (var s in objPacking.ListPackingList)
                {
                    //List<PackingListSizeQtyBO> lstPackListQtys = s.PackingListSizeQtysWhereThisIsPackingList.Where(m => m.Qty > 0).ToList();
                    //cartonTotal += lstPackListQtys.Select(m => m.Qty).Sum();

                    //List<PackingListCartonItemBO> lstPackListCartonItems = s.PackingListCartonItemsWhereThisIsPackingList.Where(m => m.Count > 0).ToList();
                    //cartonFilledTotal += lstPackListCartonItems.Select(m => m.Count).Sum();

                    cartonTotal       += s.PackingTotal.Value;
                    cartonFilledTotal += s.ScannedTotal.Value;

                    hdnPackingListID.Value = s.PackingList.ToString();
                }

                grandTotal += cartonTotal;

                if (cartonFilledTotal == 0)
                {
                    //start packing
                    btnStartPackingCarton.Text = "Start Packing";
                }
                else if (cartonTotal > cartonFilledTotal)
                {
                    //resume
                    btnStartPackingCarton.Text = "Resume Packing";
                }
                else if (cartonTotal == cartonFilledTotal)
                {
                    //finished
                    btnStartPackingCarton.Visible = false;
                    btnAutoFill.Visible           = false;
                }

                litTotal.Text = "Total " + cartonTotal.ToString();

                DataGrid dgPackingList = (DataGrid)item.FindControl("dgPackingList");
                dgPackingList.DataSource = objPacking.ListPackingList;
                dgPackingList.DataBind();
            }
        }
Beispiel #6
0
        private void ChangeOrderDetails(int orderdetail, int invoiceorder)
        {
            try
            {
                if (orderdetail > 0)
                {
                    InvoiceOrderBO objInvoiceOrder = new InvoiceOrderBO(this.ObjContext);
                    objInvoiceOrder.ID = invoiceorder;
                    objInvoiceOrder.GetObject();

                    DateTime nextmonday = objInvoiceOrder.objOrderDetail.SheduledDate.AddDays(7 - objInvoiceOrder.objOrderDetail.SheduledDate.DayOfWeek == DayOfWeek.Monday ? 7 : (int)objInvoiceOrder.objOrderDetail.SheduledDate.DayOfWeek);

                    using (TransactionScope ts = new TransactionScope())
                    {
                        PackingListBO objPList = new PackingListBO();
                        objPList.OrderDetail = orderdetail;

                        List <PackingListBO> lstPackingLists = objPList.SearchObjects();

                        foreach (PackingListBO objpl in lstPackingLists)
                        {
                            PackingListSizeQtyBO objPlsq = new PackingListSizeQtyBO();
                            objPlsq.PackingList = objpl.ID;
                            List <PackingListSizeQtyBO> lstPackingListSizeQty = objPlsq.SearchObjects();

                            // delete the PackingListSizeQtyBO details
                            foreach (PackingListSizeQtyBO objplsqi in lstPackingListSizeQty)
                            {
                                PackingListSizeQtyBO objPackingListSizeQtyItem = new PackingListSizeQtyBO(this.ObjContext);
                                objPackingListSizeQtyItem.ID = objplsqi.ID;
                                objPackingListSizeQtyItem.GetObject();

                                objPackingListSizeQtyItem.Delete();
                            }

                            //this.ObjContext.SaveChanges();

                            PackingListCartonItemBO objPLCI = new PackingListCartonItemBO();
                            objPLCI.PackingList = objpl.ID;
                            List <PackingListCartonItemBO> lstPackingListCartonItems = objPLCI.SearchObjects();

                            // delete the PackingListCartonItemBO details
                            foreach (PackingListCartonItemBO objplci in lstPackingListCartonItems)
                            {
                                PackingListCartonItemBO objPackingListCartonItem = new PackingListCartonItemBO(this.ObjContext);
                                objPackingListCartonItem.ID = objplci.ID;
                                objPackingListCartonItem.GetObject();

                                objPackingListCartonItem.Delete();
                            }

                            //this.ObjContext.SaveChanges();

                            // delete the PackingListBO details

                            PackingListBO objPackingList = new PackingListBO(this.ObjContext);
                            objPackingList.ID = objpl.ID;
                            objPackingList.GetObject();

                            objPackingList.Delete();
                        }

                        //Creating new packing list record for next week
                        List <WeeklyProductionCapacityBO> lstwpc = (new WeeklyProductionCapacityBO()).SearchObjects().Where(o => o.WeekendDate >= nextmonday && o.WeekendDate <= nextmonday.AddDays(7)).ToList();

                        PackingListBO objp = new PackingListBO();
                        objp.WeeklyProductionCapacity = lstwpc[0].ID;

                        List <PackingListBO> lst = objp.SearchObjects();

                        if (lst.Count > 0)
                        {
                            PackingListBO objNewPl = new PackingListBO(this.ObjContext);
                            objNewPl.Carton      = 1;
                            objNewPl.CartonNo    = 0;
                            objNewPl.CreatedDate = objNewPl.ModifiedDate = DateTime.Now;
                            objNewPl.Creator     = objNewPl.Modifier = this.LoggedUser.ID;
                            objNewPl.OrderDetail = orderdetail;
                            objNewPl.WeeklyProductionCapacity = lstwpc[0].ID;
                            objNewPl.PackingQty = 0;

                            this.ObjContext.SaveChanges();

                            int Newplid = objNewPl.ID;

                            OrderDetailQtyBO objOrderDetailqty = new OrderDetailQtyBO();
                            objOrderDetailqty.OrderDetail = orderdetail;

                            List <OrderDetailQtyBO> lstOrderDetailsQty = objOrderDetailqty.SearchObjects();

                            foreach (OrderDetailQtyBO objOdq in lstOrderDetailsQty)
                            {
                                if (objOdq.Qty > 0)
                                {
                                    PackingListSizeQtyBO objPackingListSizeQty = new PackingListSizeQtyBO(this.ObjContext);
                                    objPackingListSizeQty.PackingList = Newplid;
                                    objPackingListSizeQty.Size        = objOdq.Size;
                                }
                            }
                        }
                        //this.ObjContext.SaveChanges();

                        //change the shipment date, scheduled date
                        OrderDetailBO objOrderDetail = new OrderDetailBO(this.ObjContext);
                        objOrderDetail.ID = orderdetail;
                        objOrderDetail.GetObject();

                        objOrderDetail.SheduledDate = nextmonday;
                        objOrderDetail.ShipmentDate = nextmonday;

                        this.ObjContext.SaveChanges();

                        ts.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while deleting or adding packing list details and changing the shipment date and scheduled date from the AddEditInvoce.aspx", ex);
            }
        }
Beispiel #7
0
        private void ProcessForm()
        {
            //NNM
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    #region Create InvoiceHeader

                    InvoiceBO objInvoice = new InvoiceBO(this.ObjContext);
                    if (QueryID > 0)
                    {
                        objInvoice.ID = this.QueryID;
                        objInvoice.GetObject();
                    }
                    else
                    {
                        objInvoice.Creator     = this.LoggedUser.ID;
                        objInvoice.CreatedDate = DateTime.Now;
                    }
                    objInvoice.InvoiceNo   = this.txtInvoiceNo.Text;
                    objInvoice.InvoiceDate = Convert.ToDateTime(this.txtInvoiceDate.Text);
                    objInvoice.ShipTo      = this.DistributorClientAddress;
                    objInvoice.AWBNo       = this.txtAwbNo.Text;
                    objInvoice.WeeklyProductionCapacity = int.Parse(this.RadComboWeek.SelectedValue);
                    objInvoice.ShipmentMode             = this.ShipmentModeID;
                    objInvoice.IndimanInvoiceNo         = (this.LoggedUserRoleName == UserRole.IndimanAdministrator) ? this.txtIndimanInvoiceNo.Text : string.Empty;
                    objInvoice.IsBillTo = this.chkIsBillTo.Checked;
                    objInvoice.BillTo   = (this.chkIsBillTo.Checked) ? int.Parse(this.ddlBillTo.SelectedValue) : 22;
                    objInvoice.Bank     = int.Parse(this.ddlBank.SelectedValue);

                    if (this.LoggedUserRoleName == UserRole.IndimanAdministrator)
                    {
                        objInvoice.IndimanInvoiceDate = Convert.ToDateTime(this.txtIndimanInvoiceDate.Text);
                    }

                    objInvoice.Modifier     = this.LoggedUser.ID;
                    objInvoice.ModifiedDate = DateTime.Now;

                    this.ObjContext.SaveChanges();

                    ViewState["InvoiceId"] = objInvoice.ID;

                    #endregion

                    #region InvoiceOrderDetail

                    foreach (GridDataItem item in RadInvoice.Items)
                    {
                        TextBox txtRate     = (TextBox)item.FindControl("txtRate");
                        int     id          = int.Parse(((System.Web.UI.WebControls.WebControl)(txtRate)).Attributes["invoiceorder"].ToString());
                        int     orderdetail = int.Parse(((System.Web.UI.WebControls.WebControl)(txtRate)).Attributes["orderdetail"].ToString());

                        TextBox txtIndimanRate = (TextBox)item.FindControl("txtIndimanRate");

                        InvoiceOrderBO objInvoiceOrder = new InvoiceOrderBO(this.ObjContext);
                        if (id > 0)
                        {
                            objInvoiceOrder.ID = id;
                            objInvoiceOrder.GetObject();
                        }

                        objInvoiceOrder.Invoice      = int.Parse(ViewState["InvoiceId"].ToString());
                        objInvoiceOrder.OrderDetail  = orderdetail;
                        objInvoiceOrder.FactoryPrice = Convert.ToDecimal(txtRate.Text);
                        objInvoiceOrder.IndimanPrice = (this.LoggedUserRoleName == UserRole.IndimanAdministrator) ? Convert.ToDecimal(txtIndimanRate.Text) : Convert.ToDecimal("0");
                    }
                    this.ObjContext.SaveChanges();

                    #endregion

                    #region Change Order Detail Status

                    List <int> lstOrders = new List <int>();
                    int        orderid   = 0;

                    if (this.ddlStatus.SelectedItem.Text == "Shipped")
                    {
                        foreach (GridDataItem item in RadInvoice.Items)
                        {
                            TextBox txtRate     = (TextBox)item.FindControl("txtRate");
                            int     orderdetail = int.Parse(((System.Web.UI.WebControls.WebControl)(txtRate)).Attributes["orderdetail"].ToString());

                            OrderDetailBO objOrderDetail = new OrderDetailBO(this.ObjContext);
                            objOrderDetail.ID = orderdetail;
                            objOrderDetail.GetObject();

                            if (objOrderDetail.Order != orderid)
                            {
                                lstOrders.Add(objOrderDetail.Order);
                                orderid = objOrderDetail.Order;
                            }

                            objOrderDetail.Status = 16;
                        }

                        this.ObjContext.SaveChanges();
                    }

                    #endregion

                    #region Change Order Status

                    if (lstOrders.Count > 0)
                    {
                        foreach (int order in lstOrders)
                        {
                            OrderBO objOrder = new OrderBO(this.ObjContext);
                            objOrder.ID = order;
                            objOrder.GetObject();

                            objOrder.Status = 21;
                        }

                        this.ObjContext.SaveChanges();
                    }

                    #endregion

                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                // Log the error
                IndicoLogging.log.Error("Error occured while Adding or Updating Invoicing", ex);
            }
        }