コード例 #1
0
        public string SelectSalesOrderDataDetailed(int PgID, int ObjID, string Reg, string LocCode, string LocType, string PCode, string PType, string Thick, string Specie, string Grade, string Season, string Surf,
                                                   string Wdth, string Len, string Color, string fSort, string Milling, string NoPrint, string FuzzyGrade, string FuzzySort, string FuzzyProd, string sBDt, string sEDt, int OrdNbr, string CustCode, string Lvl,
                                                   int Sort, int Active, int ROnly, int APShipStat, int DateType, int PgNbr, int PgSize, int ByID)
        {
            Commands cmd     = new Commands();
            string   s       = string.Empty;
            int      iResult = 0;

            try
            {
                SalesFunctions sf = new SalesFunctions();
                DataTable      dt = sf.SelectSalesOrderDataDetailed(Reg, LocCode, LocType, PCode, PType, Thick, Specie, Grade, Season, Surf, Wdth, Len, Color, fSort, Milling, NoPrint, FuzzyGrade, FuzzySort, FuzzyProd,
                                                                    sBDt, sEDt, OrdNbr, CustCode, Lvl, Sort, Active, ROnly, APShipStat, DateType, PgNbr, PgSize, ByID);
                s       = GenUtilities.JSON(dt);
                iResult = cmd.LogAjaxCall(PgID, ObjID, 1, "SelectSalesOrderDataDetailed", s.Length, ByID);
                return(s);
            }
            catch (Exception ex)
            {
                iResult = cmd.LogApplicationError("Sales Ord Data Detailed", 0, ByID, ex.Message, 0, "SelectSalesOrderDataDetailed function", ByID);
                JavaScriptSerializer js = new JavaScriptSerializer();
                var response            = new { success = "false", message = ex.Message };
                return(response.ToJSON());
            }
        }
コード例 #2
0
 protected void LoadOrderItemsGrid()
 {
     try
     {
         int NbrItems = 0;
         int OrdNbr   = Convert.ToInt32(this.txtOrderNbr.Text);
         int AllWurth = 0;
         if (chkWurthOnly.Checked == true)
         {
             AllWurth = 1;
         }
         //Commands cmd = new Commands();
         //DataTable dt = cmd.SelectOrderItemData(OrdNbr, 1, 0, _UserID);
         SalesFunctions sf = new SalesFunctions();
         DataTable      dt = sf.SelectLTWurthProductData(OrdNbr, 0, AllWurth, _UserID);
         gvOrderItems.DataSource = dt;
         gvOrderItems.DataBind();
         NbrItems         = dt.Rows.Count;
         txtNbrItems.Text = NbrItems.ToString();
         if (NbrItems > 0)
         {
             if (NbrItems > 0)
             {
                 spnPrintBtn1.Style["display"] = "inline";
             }
             if (NbrItems > 20)
             {
                 spnPrintBtn2.Style["display"] = "inline";
             }
             if (NbrItems > 40)
             {
                 spnPrintBtn3.Style["display"] = "inline";
             }
             if (NbrItems > 60)
             {
                 spnPrintBtn4.Style["display"] = "inline";
             }
             if (NbrItems > 80)
             {
                 spnPrintBtn5.Style["display"] = "inline";
             }
             if (NbrItems > 100)
             {
                 spnPrintBtn6.Style["display"] = "inline";
             }
         }
         else
         {
             this._ErrMsg          = "No order items were found.";
             this.lblErrorMsg.Text = this._ErrMsg;
         }
     }
     catch (Exception ex)
     {
         this._ErrMsg          = "Error while loading order items: " + ex.Message;
         this.lblErrorMsg.Text = this._ErrMsg;
     }
 }
コード例 #3
0
        public string SelectSalesPersonList(int PgID, int ObjID, int Active, int ByID)
        {
            Commands cmd     = new Commands();
            string   s       = string.Empty;
            int      iResult = 0;

            try
            {
                SalesFunctions sf = new SalesFunctions();
                DataTable      dt = sf.SelectSalesPersonList(Active, ByID);
                s       = GenUtilities.JSON(dt);
                iResult = cmd.LogAjaxCall(PgID, ObjID, 1, "SelectSalesPersonList", s.Length, ByID);
                return(s);
            }
            catch (Exception ex)
            {
                iResult = cmd.LogApplicationError("Sales Pers List", 0, ByID, ex.Message, 0, "SelectSalesPersonList function", ByID);
                JavaScriptSerializer js = new JavaScriptSerializer();
                var response            = new { success = "false", message = ex.Message };
                return(response.ToJSON());
            }
        }
コード例 #4
0
        public string SelectProductItemData(int PgID, int ObjID, int PMID, int PLID, string ProdType, string ProdCode, int ByID)
        {
            Commands cmd     = new Commands();
            string   s       = string.Empty;
            int      iResult = 0;

            try
            {
                SalesFunctions sf = new SalesFunctions();
                DataTable      dt = sf.SelectProductItemData(PMID, PLID, ProdType, ProdCode, ByID);
                s       = GenUtilities.JSON(dt);
                iResult = cmd.LogAjaxCall(PgID, ObjID, 1, "SelectProductItemData", s.Length, ByID);
                return(s);
            }
            catch (Exception ex)
            {
                iResult = cmd.LogApplicationError("Prod Item Data", PMID, ByID, ex.Message, 0, "SelectProductItemData function", ByID);
                JavaScriptSerializer js = new JavaScriptSerializer();
                var response            = new { success = "false", message = ex.Message };
                return(response.ToJSON());
            }
        }
コード例 #5
0
        public string SelectProductDataForTargetWeek(int PgID, int ObjID, string ProdType, string ProdCode, int WeekNbr, int Rollup, int RollProd, int NoLoc, int NoCust, int NoForecast, int NoOrd, int NoProd, int Sort, int PgNbr, int PgSize, int ByID)
        {
            Commands cmd     = new Commands();
            string   s       = string.Empty;
            int      iResult = 0;

            try
            {
                SalesFunctions sf = new SalesFunctions();
                DataTable      dt = sf.SelectProductDataForTargetWeek(ProdType, ProdCode, WeekNbr, Rollup, RollProd, NoLoc, NoCust, NoForecast, NoOrd, NoProd, Sort, PgNbr, PgSize, ByID);
                s       = GenUtilities.JSON(dt);
                iResult = cmd.LogAjaxCall(PgID, ObjID, 1, "SelectProductDataForTargetWeek", s.Length, ByID);
                return(s);
            }
            catch (Exception ex)
            {
                iResult = cmd.LogApplicationError("Sales Grp List", 0, ByID, ex.Message, 0, "SelectProductDataForTargetWeek function", ByID);
                JavaScriptSerializer js = new JavaScriptSerializer();
                var response            = new { success = "false", message = ex.Message };
                return(response.ToJSON());
            }
        }
コード例 #6
0
        public string SelectLTShippingList(int PgID, int ObjID, int ShipNbr, string Region, string Loc, string Thickness, string Species, string Grade, string Len, string Color, string fSort, string Milling,
                                           string NoPrint, int Vendor, string sBDt, string sEDt, int Sort, int PgNbr, int PgSize, int ByID)
        {
            Commands cmd     = new Commands();
            string   s       = string.Empty;
            int      iResult = 0;

            try
            {
                SalesFunctions sf = new SalesFunctions();
                DataTable      dt = sf.SelectLTShippingList(ShipNbr, Region, Loc, Thickness, Species, Grade, Len, Color, fSort, Milling, NoPrint, Vendor, sBDt, sEDt, Sort, PgNbr, PgSize, ByID);
                s       = GenUtilities.JSON(dt);
                iResult = cmd.LogAjaxCall(PgID, ObjID, 1, "SelectLTShippingList", s.Length, ByID);
                return(s);
            }
            catch (Exception ex)
            {
                iResult = cmd.LogApplicationError("Ship List", ShipNbr, ByID, ex.Message, 0, "SelectLTShippingList function", ByID);
                JavaScriptSerializer js = new JavaScriptSerializer();
                var response            = new { success = "false", message = ex.Message };
                return(response.ToJSON());
            }
        }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string   FileName       = string.Empty;
            int      FirstNCol      = 0;
            int      FirstQtyCol    = 0;
            int      LastNCol       = 0;
            string   MyCSV          = string.Empty;
            int      NbrCols        = 0;
            int      NbrColsVisible = 0;
            DateTime now            = DateTime.Now;
            int      NoZeros        = 0;
            string   UIType         = string.Empty;

            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetValidUntilExpires(true);
            Response.Expires         = -1441;
            Response.ExpiresAbsolute = DateTime.Now;
            Response.CacheControl    = "no-cache";
            Response.AddHeader("Pragma", "no-cache");
            Response.AddHeader("Pragma", "no-store");
            Response.AddHeader("cache-control", "no-cache");
            Response.Cache.SetNoServerCaching();

            _PageID   = Convert.ToInt32(Request["p"]);
            _ObjectID = Convert.ToInt32(Request["q"]);

            _CBuildNbr = System.Configuration.ConfigurationManager.AppSettings["BuildNbr"];
            string logFile = System.Configuration.ConfigurationManager.AppSettings["AppLogFilePath"];

            string ips = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

            _Browser = new Browser(System.Web.HttpContext.Current.Request, ips, "");

            string usrname = Request.ServerVariables["LOGON_USER"];

            _UserName = usrname;
            _user     = new CurrentUser(usrname, logFile, "");         // SessionHelper.GetCurrentUser(Request.ServerVariables["LOGON_USER"]);

            // check for access
            if (_user == null)
            {
                //HttpContext.Current.Session["NoAccessMsg"] = "You do not have access to the Sales Plan portion of this application";
                HttpContext.Current.Response.Redirect("NoAccess.aspx", true);
            }
            if (_user.IsLoaded == false || _user.IsValid == false)
            {
                //HttpContext.Current.Session["NoAccessMsg"] = "You do not have high enough access to export data.";
                HttpContext.Current.Response.Redirect("NoAccess.aspx", true);
            }

            _ReqPageID = Convert.ToInt32(Request["p"]);             // 58-Sales Plan, 55-CT
            _ObjectID  = Convert.ToInt32(Request["oj"]);

            // ****************************************************************************
            try
            {
                int[] colvis = new int[41];
                if (_ReqPageID == 55 && _ObjectID == 1)
                {
                    UIType = "ConsolCol";
                }
                if (_ReqPageID == 58 && _ObjectID == 1)
                {
                    UIType = "SPlnCols";
                }
                if (_ReqPageID == 58 && _ObjectID == 2)
                {
                    UIType = "SalesPFltr";
                }

                // get data
                Commands cmd = new Commands();
                // ************** Get global settings ***********************
                DataTable uidata = cmd.SelectUserExportDataHdr(_user.UserID, _ReqPageID, _ObjectID, _user.UserID);
                if (uidata.Rows.Count > 0)
                {
                    FileName    = uidata.Rows[0]["ExportFileName"].ToString();                  // "CAT_Availability_";
                    LastNCol    = Convert.ToInt32(uidata.Rows[0]["NbrColumns"]);
                    FirstQtyCol = Convert.ToInt32(uidata.Rows[0]["FirstQtyCol"]);
                    NoZeros     = Convert.ToInt32(uidata.Rows[0]["Setting3"]);
                }
                else
                {
                    FileName = "Generic Export for ";
                }
                FileName = FileName.Replace(" ", "_") + " " + now.ToString("yyyy-dd-MM") + ".csv";

                // ************** GET COLUMN FORMAT data ***********************
                //DataTable CDat = cmd.SelectUIColumnData(_ReqPageID, _ObjectID, _user.UserID);
                DataTable CDat = cmd.SelectUserInterfaceItems(_user.UserID, UIType, _user.UserID);
                NbrCols = CDat.Rows.Count;
                for (int itm = 0; itm < NbrCols; itm++)
                {
                    colvis[itm] = Convert.ToInt32(CDat.Rows[itm]["IsVisible"]);
                    if (colvis[itm] == 1)
                    {
                        NbrColsVisible++;
                    }
                    if (itm == FirstQtyCol)
                    {
                        FirstNCol = NbrColsVisible - 1;
                    }
                }

                int ColCount = 0;
                for (int itm = 0; itm < NbrCols; itm++)
                {
                    if (colvis[itm] == 1)
                    {
                        ColCount++;
                    }
                }

                //_NbrCols = NbrCols; // ColCount;
                _NbrShownIdentCols = FirstNCol;
                _FirstQtyCol       = FirstQtyCol;

                // Get raw list of data for export
                SalesFunctions sf = new SalesFunctions();
                DataTable      dt = sf.SelectUserExportData(_user.UserID, _ReqPageID, _ObjectID, _user.UserID);
                // change table to CSV format
                if (dt.Rows.Count > 0)
                {
                    MyCSV = ToCSV(dt, CDat, NbrCols, FirstQtyCol);
                    // save CSV file
                    HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", FileName));
                    HttpContext.Current.Response.ContentType = "application/CSV";
                    Response.ContentEncoding = Encoding.UTF8;
                }
                Response.Write(MyCSV);
                Response.Flush();
                Response.End();
            }
            catch (System.Threading.ThreadAbortException ext)
            {
                // nothing
            }
            catch (Exception ex)
            {
                //this.lblStatusMsg.Text = "Error: " + ex.Message;
            }
        }
コード例 #8
0
        private void ExportGridToPDF()
        {
            //this.lblErrorMsg.Text = "";
            try
            {
                string   CellVal        = string.Empty;
                string   Color          = string.Empty;
                int      CurrentRow     = 0;
                int      FirstNCol      = 14;
                int      FirstQtyCol    = 14;
                int      LastNCol       = 39;
                int      Excl0          = 0;
                int      ExclDups       = 1;
                double   fig            = 0;
                string   FileName       = string.Empty;
                string   ForeVal        = string.Empty;
                string   FSort          = string.Empty;
                string   Grade          = string.Empty;
                string   GradeID        = string.Empty;
                string   LocID          = string.Empty;
                int      NbrColsVisible = 0;
                string   NextVal        = string.Empty;
                string   NoPrint        = string.Empty;
                int      NoZeros        = 0;
                DateTime now            = DateTime.Now;
                string   prod           = string.Empty;
                string   prodA          = string.Empty;
                string   Product        = string.Empty;
                string   Reg            = string.Empty;    // this.lbxRegionF.SelectedValue;
                string   Region         = string.Empty;
                string   RollupItems    = string.Empty;
                string   s          = string.Empty;
                string   spec       = string.Empty;
                string   SpecID     = string.Empty;
                bool     STProd     = true;
                bool     STProdA    = false;
                bool     STSpec     = false;
                bool     STThick    = false;
                bool     STGrade    = false;
                bool     STColor    = false;
                bool     STSort     = false;
                bool     STNoP      = false;
                string   SubTotals  = string.Empty;
                string   Thickness  = string.Empty;
                int      TotalsLast = 0;
                string   UIType     = string.Empty;

                PdfPCell cell;
                int[]    colvis = new int[41];
                if (_ReqPageID == 55 && _ObjectID == 1)
                {
                    UIType = "ConsolCol";
                }
                if (_ReqPageID == 58 && _ObjectID == 1)
                {
                    UIType = "SPlnCols";
                }
                if (_ReqPageID == 58 && _ObjectID == 2)
                {
                    UIType = "SalesPFltr";
                }
                Commands cmd = new Commands();

                // ************** Get global settings ***********************
                DataTable uidata = cmd.SelectUserExportDataHdr(_user.UserID, _ReqPageID, _ObjectID, _user.UserID);
                if (uidata.Rows.Count > 0)
                {
                    FileName    = uidata.Rows[0]["ExportFileName"].ToString();                  // "CAT_Availability_";
                    LastNCol    = Convert.ToInt32(uidata.Rows[0]["NbrColumns"]);
                    FirstQtyCol = Convert.ToInt32(uidata.Rows[0]["FirstQtyCol"]);
                    NoZeros     = Convert.ToInt32(uidata.Rows[0]["Setting3"]);
                }
                else
                {
                    FileName = "Generic Export for ";
                }
                FileName = FileName + " " + now.ToString("yyyy-dd-MM");

                // ************** GET COLUMN FORMAT data ***********************
                //DataTable CDat = cmd.SelectUIColumnData(_ReqPageID, _ObjectID, _user.UserID);
                DataTable CDat    = cmd.SelectUserInterfaceItems(_user.UserID, UIType, _user.UserID);
                int       NbrCols = CDat.Rows.Count;
                for (int itm = 0; itm < NbrCols; itm++)
                {
                    colvis[itm] = Convert.ToInt32(CDat.Rows[itm]["IsVisible"]);
                    if (colvis[itm] == 1)
                    {
                        NbrColsVisible++;
                    }
                    if (itm == FirstQtyCol)
                    {
                        FirstNCol = NbrColsVisible - 1;
                    }
                }
                _widths = new float[NbrColsVisible];                 // { 76, 76, 80, 74, 79, 72, 72, 76, 58, 40, 60, 72, 136, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66 };

                int ColCount = 0;
                for (int itm = 0; itm < NbrCols; itm++)
                {
                    if (colvis[itm] == 1)
                    {
                        _widths[ColCount] = Convert.ToInt32(CDat.Rows[itm]["ColumnWidth"]);
                        ColCount++;
                    }
                }

                _NbrCols           = LastNCol;       // ColCount;
                _NbrShownIdentCols = FirstNCol;
                _FirstQtyCol       = FirstQtyCol;

                // Get raw list of data for export
                SalesFunctions sf = new SalesFunctions();
                DataTable      dt = sf.SelectUserExportData(_user.UserID, _ReqPageID, _ObjectID, _user.UserID);
                if (dt.Rows.Count > 0)
                {
                    int cols = dt.Columns.Count;
                    int rows = dt.Rows.Count;
                    RollupItems = dt.Rows[0]["RollupCols"].ToString();
                    if (_ReqPageID == 58 && _ObjectID == 1)
                    {
                        SubTotals = dt.Rows[0]["SubTotals"].ToString();
                        if (SubTotals.Substring(1, 0) == "0")
                        {
                            STProd = false;
                        }
                        if (SubTotals.Substring(2, 1) == "1")
                        {
                            STProdA = true;
                        }
                        if (SubTotals.Substring(3, 1) == "1")
                        {
                            STSpec = true;
                        }
                        if (SubTotals.Substring(4, 1) == "1")
                        {
                            STThick = true;
                        }
                        if (SubTotals.Substring(5, 1) == "1")
                        {
                            STGrade = true;
                        }
                        if (SubTotals.Substring(6, 1) == "1")
                        {
                            STColor = true;
                        }
                        if (SubTotals.Substring(7, 1) == "1")
                        {
                            STSort = true;
                        }
                        if (SubTotals.Substring(8, 1) == "1")
                        {
                            STNoP = true;
                        }
                    }
                    string parag = FileName;                     // + " " + now.ToString("yyyy-dd-MM");

                    // ***************************************************************************************
                    // create PDF document object
                    Document pdfDoc = new Document(PageSize.LETTER.Rotate(), 30, 30, 46, 30);
                    System.IO.MemoryStream mStream = new System.IO.MemoryStream();
                    PdfWriter            writer    = PdfWriter.GetInstance(pdfDoc, mStream);
                    iTextSharp.text.Font font5     = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA, 5);
                    // Our custom Header and Footer is done using Event Handler
                    TwoColumnHeaderFooter PageEventHandler = new TwoColumnHeaderFooter();
                    writer.PageEvent = PageEventHandler;
                    // Define the page header
                    PageEventHandler.Title      = parag;
                    PageEventHandler.HeaderFont = FontFactory.GetFont(BaseFont.COURIER_BOLD, 10, iTextSharp.text.Font.BOLD);
                    //PageEventHandler.HeaderLeft = "Group";
                    //PageEventHandler.HeaderRight = "1";
                    pdfDoc.Open();

                    // create PDF table object
                    PdfPTable pdfTable = new PdfPTable(NbrColsVisible);
                    pdfTable.DefaultCell.BorderWidth = 1;
                    pdfTable.DefaultCell.Padding     = 1;
                    //PdfPRow row = null;
                    //float[] widths = new float[] { 76, 76, 80, 74, 79, 72, 72, 76, 58, 40, 60, 72, 136, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66 };
                    pdfTable.SetWidths(_widths);
                    pdfTable.WidthPercentage = 100;
                    pdfTable.HeaderRows      = 1;
                    //pdfTable.SkipLastFooter = true;

                    // ****************************** Write to PDF *******************************************
                    //PdfPCell Tcell = new PdfPCell(new Phrase(parag));
                    //Tcell.Colspan = dt.Columns.Count;
                    //Tcell.HorizontalAlignment = Element.ALIGN_CENTER;

                    // Add header title
                    //pdfTable.AddCell(Tcell);
                    //PdfPCell cell;

                    // Add column titles
                    for (int cz = 0; cz < CDat.Rows.Count; cz++)
                    {
                        if (colvis[cz] == 1)
                        {
                            cell = new PdfPCell(new Phrase(CDat.Rows[cz]["ColumnTitle"].ToString(), font5));
                            cell.BackgroundColor     = BaseColor.LIGHT_GRAY;
                            cell.HorizontalAlignment = 1;
                            pdfTable.AddCell(cell);
                        }
                    }

                    // ***************************************************************************************
                    // add data rows
                    CurrentRow = 0;
                    foreach (DataRow r in dt.Rows)
                    {
                        TotalsLast = 0;
                        if (STProd && prod != r["ProductCode"].ToString() && CurrentRow > 0)
                        {
                            AddTotalsRow(_Ptotal, pdfTable, "Product Totals", 3, _NbrShownIdentCols, (NbrCols - _FirstQtyCol), colvis, 1);
                            for (int pt = 0; pt < 36; pt++)
                            {
                                _Ptotal[pt] = 0;
                            }
                            TotalsLast = 1;
                        }
                        if (STProdA && CurrentRow > 0 && prodA != r["ProductCode"].ToString() + " " + r["ItemLength"].ToString() + " " + r["Color"].ToString() + " " + r["Sort"].ToString() + " " + r["Milling"].ToString() + " " + r["NoPrint"].ToString())
                        {
                            AddTotalsRow(_PAtotal, pdfTable, "PProduct/Attribute Totals", 6, _NbrShownIdentCols, (NbrCols - _FirstQtyCol), colvis, 1);
                            for (int pat = 0; pat < 36; pat++)
                            {
                                _PAtotal[pat] = 0;
                            }
                            TotalsLast = 1;
                        }
                        if (STSpec && spec != r["Specie"].ToString() && CurrentRow > 0)
                        {
                            AddTotalsRow(_Stotal, pdfTable, "Species Totals", 0, _NbrShownIdentCols, (NbrCols - _FirstQtyCol), colvis, 1);
                            for (int st = 0; st < 36; st++)
                            {
                                _Stotal[st] = 0;
                            }
                            TotalsLast = 1;
                        }
                        if (STThick && CurrentRow > 0 && Thickness != r["Thickness"].ToString())
                        {
                            AddTotalsRow(_Ttotal, pdfTable, "Thickness Totals", 1, _NbrShownIdentCols, (NbrCols - _FirstQtyCol), colvis, 1);
                            for (int tt = 0; tt < 36; tt++)
                            {
                                _Ttotal[tt] = 0;
                            }
                            TotalsLast = 1;
                        }
                        if (STGrade && CurrentRow > 0 && Grade != r["Grade"].ToString())
                        {
                            AddTotalsRow(_Gtotal, pdfTable, "Grade Totals", 2, _NbrShownIdentCols, (NbrCols - _FirstQtyCol), colvis, 1);
                            for (int tg = 0; tg < 36; tg++)
                            {
                                _Gtotal[tg] = 0;
                            }
                            TotalsLast = 1;
                        }
                        if (STColor && CurrentRow > 0 && Color != r["Color"].ToString())
                        {
                            AddTotalsRow(_Ctotal, pdfTable, "Color Totals", 6, _NbrShownIdentCols, (NbrCols - _FirstQtyCol), colvis, 1);
                            for (int ct = 0; ct < 36; ct++)
                            {
                                _Ctotal[ct] = 0;
                            }
                            TotalsLast = 1;
                        }
                        if (STSort && CurrentRow > 0 && FSort != r["Sort"].ToString())
                        {
                            AddTotalsRow(_Sttotal, pdfTable, "Sort Totals", 7, _NbrShownIdentCols, (NbrCols - _FirstQtyCol), colvis, 1);
                            for (int stt = 0; stt < 36; stt++)
                            {
                                _Sttotal[stt] = 0;
                            }
                            TotalsLast = 1;
                        }
                        if (STNoP && CurrentRow > 0 && NoPrint != r["NoPrint"].ToString())
                        {
                            AddTotalsRow(_NPtotal, pdfTable, "NoPrint Totals", 9, _NbrShownIdentCols, (NbrCols - _FirstQtyCol), colvis, 1);
                            for (int npt = 0; npt < 36; npt++)
                            {
                                _NPtotal[npt] = 0;
                            }
                            TotalsLast = 1;
                        }

                        // Add Column by column for each row
                        for (int c = 0; c < NbrCols; c++)
                        {
                            ForeVal = "";
                            NextVal = "";
                            CellVal = r[c].ToString();
                            if (c < FirstQtyCol)
                            {
                                if (CurrentRow > 0)
                                {
                                    ForeVal = dt.Rows[CurrentRow - 1][c].ToString();
                                }
                                if (CurrentRow < (dt.Rows.Count - 1))
                                {
                                    NextVal = dt.Rows[CurrentRow + 1][c].ToString();
                                }
                                if (TotalsLast == 1)
                                {
                                    ForeVal = "";
                                }
                            }

                            if (colvis[c] == 1)
                            {
                                cell = new PdfPCell();
                                if (c < FirstQtyCol)
                                {
                                    if (ExclDups == 1)
                                    {
                                        if (ForeVal != CellVal && NextVal != CellVal)
                                        {
                                            cell.Phrase = new Phrase(CellVal, font5);
                                        }
                                        if (ForeVal == CellVal && NextVal == CellVal)
                                        {
                                            if (c == (NbrCols - 1))
                                            {
                                                cell.Border = PdfPCell.LEFT_BORDER | PdfPCell.RIGHT_BORDER | PdfPCell.BOTTOM_BORDER;
                                            }
                                            else
                                            {
                                                cell.Border = PdfPCell.LEFT_BORDER | PdfPCell.RIGHT_BORDER;
                                            }
                                            cell.Phrase = new Phrase("", font5);
                                            //col = new PdfPCell(new Phrase("", font5));
                                        }
                                        if (ForeVal == CellVal && NextVal != CellVal)
                                        {
                                            cell.Border = PdfPCell.LEFT_BORDER | PdfPCell.RIGHT_BORDER | PdfPCell.BOTTOM_BORDER;
                                            cell.Phrase = new Phrase("", font5);
                                        }
                                        if (ForeVal != CellVal && NextVal == CellVal)
                                        {
                                            cell.Border = PdfPCell.LEFT_BORDER | PdfPCell.RIGHT_BORDER | PdfPCell.TOP_BORDER;
                                            cell.Phrase = new Phrase(CellVal, font5);
                                        }
                                    }
                                    else
                                    {
                                        cell.Phrase = new Phrase(CellVal, font5);
                                    }
                                }
                                else
                                {
                                    if (c >= FirstQtyCol && Convert.ToDouble(CellVal) == 0 && NoZeros == 0)
                                    {
                                        cell.Phrase = new Phrase("", font5);
                                    }
                                    else
                                    {
                                        cell.Phrase = new Phrase(CellVal, font5);
                                    }
                                }
                                cell.SetLeading(6, 0);
                                if (c < FirstQtyCol)
                                {
                                    cell.BackgroundColor = new BaseColor(System.Drawing.Color.Cornsilk);
                                }
                                //cell.MinimumHeight = 10.0F;
                                //cell.PaddingTop = 1;
                                pdfTable.AddCell(cell);
                            }
                            if (c >= FirstQtyCol)
                            {
                                fig = Convert.ToDouble(CellVal);
                                if (STProd)
                                {
                                    _Ptotal[c - FirstQtyCol] += fig;
                                }
                                if (STProdA)
                                {
                                    _PAtotal[c - FirstQtyCol] += fig;
                                }
                                if (STSpec)
                                {
                                    _Stotal[c - FirstQtyCol] += fig;
                                }
                                if (STThick)
                                {
                                    _Ttotal[c - FirstQtyCol] += fig;
                                }
                                if (STGrade)
                                {
                                    _Gtotal[c - FirstQtyCol] += fig;
                                }
                                if (STColor)
                                {
                                    _Ctotal[c - FirstQtyCol] += fig;
                                }
                                if (STSort)
                                {
                                    _Sttotal[c - FirstQtyCol] += fig;
                                }
                                if (STNoP)
                                {
                                    _NPtotal[c - FirstQtyCol] += fig;
                                }
                                _GrandTotals[c - FirstQtyCol] += fig;
                                _PgTotals[c - FirstQtyCol]    += fig;
                            }
                            SValues[c] = CellVal;                               // capture last value
                        }
                        prod      = r["ProductCode"].ToString();
                        prodA     = r["ProductCode"].ToString() + " " + r["ItemLength"].ToString() + " " + r["Color"].ToString() + " " + r["Sort"].ToString() + " " + r["Milling"].ToString() + " " + r["NoPrint"].ToString();
                        spec      = r["Specie"].ToString();
                        FSort     = r["Sort"].ToString();
                        Color     = r["Color"].ToString();
                        NoPrint   = r["NoPrint"].ToString();
                        Grade     = r["Grade"].ToString();
                        Thickness = r["Thickness"].ToString();
                        CurrentRow++;
                    }

                    // Add final totals
                    AddTotalsRow(_GrandTotals, pdfTable, "Grand Total Quantities", 0, _NbrShownIdentCols, (NbrCols - _FirstQtyCol), colvis, 0);

                    pdfDoc.Add(pdfTable);
                    pdfDoc.Close();
                    Response.ContentType = "application/octet-stream";
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName.Replace(" ", "_") + ".pdf");
                    Response.Clear();
                    Response.BinaryWrite(mStream.ToArray());
                    Response.End();
                }
            }
            catch (DocumentException de)
            {
                this._ErrMsg = "Error while generating PDF: " + de.Message;
                //this.lblErrorMsg.Text = this._ErrMsg;
            }
            catch (IOException ioEx)
            {
                this._ErrMsg = "Error while generating PDF: " + ioEx.Message;
                //this.lblErrorMsg.Text = this._ErrMsg;
            }
            catch (System.Threading.ThreadAbortException ext)
            {
                // nothing
            }
            catch (Exception ex)
            {
                this._ErrMsg = "Error while generating PDF: " + ex.Message;
                //this.lblErrorMsg.Text = this._ErrMsg;
            }
        }
コード例 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
            Response.Cache.SetNoStore();
            Response.ExpiresAbsolute = DateTime.Now;
            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoServerCaching();
            Response.Cache.SetValidUntilExpires(true);
            Response.Cache.SetNoStore();
            Response.Cache.SetExpires(DateTime.Parse(DateTime.Now.ToString()));
            Response.Expires      = -1441;
            Response.CacheControl = "no-cache";
            Response.DisableKernelCache();

            // establish initial and default values
            string s       = string.Empty;
            string s2      = string.Empty;
            string s3      = string.Empty;
            string usrname = string.Empty;

            //_PgNbr = 0;
            _PgSize = 20;
            string logFilePath = System.Configuration.ConfigurationManager.AppSettings["AppLogFilePath"].ToString();

            // grab browser data
            if (Session["CurrentUser"] == null)
            {
                string ips           = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
                string CurrSessionID = System.Web.HttpContext.Current.Session.SessionID;
                _Browser = new CurrBrowser(System.Web.HttpContext.Current.Request);
            }
            else
            {
                _Browser = (CurrBrowser)Session["bw"];
            }

            // check for user rights to this page
            if (Session["UserName"] == null)
            {
                usrname = Request.ServerVariables["LOGON_USER"];
                HttpContext.Current.Session["UserName"] = usrname;
            }
            else
            {
                usrname = HttpContext.Current.Session["UserName"].ToString();
            }

            // get user object and put it in the session
            if (_user == null)
            {
                if (HttpContext.Current.Session["CurrentUser"] != null)
                {
                    _user = (CurrentUser)HttpContext.Current.Session["CurrentUser"];
                }
                else
                {
                    _user = new CurrentUser(usrname, logFilePath, "");                     // SessionHelper.GetCurrentUser(Request.ServerVariables["LOGON_USER"]);
                    HttpContext.Current.Session["CurrentUser"] = _user;
                }
            }

            // Access rule
            if (_user == null || !_user.IsValid)
            {
                string AppLog = System.Configuration.ConfigurationManager.AppSettings["AppLogFilePath"].ToString();
                Log.WriteLogEntry("User Login failed " + usrname, AppLog);
                Session["NoAccessMsg"] = "You do not have access to forecasting";
                Response.Redirect("../NoAcc/NoAccess.aspx", true);
            }

            // check for specific rights
            if (!_user.IsInRole("wurthedt") && !_user.IsInRole("datmngtedit") && !_user.IsInRole("datmngtview") && !_user.IsAdmin == true && !_user.IsInRole("forecastedit"))
            {
                Session["NoAccessMsg"] = "You do not have access to wurth generation.";
                Response.Redirect("../NoAcc/NoAccess.aspx", true);
            }
            this._CanEdit = true;
            this._IsAdmin = _user.IsAdmin;
            _UserID       = _user.UserID;
            int NbrItems = 0;

            //string inbr = "var jogItemNbr=[[i1],[i2],[i3],[i4],[i5],[i6],[i7],[i8],[i9],[i10],[i11],[i12],[i13],[i14],[i15],[i16],[i17],[i18],[i19],[i20]];";
            //string pobr = "var jogPONbr=[[i1],[i2],[i3],[i4],[i5],[i6],[i7],[i8],[i9],[i10],[i11],[i12],[i13],[i14],[i15],[i16],[i17],[i18],[i19],[i20]];";
            //string ft = "var jogFootage=[[i1],[i2],[i3],[i4],[i5],[i6],[i7],[i8],[i9],[i10],[i11],[i12],[i13],[i14],[i15],[i16],[i17],[i18],[i19],[i20]];";
            //string len = "var jogLen=[[i1],[i2],[i3],[i4],[i5],[i6],[i7],[i8],[i9],[i10],[i11],[i12],[i13],[i14],[i15],[i16],[i17],[i18],[i19],[i20]];";

            if (!this.IsPostBack)
            {
                try
                {
                    string CustAddr    = string.Empty;
                    string CustCity    = string.Empty;
                    string CustCountry = string.Empty;
                    string CustName    = string.Empty;
                    string CustPO      = string.Empty;
                    string CustSt      = string.Empty;
                    string CustZip     = string.Empty;
                    string ItemNbr     = string.Empty;
                    double Fig         = 0;
                    _Page      = Convert.ToInt32(Request["p"]);
                    _OrdNbr    = Convert.ToInt32(Request["o"]);
                    _WurthOnly = Convert.ToInt32(Request["w"]);
                    if (_OrdNbr > 0)
                    {
                        // Load Order and associated data
                        //Commands cmd = new Commands();
                        //DataTable dt0 = cmd.SelectOrderNbrData(_OrdNbr, _UserID);
                        //if (dt0.Rows.Count > 0)
                        //{
                        //	CustName = dt0.Rows[0]["CustName"].ToString();
                        //	CustAddr = dt0.Rows[0]["CustAddress"].ToString();
                        //	CustCity = dt0.Rows[0]["CustCity"].ToString();
                        //	CustCountry = dt0.Rows[0]["Country"].ToString();
                        //	CustSt = dt0.Rows[0]["StProv"].ToString();
                        //	CustZip = dt0.Rows[0]["Zip"].ToString();
                        //	CustPO = dt0.Rows[0]["CustPO"].ToString();
                        //}

                        // populate page objects
                        DataRow dr;
                        //DataTable dt = cmd.SelectOrderItemData(_OrdNbr, 1, (_Page + 1), _UserID);
                        SalesFunctions sf = new SalesFunctions();
                        DataTable      dt = sf.SelectLTWurthProductData(_OrdNbr, (_Page + 1), _WurthOnly, _UserID);
                        NbrItems = dt.Rows.Count;
                        if (NbrItems > 0)
                        {
                            for (int rowz = 0; rowz < 20; rowz++)
                            {
                                if (rowz < NbrItems)
                                {
                                    dr      = dt.Rows[rowz];
                                    ItemNbr = "0";
                                    Label lbl = new Label();
                                    // if more than one item, show print area (half page each)
                                    if (rowz == 1)
                                    {
                                        this.divOrderItem1.Style["display"] = "block";
                                    }
                                    if (rowz == 2)
                                    {
                                        this.divOrderItem2.Style["display"] = "block";
                                    }
                                    if (rowz == 3)
                                    {
                                        this.divOrderItem3.Style["display"] = "block";
                                    }
                                    if (rowz == 4)
                                    {
                                        this.divOrderItem4.Style["display"] = "block";
                                    }
                                    if (rowz == 5)
                                    {
                                        this.divOrderItem5.Style["display"] = "block";
                                    }
                                    if (rowz == 6)
                                    {
                                        this.divOrderItem6.Style["display"] = "block";
                                    }
                                    if (rowz == 7)
                                    {
                                        this.divOrderItem7.Style["display"] = "block";
                                    }
                                    if (rowz == 8)
                                    {
                                        this.divOrderItem8.Style["display"] = "block";
                                    }
                                    if (rowz == 9)
                                    {
                                        this.divOrderItem9.Style["display"] = "block";
                                    }
                                    if (rowz == 10)
                                    {
                                        this.divOrderItem10.Style["display"] = "block";
                                    }
                                    if (rowz == 11)
                                    {
                                        this.divOrderItem11.Style["display"] = "block";
                                    }
                                    if (rowz == 12)
                                    {
                                        this.divOrderItem12.Style["display"] = "block";
                                    }
                                    if (rowz == 13)
                                    {
                                        this.divOrderItem13.Style["display"] = "block";
                                    }
                                    if (rowz == 14)
                                    {
                                        this.divOrderItem14.Style["display"] = "block";
                                    }
                                    if (rowz == 15)
                                    {
                                        this.divOrderItem15.Style["display"] = "block";
                                    }
                                    if (rowz == 16)
                                    {
                                        this.divOrderItem16.Style["display"] = "block";
                                    }
                                    if (rowz == 17)
                                    {
                                        this.divOrderItem17.Style["display"] = "block";
                                    }
                                    if (rowz == 18)
                                    {
                                        this.divOrderItem18.Style["display"] = "block";
                                    }
                                    if (rowz == 19)
                                    {
                                        this.divOrderItem19.Style["display"] = "block";
                                    }
                                    // fill in associated data for print area
                                    lbl = (Label)this.FindControl("lblMainTagHeader" + rowz.ToString());
                                    if (lbl != null)
                                    {
                                        lbl.Text = dr["CustName"].ToString();
                                    }
                                    lbl = (Label)this.FindControl("lblTagHdrAddress" + rowz.ToString());
                                    if (lbl != null)
                                    {
                                        lbl.Text = dr["CustAddress"].ToString();
                                    }
                                    lbl = (Label)this.FindControl("lblTagHdrCityStZip" + rowz.ToString());
                                    if (lbl != null)
                                    {
                                        lbl.Text = dr["CustCity"].ToString() + " " + dr["StProv"].ToString() + " " + dr["Zip"].ToString();
                                    }
                                    lbl = (Label)this.FindControl("lblTagHdrCountry" + rowz.ToString());
                                    if (lbl != null)
                                    {
                                        lbl.Text = dr["Country"].ToString();
                                    }
                                    lbl = (Label)this.FindControl("lblOrderNbr" + rowz.ToString());
                                    if (lbl != null)
                                    {
                                        lbl.Text = _OrdNbr.ToString();
                                    }
                                    lbl = (Label)this.FindControl("lblShipDate" + rowz.ToString());
                                    if (lbl != null)
                                    {
                                        lbl.Text = dr["sShipDate"].ToString();
                                    }

                                    lbl     = (Label)this.FindControl("lblItemNbr" + rowz.ToString());
                                    ItemNbr = dr["WurthCode"].ToString().ToUpper();
                                    if (lbl != null)
                                    {
                                        lbl.Text = ItemNbr;
                                    }
                                    lbl = (Label)this.FindControl("lblItemNbrBarCode" + rowz.ToString());
                                    if (lbl != null)
                                    {
                                        lbl.Text = ItemNbr;
                                    }

                                    lbl = (Label)this.FindControl("lblPONbrBarCode" + rowz.ToString());
                                    if (lbl != null)
                                    {
                                        lbl.Text = dr["CustPO"].ToString();
                                    }
                                    lbl = (Label)this.FindControl("lblFootageBarCode" + rowz.ToString());
                                    Fig = Convert.ToDouble(dr["WWGVol"]) * 1000;
                                    if (lbl != null)
                                    {
                                        lbl.Text = Fig.ToString();
                                    }
                                    lbl = (Label)this.FindControl("lblLengthBarCode" + rowz.ToString());
                                    if (lbl != null)
                                    {
                                        lbl.Text = dr["iProdLen"].ToString();
                                    }
                                    lbl = (Label)this.FindControl("lblPackage" + rowz.ToString());
                                    s   = dt.Rows[0]["ProdWidth"].ToString();
                                    if (s == null)
                                    {
                                        s = "";
                                    }
                                    s2 = dt.Rows[0]["iProdLen"].ToString();
                                    if (s2 == null)
                                    {
                                        s2 = "";
                                    }
                                    s3 = dt.Rows[0]["PkgHeight"].ToString();
                                    if (s3 == "")
                                    {
                                        s3 = "0";
                                    }
                                    if (lbl != null)
                                    {
                                        lbl.Text = s3 + "x" + s + "x" + s2;
                                    }
                                    lbl = (Label)this.FindControl("lblUnitNbrValue" + rowz.ToString());
                                    if (lbl != null)
                                    {
                                        lbl.Text = dr["WurthCode"].ToString();
                                    }
                                    lbl = (Label)this.FindControl("lblUnitNbrValue" + rowz.ToString());
                                    if (lbl != null)
                                    {
                                        lbl.Text = dr["TagNbr"].ToString();
                                    }
                                }
                                else
                                {
                                    if (rowz == 1)
                                    {
                                        this.divOrderItem1.Style["display"] = "none";
                                    }
                                    if (rowz == 2)
                                    {
                                        this.divOrderItem2.Style["display"] = "none";
                                    }
                                    if (rowz == 3)
                                    {
                                        this.divOrderItem3.Style["display"] = "none";
                                    }
                                    if (rowz == 4)
                                    {
                                        this.divOrderItem4.Style["display"] = "none";
                                    }
                                    if (rowz == 5)
                                    {
                                        this.divOrderItem5.Style["display"] = "none";
                                    }
                                    if (rowz == 6)
                                    {
                                        this.divOrderItem6.Style["display"] = "none";
                                    }
                                    if (rowz == 7)
                                    {
                                        this.divOrderItem7.Style["display"] = "none";
                                    }
                                    if (rowz == 8)
                                    {
                                        this.divOrderItem8.Style["display"] = "none";
                                    }
                                    if (rowz == 9)
                                    {
                                        this.divOrderItem9.Style["display"] = "none";
                                    }
                                    if (rowz == 10)
                                    {
                                        this.divOrderItem10.Style["display"] = "none";
                                    }
                                    if (rowz == 11)
                                    {
                                        this.divOrderItem11.Style["display"] = "none";
                                    }
                                    if (rowz == 12)
                                    {
                                        this.divOrderItem12.Style["display"] = "none";
                                    }
                                    if (rowz == 13)
                                    {
                                        this.divOrderItem13.Style["display"] = "none";
                                    }
                                    if (rowz == 14)
                                    {
                                        this.divOrderItem14.Style["display"] = "none";
                                    }
                                    if (rowz == 15)
                                    {
                                        this.divOrderItem15.Style["display"] = "none";
                                    }
                                    if (rowz == 16)
                                    {
                                        this.divOrderItem16.Style["display"] = "none";
                                    }
                                    if (rowz == 17)
                                    {
                                        this.divOrderItem17.Style["display"] = "none";
                                    }
                                    if (rowz == 18)
                                    {
                                        this.divOrderItem18.Style["display"] = "none";
                                    }
                                    if (rowz == 19)
                                    {
                                        this.divOrderItem19.Style["display"] = "none";
                                    }
                                }
                            }                     //or (int rowz = 0; rowz < 20; rowz++)
                        }                         //NbrItems > 0
                        else
                        {
                            divErrorMsg.Style["display"] = "block";
                            lblErrorMsg.Text             = "No items were found for that order number.";
                        }
                    }
                    else
                    {
                        divErrorMsg.Style["display"] = "block";
                        lblErrorMsg.Text             = "Invalid order number.";
                    }
                }
                catch (Exception ex)
                {
                    this._ErrMsg          = "Could not generate Wurth-Style tags. Initial data Load encountered an error: " + ex.Message;
                    this.lblErrorMsg.Text = this._ErrMsg;
                }
            }
            string jsScript = "<script type=\"text/javascript\">var jgNItems=" + NbrItems.ToString() + ";</script>";

            //window.print(); window.onfocus = function() { window.close();
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PrintThisForm", jsScript);
        }