Esempio n. 1
0
            public void Save(Shortage oShortage)
            {
                if (oShortage.ID != String.Empty)
                {
                    String Sql = String.Format("Delete From ShortageDetail Where ShortageID = '{0}'",
                                               oShortage.ID);
                    oMySql.exec_sql(Sql);

                    Detail.AcceptChanges();
                    foreach (DataRow drow in Detail.Rows)
                    {
                        int Qty = 0;
                        if (drow["Quantity"] == DBNull.Value)
                        {
                            Qty = 0;
                        }
                        else
                        {
                            Qty = Convert.ToInt16(drow["Quantity"].ToString());
                        }

                        if (Qty > 0)
                        {
                            oMySql.exec_sql(String.Format("Insert Into ShortageDetail (ShortageID,CompanyID, ProductID, Quantity) Values ('{0}','{1}','{2}','{3}')",
                                                          oShortage.ID, oShortage.CompanyID, drow["ProductID"].ToString(), drow["Quantity"].ToString()));
                        }
                    }
                }
            }
Esempio n. 2
0
            public void Load(Shortage oShortage)
            {
                Detail = oMySql.GetDataTable(String.Format("SELECT p.ProductID,p.Description,s.Quantity FROM ShortageDetail s Left Join Product p On s.CompanyID=p.CompanyID And s.ProductID=p.ProductID Where ShortageID='" + oShortage.ID + "'"), "ShortageDetail");
                DataColumn colWork = new DataColumn("SubTotal", System.Type.GetType("System.Double"));

                Detail.Columns.Add(colWork);
            }
Esempio n. 3
0
        } //Constructor

        public Shortage(Shortage oShortage)
        {
            this.ID = oShortage.ID;

            this.CompanyID   = oShortage.CompanyID;
            this.CustomerID  = oShortage.CustomerID;
            this.OrderID     = oShortage.OrderID;
            this.SchoolName  = oShortage.SchoolName;
            this.ParentName  = oShortage.ParentName;
            this.TeacherName = oShortage.Name;
            this.Name        = oShortage.Name;
            this.Date        = oShortage.Date;
            this.Detail      = oShortage.Detail;
            this.DayPhone    = oShortage.DayPhone;
            this.EvePhone    = oShortage.EvePhone;
            this.QVNOption   = oShortage.QVNOption;
            this.Address     = oShortage.Address;
            this.Address_2   = oShortage.Address_2;
            this.Attention   = oShortage.Attention;
            this.City        = oShortage.City;
            this.State       = oShortage.State;
            this.ZipCode     = oShortage.ZipCode;
            this.eMail       = oShortage.ZipCode;
            this.Type        = oShortage.Type;
            this.StudentName = oShortage.StudentName;
            //  this.oCustomer=oShortage.oCustomer;
            this.Items = new _Items(oShortage.Items);
            //this.TrakingNumber = oShortage.TrakingNumber;
        }
Esempio n. 4
0
        public void Save(Shortage oCurrentShortage)
        {
            Inventory oInventory = new Inventory(CompanyID);

            oInventory.Update(this, Inventory.InventoryType.RollBack);
            if (IfExist())
            {
                Update();
            }
            else
            {
                Insert();
            }
            Items.Save(this);
            oInventory.Update(this, Inventory.InventoryType.Commit);
        }
 public void Update(Shortage oShortage, InventoryType Type)
 {
     if (oShortage != null)
     {
         #region Commit
         if (Type == InventoryType.Commit)
         {
             //MessageBox.Show("Commiting...");
             foreach (DataRow drow in oShortage.Items.Detail.Rows)
             {
                 if (base.Find(drow["ProductID"].ToString()))
                 {
                     //MessageBox.Show(drow["Quantity"].ToString());
                     this.Sold += Convert.ToInt32(drow["Quantity"].ToString());
                     this.UpdateInventory();
                 }
             }
         }
         #endregion
         #region Rollback
         if (Type == InventoryType.RollBack)
         {
             if (oShortage != null)
             {
                 if (oShortage.currentDetail != null)
                 {
                     foreach (DataRow drow in oShortage.currentDetail.Rows)
                     {
                         if (base.Find(drow["ProductID"].ToString()))
                         {
                             //MessageBox.Show(drow["Quantity"].ToString());
                             this.Sold -= (Int32)drow["Quantity"];
                             this.UpdateInventory();
                         }
                     }
                 }
             }
         }
         #endregion
     }
 }
Esempio n. 6
0
 public DataTable GetDataTable(Shortage oShortage)
 {
     Detail.Clear();
     Detail = oMySql.GetDataTable("SELECT ks.KitID, k.Name,  Quantity FROM ga_kitbyschool ks Left Join ga_kit k on ks.KitID=k.ID And ks.CompanyID=k.CompanyID  Where CustomerID='" + oShortage.ID + "'", "Kits");
     return(Detail);
 }
        public void ImportOrders()
        {
            DataSet dsTables = new DataSet();

            dsTables.Tables.Add(this.oMySql.GetDataTable("Select * from ga_order Where Status='0'", "Order"));
            //   dsTables.Tables.Add(this.oMySql.GetDataTable("Select * from ga_order Where Status='0'","OrderDetail"));


            Customer         oCustomer = new Customer(this.CompanyID);
            GA_OrderInternet oOrder    = new GA_OrderInternet(this.CompanyID);


            String strBody = "";

            if (dsTables.Tables["Order"].Rows.Count > 0)
            {
                oOrder.OpenPrinter(1);
            }


            foreach (DataRow row in dsTables.Tables["Order"].Rows)
            {
                if (!oOrder.Exist((Int32)row["OrderID"], ShoppingType.GA))
                {
                    oOrder.Clear();
                    oOrder.IOrderID = (Int32)row["OrderID"];
                    oOrder.UpdateStatus(GA_InternetOrderStatus.Processing);

                    oOrder.CustomerID = row["CustomerID"].ToString();
                    oOrder.Teacher    = "RE-ORDER";
                    oOrder.Student    = "RE-ORDER " + ((DateTime)row["Date"]).Month.ToString() + "/" + ((DateTime)row["Date"]).Day.ToString();

                    if (oOrder.Exist(oOrder.Teacher, oOrder.Student))
                    {
                        oOrder.Student += "(" + row["OrderID"].ToString() + ")";
                    }


                    oOrder.oCustomer.Find(oOrder.CustomerID);
                    oOrder.oCustomer.Brochures.Load(this.CompanyID, oOrder.CustomerID);


                    oOrder.Type    = OrderType.GA_Internet;
                    oOrder.Process = OrderProcess.Internet;


                    oOrder.Items.Clear();

                    //    Console.Out.WriteLine(oOrder.Student);

                    DataTable dsDetail = oMySql.GetDataTable(String.Format("Select * from ga_order_detail Where OrderID='{0}'", row["OrderID"].ToString()), "Detail");

                    foreach (DataRow detailRow in dsDetail.Rows)
                    {
                        String ProductID = detailRow["ProductID"].ToString();

                        if (oOrder.oProduct.Find(ProductID))
                        {
                            Order.Item Item = new Order.Item();
                            Item.ProductID   = oOrder.oProduct.ID;
                            Item.Quantity    = (Int32)detailRow["Quantity"];
                            Item.Description = oOrder.oProduct.Description;
                            Item.Price       = oOrder.oProduct.ExtendedPrice(oOrder.oCustomer);
                            Item.PackID      = oOrder.oProduct.PackID(oOrder.oCustomer);

                            if (oOrder.Items.Contains(oOrder.oProduct.ID))
                            {
                                oOrder.Items[oOrder.oProduct.ID].Quantity += Item.Quantity;
                            }
                            else
                            {
                                oOrder.Items.Add(oOrder.oProduct.ID, Item);
                            }
                        }
                        else
                        {
                            this.SendErrorEmail("Item Error  " + oOrder.IOrderID.ToString() + " " + oOrder.Teacher + " " + oOrder.Student);
                        }
                    }
                    oOrder.GetTotals();
                    oOrder.Collected = 0.00; // oOrder.Retail;
                    oOrder.Save(OrderType.GA_Internet);

                    //Printing Packing Slips
                    if (oOrder.Find(Convert.ToInt32(oOrder.ID)))
                    {
                        oOrder.UpdateOrderID((Int32)row["OrderID"]);


                        //Create Shortage
                        Shortage oShortage = new Shortage(this.CompanyID);
                        //oShortage.oOrder = oOrder;
                        oShortage.OrderID     = oOrder.ID;
                        oShortage.oCustomer   = oOrder.oCustomer;
                        oShortage.CustomerID  = oOrder.CustomerID;
                        oShortage.SchoolName  = oOrder.oCustomer.Name;
                        oShortage.DayPhone    = oOrder.oCustomer.PhoneNumber;
                        oShortage.TeacherName = oOrder.Teacher;
                        oShortage.StudentName = oOrder.Student;
                        oShortage.Address     = oOrder.oCustomer.Address;
                        oShortage.City        = oOrder.oCustomer.City;
                        oShortage.ZipCode     = oOrder.oCustomer.ZipCode;
                        oShortage.State       = oOrder.oCustomer.State;
                        oShortage.Type        = "I";
                        oShortage.Detail      = oOrder.NoItems.ToString() + " Item(s)" + "\n\r" + "\n\r";
                        oShortage.Detail     += "OrderID      : " + oOrder.ID.ToString() + "\n\r";
                        oShortage.Detail     += "Processed On : " + (row["Date"] == null ? "" : ((DateTime)row["Date"]).ToString()) + "\n\r";
                        oShortage.eMail       = row["eMail"].ToString();
                        oShortage.Save();
                        // oShortage.Print(false);

                        oOrder.ShortageID = Convert.ToInt32(oShortage.ID);
                        oOrder.Print();
                    }
                    else
                    {
                        this.SendErrorEmail(oOrder.IOrderID.ToString() + " " + oOrder.Teacher + " " + oOrder.Student + oOrder.LastError);
                    }

                    strBody += oOrder.ID.ToString() + " " + oOrder.Teacher.PadRight(30) + " " + oOrder.Student.PadRight(30).Substring(0, 30) + " " + oOrder.NoItems.ToString().PadRight(3).Substring(0, 3) + " " + oOrder.oCustomer.City + " " + oOrder.oCustomer.State + "\n\r";
                    Console.Out.WriteLine(DateTime.Now.ToString() + " " + oOrder.ID.ToString() + " " + oOrder.oCustomer.ID + " " + oOrder.oCustomer.Name);
                }


                if (!oOrder.UpdateStatus(GA_InternetOrderStatus.Processed))
                {
                    this.SendErrorEmail(oOrder.IOrderID.ToString() + " " + oOrder.Teacher + " " + oOrder.Student + oOrder.LastError);
                    return;
                }
            }

            if (dsTables.Tables["Order"].Rows.Count > 0)
            {
                oOrder.ClosePrinter();
            }

            /*    //Sending Email
             *      Smtp oSmtp = new Smtp();
             *      oSmtp.Subject = "Emails processed " + DateTime.Now.ToShortDateString() + "   " + DateTime.Now.ToShortTimeString();
             *      if (this.CustomerID == "TEST")
             *          oSmtp.To = "\"Alvaro Medina\" <*****@*****.**>";
             *      else
             *          oSmtp.To = "\"Daisy Caro\" <*****@*****.**>";
             *      oSmtp.From = "\"Signature Server\" <*****@*****.**>";
             *
             *      String  strTitle =  "Order ID             Teacher           Student         Items   City  State Ship/Del Packed\n\r";
             *              strTitle += "------------------------------------------------------------------------------------------\n\r";
             *      oSmtp.Body = strTitle + strBody;
             *      oSmtp.Send();
             * }
             */
            dsTables.Dispose();
        }
        public void ImportOrders(String Database, ShoppingType ShoppingCart, String CompanyID, String CustomerID)
        {
            this.CompanyID  = CompanyID;
            this.CustomerID = CustomerID;


            Customer oCustomer = new Customer(this.CompanyID);

            /*
             * if (!oMySql.ChangeDatabase("69.89.31.153", "signatv9_sa", "sa", "signatv9_SigWeb"))
             * {
             *  MessageBox.Show("We cannot open this database");
             *  return;
             * }
             */
            oMySql.ChangeDatabase(Database);

            //DataTable dtOrders = oRemoteMysql.GetDataTable("SELECT * FROM cart_orders Where Status='"+(int)InternetOrderStatus.Pending+"' And open='n'","Order");
            DataSet dsTables = oMySql.GetDataset("CALL get_tables();");

            //MessageBox.Show(dsTables.Tables["Table6"].Rows.Count.ToString());
            Console.WriteLine(ShoppingCart.ToString() + " " + dsTables.Tables["Table6"].Rows.Count.ToString() + " order(s)");

            //return;
            //192.168.254.65

            /*
             * if (!oMySql.ChangeDatabase(this.Local, "SigData", "SigData009", "SigData"))
             * {
             *  return;
             * }*/

            oMySql.ChangeDatabase("SigData");

            dsTables.Tables["table"].TableName  = "Customer";
            dsTables.Tables["table1"].TableName = "Student";
            dsTables.Tables["table2"].TableName = "CreditCard";
            dsTables.Tables["table3"].TableName = "Shipment";
            dsTables.Tables["table4"].TableName = "Detail";
            dsTables.Tables["table5"].TableName = "Product";
            dsTables.Tables["table6"].TableName = "Order";
            dsTables.Tables["table7"].TableName = "CustomCard";
            //dsTables.Tables.Add(dtOrders);


            DataRelation custOrderRel = dsTables.Relations.Add("OrdersCust",
                                                               dsTables.Tables["Order"].Columns["customer"],
                                                               dsTables.Tables["Customer"].Columns["id"], false);

            DataRelation studentOrderRel = dsTables.Relations.Add("OrdersStudent",
                                                                  dsTables.Tables["Order"].Columns["id"],
                                                                  dsTables.Tables["Student"].Columns["order_id"]);

            DataRelation detailOrderRel = dsTables.Relations.Add("OrdersDetail",
                                                                 dsTables.Tables["Order"].Columns["id"],
                                                                 dsTables.Tables["Detail"].Columns["order_id"]);

            DataRelation creditcardOrderRel = dsTables.Relations.Add("OrdersCreditcard",
                                                                     dsTables.Tables["Order"].Columns["id"],
                                                                     dsTables.Tables["CreditCard"].Columns["order_id"]);

            DataRelation shipOrderRel = dsTables.Relations.Add("OrdersShip",
                                                               dsTables.Tables["Order"].Columns["id"],
                                                               dsTables.Tables["Shipment"].Columns["order_id"]);

            DataRelation productDetailRel = dsTables.Relations.Add("DetailProduct",
                                                                   dsTables.Tables["Detail"].Columns["product_id"],
                                                                   dsTables.Tables["Product"].Columns["ProductID"], false);


            DataRelation productCustomCard = dsTables.Relations.Add("Custom_Card",
                                                                    dsTables.Tables["Detail"].Columns["id"],
                                                                    dsTables.Tables["CustomCard"].Columns["ticket_id"], false);



            //MySQL.conn = null;
            OrderInternet oOrder = new OrderInternet(this.CompanyID);

            //int i = 0;

            String strBody       = "";
            String strBodyPrizes = "";

            if (dsTables.Tables["Order"].Rows.Count > 0)
            {
                oOrder.OpenPrinter(3);
            }



            foreach (DataRow row in dsTables.Tables["Order"].Rows)
            {
                oOrder.CustomerID = CustomerID;
                String StudentName = "";
                String TeacherName = "";
                String Customized  = "";



                if (row.GetChildRows(studentOrderRel).Length > 0)
                {
                    TeacherName = row.GetChildRows(studentOrderRel)[0]["school_name"].ToString().ToUpper().Replace("\"", " ").Replace("'", " ");
                }

                if (TeacherName.Trim().Length == 0)
                {
                    TeacherName = "GENERAL CUSTOMER";
                    StudentName = ((row.GetChildRows(shipOrderRel)[0]["FirstName"].ToString().Length > 0 ? (row.GetChildRows(shipOrderRel)[0]["FirstName"].ToString().Substring(0, 1)) : "?") + "." + row.GetChildRows(shipOrderRel)[0]["LastName"].ToString()).ToUpper().Replace("\"", " ").Replace("'", " ");
                }
                else
                {
                    String Initial = "";
                    if (row.GetChildRows(shipOrderRel)[0]["FirstName"].ToString() != "")
                    {
                        Initial = row.GetChildRows(shipOrderRel)[0]["FirstName"].ToString().Substring(0, 1);
                    }

                    StudentName = (Initial + "." + row.GetChildRows(shipOrderRel)[0]["LastName"].ToString() + "-" +
                                   row.GetChildRows(studentOrderRel)[0]["student_name"].ToString()).ToUpper().Replace("\"", " ").Replace("'", " ");


                    String Result = oCustomer.GetSchool(TeacherName, row.GetChildRows(studentOrderRel)[0]["school_city"].ToString());

                    if (oCustomer.Find(Result))
                    {
                        TeacherName = oCustomer.Name.PadRight(30).Substring(0, 24) + " " + oCustomer.ID.Trim();
                    }
                    else
                    {
                        TeacherName = TeacherName.PadRight(30).Substring(0, 24) + " " + "00000";
                    }

                    //    Console.Out.WriteLine(TeacherName + " " + Global.getState(row.GetChildRows(studentOrderRel)[0]["school_city"].ToString().ToUpper() ));
                }
                Console.Out.WriteLine(DateTime.Now.ToString() + "-" + TeacherName);
                //  continue;


                if (!oOrder.Exist((Int32)row["id"], ShoppingCart))
                {
                    if (oOrder.Exist((ShoppingCart == ShoppingType.WLOT)? ShoppingType.WLOT.ToString():TeacherName, StudentName))
                    {
                        if (StudentName.Length >= 33)
                        {
                            StudentName = StudentName.Substring(0, 33);
                        }
                        StudentName += "-" + row["id"].ToString();
                    }

                    oOrder.Clear();

                    oOrder.CustomerID = CustomerID;
                    oOrder.oCustomer.Find(oOrder.CustomerID);
                    oOrder.oCustomer.Brochures.Load(this.CompanyID, oOrder.CustomerID);


                    oOrder.Type    = OrderType.Internet;
                    oOrder.Process = OrderProcess.Internet;

                    oOrder.IOrderID = (Int32)row["id"];
                    oOrder.Teacher  = (ShoppingCart == ShoppingType.WLOT)? ShoppingType.WLOT.ToString():TeacherName;
                    oOrder.Student  = StudentName.Replace("\"", " ").Replace("'", " ");;



                    oOrder.Items.Clear();

                    //    Console.Out.WriteLine(oOrder.Student);

                    foreach (DataRow detailRow in row.GetChildRows(detailOrderRel))
                    {
                        // Console.Out.WriteLine("Product ID: " + detailRow["product_id"]);
                        // Console.Out.WriteLine("Quantity: " + detailRow["quantity"]);

                        //Console.Out.WriteLine("Description: " + oOrder.oProduct.Description);

                        String ProductID = detailRow["product_id"].ToString();

                        if (IsMagazine(ProductID))
                        {
                            if (detailRow.GetChildRows(productDetailRel).Length == 0)
                            {
                                this.SendErrorEmail(ShoppingCart.ToString() + " Item Error  " + oOrder.IOrderID.ToString() + " " + oOrder.Teacher + " " + oOrder.Student + " Item:" + ProductID);
                                continue;
                            }
                            else
                            {
                                ProductID = GetMagazineCode(ProductID, (Double)detailRow.GetChildRows(productDetailRel)[0]["Price"]);
                            }
                        }



                        if (oOrder.oProduct.Find(ProductID))
                        {
                            // Console.Out.WriteLine("Price: " + oOrder.oProduct.Price.ToString());

                            Order.Item Item = new Order.Item();
                            Item.ProductID   = oOrder.oProduct.ID;
                            Item.Quantity    = (Int32)detailRow["quantity"];
                            Item.Description = oOrder.oProduct.Description;
                            Item.Price       = oOrder.oProduct.ExtendedPrice(oOrder.oCustomer);
                            Item.PackID      = oOrder.oProduct.PackID(oOrder.oCustomer);

                            // Custom Card
                            foreach (DataRow DetailRow in detailRow.GetChildRows(productCustomCard))
                            {
                                Customized = "(Customized)";

                                //   if (Item.ProductID != DetailRow["product_id"].ToString())
                                //       continue;

                                Ticket oTicket = new Ticket(oOrder.CompanyID);
                                oTicket.OrderID   = Convert.ToInt32(oOrder.ID);
                                oTicket.Quantity  = (Int32)detailRow["quantity"]; //1; Modified on 10/06/2001
                                oTicket.ProductID = DetailRow["product_id"].ToString();

                                //Line 1
                                Ticket.Line oLine = new Ticket.Line();
                                oLine.Text = (DetailRow["Line_1"].ToString().Length > 40 ? DetailRow["Line_1"].ToString().Substring(0, 39) : DetailRow["Line_1"].ToString()).ToUpper();
                                oLine.Type = Ticket.ImprintType.Card;
                                oTicket.Lines.Add("Line_1", oLine);

                                oLine      = new Ticket.Line();
                                oLine.Text = (DetailRow["Line_2"].ToString().Length > 40 ? DetailRow["Line_2"].ToString().Substring(0, 39) : DetailRow["Line_2"].ToString()).ToUpper();
                                oLine.Type = Ticket.ImprintType.Card;
                                oTicket.Lines.Add("Line_2", oLine);

                                oLine      = new Ticket.Line();
                                oLine.Text = (DetailRow["Line_3"].ToString().Length > 40 ? DetailRow["Line_3"].ToString().Substring(0, 39) : DetailRow["Line_3"].ToString()).ToUpper();
                                oLine.Type = Ticket.ImprintType.Card;
                                oTicket.Lines.Add("Line_3", oLine);

                                oLine      = new Ticket.Line();
                                oLine.Text = (DetailRow["Line_4"].ToString().Length > 40 ? DetailRow["Line_4"].ToString().Substring(0, 39) : DetailRow["Line_4"].ToString()).ToUpper();
                                oLine.Type = Ticket.ImprintType.Card;
                                oTicket.Lines.Add("Line_4", oLine);

                                oLine      = new Ticket.Line();
                                oLine.Text = (DetailRow["Line_5"].ToString().Length > 40 ? DetailRow["Line_5"].ToString().Substring(0, 39) : DetailRow["Line_5"].ToString()).ToUpper();
                                oLine.Type = Ticket.ImprintType.Card;
                                oTicket.Lines.Add("Line_5", oLine);

                                // Console.Out.WriteLine("Quantity: " + detailRow["quantity"]);
                                //oTicket.Save();
                                Item.Tickets.Add(Item.ProductID, oTicket);
                            }



                            if (oOrder.Items.Contains(oOrder.oProduct.ID))
                            {
                                oOrder.Items[oOrder.oProduct.ID].Quantity += Item.Quantity;
                            }
                            else
                            {
                                oOrder.Items.Add(oOrder.oProduct.ID, Item);
                            }
                        }
                        else
                        {
                            this.SendErrorEmail(ShoppingCart.ToString() + " Item Error  " + oOrder.IOrderID.ToString() + " " + oOrder.Teacher + " " + oOrder.Student + " Item:" + ProductID);
                        }
                    }
                    oOrder.GetTotals();
                    oOrder.Collected = oOrder.Retail;
                    oOrder.Save(OrderType.Internet);

                    /*
                     * //Custom Cards Detail
                     * if (row.GetChildRows(productCustomCard).Length > 0)
                     * {
                     *  if (oOrder.Find(Convert.ToInt32(oOrder.ID)))
                     *  {
                     *      foreach (DataRow detailRow in row.GetChildRows(productCustomCard))
                     *      {
                     *
                     *          Ticket oTicket = new Ticket(oOrder.CompanyID);
                     *          oTicket.OrderID = Convert.ToInt32(oOrder.ID);
                     *          oTicket.Quantity = 1;
                     *          oTicket.ProductID = detailRow["product_id"].ToString();
                     *
                     *          //Line 1
                     *          Ticket.Line oLine = new Ticket.Line();
                     *          oLine.Text = detailRow["Line_1"].ToString().Length > 40? detailRow["Line_1"].ToString().Substring(0,39):detailRow["Line_1"].ToString() ;
                     *          oLine.Type = Ticket.ImprintType.Card;
                     *          oTicket.Lines.Add("Line_1,",oLine);
                     *
                     *          oLine = new Ticket.Line();
                     *          oLine.Text = detailRow["Line_2"].ToString().Length > 40 ? detailRow["Line_2"].ToString().Substring(0, 39) : detailRow["Line_2"].ToString();
                     *          oLine.Type = Ticket.ImprintType.Card;
                     *          oTicket.Lines.Add("Line_2,", oLine);
                     *
                     *          oLine = new Ticket.Line();
                     *          oLine.Text = detailRow["Line_3"].ToString().Length > 40 ? detailRow["Line_3"].ToString().Substring(0, 39) : detailRow["Line_3"].ToString();
                     *          oLine.Type = Ticket.ImprintType.Card;
                     *          oTicket.Lines.Add("Line_3,", oLine);
                     *
                     *          // Console.Out.WriteLine("Quantity: " + detailRow["quantity"]);
                     *          oTicket.Save();
                     *
                     *
                     *      }
                     *  }
                     * }
                     */

                    //Printing Packing Slips
                    if (oOrder.Find(Convert.ToInt32(oOrder.ID)))
                    {
                        oOrder.UpdateOrderID((Int32)row["id"], ShoppingCart);


                        //Create Shortage
                        Shortage oShortage = new Shortage(this.CompanyID);
                        //oShortage.oOrder = oOrder;
                        oShortage.OrderID     = oOrder.ID;
                        oShortage.oCustomer   = oOrder.oCustomer;
                        oShortage.CustomerID  = oOrder.CustomerID;
                        oShortage.SchoolName  = (row.GetChildRows(shipOrderRel)[0]["FirstName"].ToString() + " " + row.GetChildRows(shipOrderRel)[0]["LastName"].ToString()).ToUpper();
                        oShortage.DayPhone    = row.GetChildRows(shipOrderRel)[0]["phone"].ToString().Replace("(", "").Replace(")", "").Replace("-", "").Replace(" ", "");
                        oShortage.TeacherName = oOrder.Teacher;
                        oShortage.StudentName = oOrder.Student;
                        oShortage.Address     = row.GetChildRows(shipOrderRel)[0]["address"].ToString() + " " + row.GetChildRows(shipOrderRel)[0]["address2"].ToString();
                        oShortage.City        = row.GetChildRows(shipOrderRel)[0]["City"].ToString();
                        oShortage.ZipCode     = row.GetChildRows(shipOrderRel)[0]["ZipCode"].ToString();
                        oShortage.State       = row.GetChildRows(shipOrderRel)[0]["State"].ToString();
                        oShortage.Type        = "I";
                        oShortage.Detail      = oOrder.NoItems.ToString() + " Item(s)" + "\n\r" + "\n\r";
                        oShortage.Detail     += "OrderID      : " + oOrder.ID.ToString() + "\n\r";
                        oShortage.Detail     += "Processed On : " + (row["processed_on"] == null? "": ((DateTime)row["processed_on"]).ToString()) + "\n\r";
                        oShortage.eMail       = row.GetChildRows(custOrderRel).Length > 0?row.GetChildRows(custOrderRel)[0]["email"].ToString():"";
                        oShortage.Save();
                        // oShortage.Print(false);

                        oOrder.ShortageID = Convert.ToInt32(oShortage.ID);
                        oOrder.Print();
                    }
                    else
                    {
                        this.SendErrorEmail(oOrder.IOrderID.ToString() + " " + oOrder.Teacher + " " + oOrder.Student + oOrder.LastError);
                    }



                    if (TeacherName != "GENERAL CUSTOMER")
                    {
                        String DeliveryDate = "  /  "; // : oCustomer.DeliveryDate.ToString("dd/MM/yyyy");
                        String Packed       = "   ";

                        if (oCustomer.ID != "")
                        {
                            if (oCustomer.ShipDate != Global.DNull)
                            {
                                DeliveryDate = oCustomer.ShipDate.ToString("MM/dd");
                            }
                            else
                            {
                                DeliveryDate = oCustomer.DeliveryDate.ToString("MM/dd");
                            }
                            Packed = oCustomer.NumberPallets > 0?"YES":"NO ";
                        }

                        //String Packed = oCustomer.ID == ""? "   ":(oCustomer.ShipDate!=null?)
                        if (oOrder.ID == "0")
                        {
                            strBody += "[" + oOrder.IOrderID.ToString().PadLeft(5) + "]" + oOrder.Teacher + " " + oOrder.Student.PadRight(30).Substring(0, 30) + " " + oOrder.NoItems.ToString().PadRight(3).Substring(0, 3) + " " + row.GetChildRows(studentOrderRel)[0]["school_city"].ToString().ToUpper() + "  " + Global.getState(row.GetChildRows(studentOrderRel)[0]["school_state"].ToString().ToUpper()) + " " + DeliveryDate + " " + Packed + Customized + "\n\r";
                        }
                        else
                        {
                            strBody += oOrder.ID.ToString().PadLeft(5) + " " + oOrder.Teacher + " " + oOrder.Student.PadRight(30).Substring(0, 30) + " " + oOrder.NoItems.ToString().PadRight(3).Substring(0, 3) + " " + row.GetChildRows(studentOrderRel)[0]["school_city"].ToString().ToUpper() + "  " + Global.getState(row.GetChildRows(studentOrderRel)[0]["school_state"].ToString().ToUpper()) + " " + DeliveryDate + " " + Packed + Customized + "\n\r";
                        }

                        if (ShoppingCart == ShoppingType.SigFund)
                        {
                            strBodyPrizes += row.GetChildRows(custOrderRel)[0]["FirstName"].ToString().ToUpper() + " " +
                                             row.GetChildRows(custOrderRel)[0]["LastName"].ToString().ToUpper() + " " +
                                             oOrder.Teacher.PadRight(30) + " " +
                                             row.GetChildRows(custOrderRel)[0]["City"].ToString().ToUpper() + " " +
                                             Global.getState(row.GetChildRows(custOrderRel)[0]["State"].ToString().ToUpper()) + " " +
                                             (row.GetChildRows(studentOrderRel)[0]["student_name"].ToString()).ToUpper().Replace("\"", " ").Replace("'", " ") + " " +
                                             oOrder.NoItems.ToString().PadRight(3).Substring(0, 3) +
                                             "\n\r";
                        }
                    }
                    else
                    {
                        strBody += oOrder.ID.ToString() + "[" + oOrder.IOrderID.ToString() + "]" + oOrder.Teacher.PadRight(30) + " " + oOrder.Student.PadRight(30).Substring(0, 30) + " " + oOrder.NoItems.ToString().PadRight(3).Substring(0, 3) + " " + row.GetChildRows(custOrderRel)[0]["City"].ToString().ToUpper() + " " + Global.getState(row.GetChildRows(custOrderRel)[0]["State"].ToString().ToUpper()) + Customized + "\n\r";


                        //oOrder.ID.ToString() + "[" + oOrder.IOrderID.ToString() + "]" + oOrder.Teacher.PadRight(30) + " " + oOrder.Student.PadRight(30).Substring(0, 30) + " " + oOrder.NoItems.ToString().PadRight(3).Substring(0, 3) + " " + row.GetChildRows(custOrderRel)[0]["City"].ToString().ToUpper() + " " + Global.getState(row.GetChildRows(custOrderRel)[0]["State"].ToString().ToUpper()) + Customized + "\n\r";
                    }
                }
                else
                {
                    /*
                     * Console.Out.Write(".");
                     * // strBody += "(R)" + oOrder.ID.ToString() + "  " + oOrder.Teacher + "  " + oOrder.Student + "  " + oOrder.NoItems.ToString() + "  " + row.GetChildRows(studentOrderRel)[0]["school_city"].ToString().ToUpper() + "  " + row.GetChildRows(studentOrderRel)[0]["school_state"].ToString().ToUpper() + "\n\r";
                     * if (TeacherName != "GENERAL CUSTOMER")
                     * {
                     *  strBody += "(R)" + oOrder.ID.ToString() + "  " + oOrder.Teacher + "  " + oOrder.Student + "  " + oOrder.NoItems.ToString() + "  " + row.GetChildRows(studentOrderRel)[0]["school_city"].ToString().ToUpper() + "  " + row.GetChildRows(studentOrderRel)[0]["school_state"].ToString().ToUpper() + "\n\r";
                     * }
                     * else
                     * {
                     *  strBody += "(R)" + oOrder.ID.ToString() + "  " + oOrder.Teacher + "  " + oOrder.Student + "  " + oOrder.NoItems.ToString() + "  " + row.GetChildRows(custOrderRel)[0]["City"].ToString().ToUpper() + "  " + row.GetChildRows(custOrderRel)[0]["State"].ToString().ToUpper() + "\n\r";
                     * }
                     */

                    //Print Orders When requested

                    oOrder.Print();
                }
                if (!oOrder.UpdateStatus(InternetOrderStatus.Processed, Database))
                {
                    this.SendErrorEmail(oOrder.IOrderID.ToString() + " " + oOrder.Teacher + " " + oOrder.Student + oOrder.LastError);
                    return;
                }
            }
            if (dsTables.Tables["Order"].Rows.Count > 0)
            {
                oOrder.ClosePrinter();
                //Sending Email
                Smtp oSmtp = new Smtp();

                oSmtp.Subject = "Emails processed " + DateTime.Now.ToShortDateString() + "   " + DateTime.Now.ToShortTimeString() + "  " + ShoppingCart.ToString();
                if (this.CustomerID == "TEST")
                {
                    oSmtp.To = "\"Alvaro Medina\" <*****@*****.**>";
                }
                else
                {
                    oSmtp.To = "\"Scott Elsbree\" <*****@*****.**>";
                    oSmtp.To = "\"Desiree\" <*****@*****.**>";
                    oSmtp.CC = "\"Alvaro Medina\" <*****@*****.**>";
                    if (ShoppingCart == ShoppingType.SigFund)
                    {
                        oSmtp.BCC = "\"signaturefundraising.com \" <*****@*****.**>";
                    }
                    if (ShoppingCart == ShoppingType.ChristianCollection)
                    {
                        oSmtp.BCC = "\"abundantfunds.com \" <*****@*****.**>";
                    }
                }
                oSmtp.From = "\"Signature Server\" <*****@*****.**>";

                String strTitle = "Order ID[Internet]   Teacher           Student         Items   City  State Ship/Del Packed\n\r";
                strTitle += "------------------------------------------------------------------------------------------\n\r";
                String strTotal = "------------------------------------------------------------------------------------------\n\r";
                strTotal  += "Total: " + dsTables.Tables["Order"].Rows.Count.ToString() + " Order(s)";
                oSmtp.Body = strTitle + strBody + strTotal;
                oSmtp.Send();

                //Second Prize Report
                if (strBodyPrizes != "" && ShoppingCart == ShoppingType.SigFund)
                {
                    oSmtp.Subject = "Emails processed (Items Update)" + DateTime.Now.ToShortDateString() + "   " + DateTime.Now.ToShortTimeString() + "  " + ShoppingCart.ToString();
                    oSmtp.To      = "\"Item Update \" <*****@*****.**>";
                    oSmtp.From    = "\"Signature Server\" <*****@*****.**>";
                    oSmtp.BCC     = "\"Alvaro Medina\" <*****@*****.**>";

                    strTitle   = "Online Customer   School Name   City  State StudentName Items\n\r";
                    strTitle  += "------------------------------------------------------------------------------------------\n\r";
                    strTotal   = "------------------------------------------------------------------------------------------\n\r";
                    strTotal  += "Total: " + dsTables.Tables["Order"].Rows.Count.ToString() + " Order(s)";
                    oSmtp.Body = strTitle + strBodyPrizes + strTotal;
                    oSmtp.Send();
                }
            }
            dsTables.Dispose();
        }