public override void Delete()
        {
            Global.ShowNotifier("Deleted Item : (" + ID + ") " + this.Description);
            String Sql = "Delete From Product Where ProductID='" + this.ID + "' And CompanyID='" + this.CompanyID + "'";

            oMySql.exec_sql(Sql);
            Sql = "Delete From BrochureDetail Where ProductID='" + this.ID + "' And CompanyID='" + this.CompanyID + "'";
            oMySql.exec_sql(Sql);
        }
        public Boolean GenerateFinanceCharges(Double Percent)
        {
            DateTime FromDate;
            DateTime ToDate;

            FromDate = this.DeliveryDate;
            ToDate   = DateTime.Now;

            if (this.DeliveryDate == Global.DNull)
            {
                Global.ShowNotifier("No delivery date to calculate from");
                return(false);
            }
            if (this.StatementAmountDue <= 0)
            {
                return(false);
            }

            Int32 PassedMonths = (Int32)DateAndTime.DateDiff(DateInterval.Month, FromDate, ToDate, FirstDayOfWeek.System, FirstWeekOfYear.System);


            Int32   ChargesNumber = GetFinanceChargesNumber();
            Double  Amount        = AmountDue - GetFinanceChargesAmount();
            Boolean Changed       = false;

            // MessageBox.Show(Amount.ToString());
            for (int i = 0; i < PassedMonths - ChargesNumber; i++)
            {
                Charge oCharge = new Charge(CompanyID);

                oCharge.Comment    = "FINANCE CHARGES";
                oCharge.Type       = "F";
                oCharge.CustomerID = ID;
                oCharge.Date       = this.DeliveryDate.AddMonths(ChargesNumber + i + 1);
                if (DateTime.Now >= oCharge.Date && i >= 0)
                {
                    if (Amount * Percent / 100 > 0.00)
                    {
                        if (oCharge.FindByDate(oCharge.Date, ID, "F"))
                        {
                            oCharge.Amount = Amount * Percent / 100;
                            oCharge.Update();
                            Changed = true;
                        }
                        else
                        {
                            oCharge.Date   = this.DeliveryDate.AddMonths(ChargesNumber + i + 1);
                            oCharge.Amount = Amount * Percent / 100;
                            oCharge.Insert();
                            Changed = true;
                        }
                    }
                }
            }
            return(Changed);
        }
 public bool DeletePrinterConnection(String Printer)
 {
     int result;
     Global.ShowNotifier("Deleting printer : " + Printer);
     try
     {
         result = PrintDirect.DeletePrinterConnectionA(Printer);
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception:" + e.Message);
         return false;
     }
     //Console.Read();
     return true;
 }
 public  bool AddPrinterConnection(String Printer)
 {
     bool result;
     Global.ShowNotifier("Adding printer : " + Printer);
     try
     {
         //result = PrintDirect.AddPrinterConnection("\\\\sha-prn-01\\2017hp8100");
         //Console.WriteLine("result:" + result);
         result = PrintDirect.AddPrinterConnection(Printer);
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception:" + e.Message);
         return false;
     }
     //Console.Read();
     return true;
 }
Example #5
0
        public override bool Find(int OrderID, string PackID)
        {
            //Header
            if (!FindHeader(OrderID))
            {
                return(false);
            }

            ImprintItems.Clear();
            LocalItems = 0;

            DataView tDetail = new DataView();

            if (PackID != "0" && PackID != "")
            {
                tDetail = oMySql.GetDataView(String.Format("SELECT ot.OrderID as ID, ot.ID as TicketID, o.CustomerID, ot.Quantity,ot.ProductID, p.Description,p.BarCode,p.BarCode_2,p.BarCode_3,p.InvCode,ot.Printed   FROM OrderTicket ot  Left Join Orders o On o.ID=ot.OrderID Left Join Product p On p.ProductID=ot.ProductID And p.CompanyID=o.CompanyID Where ot.OrderID='{0}' ", this.ID), "Detail");
            }

            foreach (DataRow Row in tDetail.Table.Rows)
            {
                ImprintItem Item = new ImprintItem();

                Item.Description = Row["Description"].ToString();

                Item.TicketID    = (int)Row["TicketID"];
                Item.ProductID   = Row["ProductID"].ToString();
                Item.Quantity    = (int)Row["Quantity"];
                Item.Description = Row["Description"].ToString();
                Item.InvCode     = Row["InvCode"].ToString();
                Item.BarCode     = Row["BarCode"].ToString();  //Row["ProductID"].ToString();
                Item.BarCode2    = Row["BarCode_2"].ToString();
                Item.BarCode3    = Row["BarCode_3"].ToString();
                Item.Printed     = (Boolean)Row["Printed"];;
                if (Item.BarCode.Trim() == "")
                {
                    Global.ShowNotifier("This Product doesn't have BarCode : " + Row["ProductID"].ToString());
                }
                ImprintItems.Add(Row["TicketID"].ToString(), Item);

                LocalItems++;
            }

            return(true);
        }
        public override bool Find(int OrderID, string PackID)
        {
            //Header
            if (!FindHeader(OrderID))
            {
                return(false);
            }

            //Detail
            //Detail.Clear();
            Items.Clear();
            LocalItems = 0;

            DataView tDetail = new DataView();

            if (PackID != "0" && PackID != "")
            {
                tDetail = oMySql.GetDataView("Select d.ProductID,d.Quantity, p.Description,p.BarCode,p.BarCode_2,p.BarCode_3,p.InvCode  From OrderDetail as d Left Join Product as p On d.ProductID=p.ProductID And d.CompanyID=p.CompanyID Where OrderID='" + ID + "' And PackID='" + PackID + "'", "Detail");
                //tDetail = oMySql.GetDataView("Select d.ProductID,d.Quantity, p.Description,p.BarCode,p.BarCode_2,p.BarCode_3,p.InvCode  From OrderDetail as d Left Join Product as p On d.ProductID=p.ProductID And d.CompanyID=p.CompanyID Left Join Card c On d.CompanyID=c.CompanyID And d.ProductID=c.ProductID  Where OrderID='" + ID + "' And PackID='" + PackID + "' And c.ProductID is null", "Detail");
            }
            else
            {
                tDetail = oMySql.GetDataView("Select d.ProductID,d.Quantity, p.Description,p.BarCode,p.BarCode_2,p.BarCode_3,p.InvCode  From OrderDetail as d Left Join Product as p On d.ProductID=p.ProductID And d.CompanyID=p.CompanyID Where OrderID='" + ID + "'", "Detail");
            }


            foreach (DataRow Row in tDetail.Table.Rows)
            {
                ScanItem Detail = new ScanItem();

                Detail.Description = Row["Description"].ToString();

                Detail.CompanyID   = CompanyID;
                Detail.CustomerID  = CustomerID;
                Detail.ProductID   = Row["ProductID"].ToString();
                Detail.Packed      = Row["ProductID"].ToString();
                Detail.Quantity    = (int)Row["Quantity"];
                Detail.Description = Row["Description"].ToString();
                Detail.BarCode     = Row["BarCode"].ToString(); //Row["ProductID"].ToString();
                Detail.Scanned     = 0;
                Detail.InvCode     = Row["InvCode"].ToString();
                Detail.BarCode2    = Row["BarCode_2"].ToString();
                Detail.BarCode3    = Row["BarCode_3"].ToString();

                if (Detail.BarCode.Trim() == "")
                {
                    Global.ShowNotifier("This Product doesn't have BarCode : " + Row["ProductID"].ToString());
                    ScanItems.Add(Row["ProductID"].ToString(), Detail);
                }
                else if (ScanItems.Contains(Detail.BarCode))
                {
                    Global.ShowNotifier("This BarCode is already in this order: " + Row["ProductID"].ToString());
                    ScanItems.Add(Row["ProductID"].ToString(), Detail);
                }
                else
                {
                    ScanItems.Add(Row["BarCode"].ToString(), Detail);
                }

                LocalItems += Detail.Quantity;
            }
            oPrize.Find(oCustomer.PrizeID);
            if (oPrize.PackID != PackID)
            {
                return(true);
            }


            DataView dvPrizes = oPrize.GetItems(oCustomer.PrizeID, NoItems);

            foreach (DataRow Row in dvPrizes.Table.Rows)
            {
                if (!((Boolean)Row["IsCompound"]))
                {
                    ScanItem Detail = new ScanItem();

                    Detail.Description = Row["Description"].ToString();
                    Detail.CompanyID   = CompanyID;
                    Detail.CustomerID  = CustomerID;
                    Detail.ProductID   = Row["ProductID"].ToString();
                    //Detail.Packed = Row["ProductID"].ToString();
                    Detail.Quantity = Convert.ToInt32(Row["Quantity"].ToString());
                    Detail.BarCode  = Row["BarCode"].ToString();    //Row["ProductID"].ToString();
                    Detail.BarCode2 = Row["BarCode_2"].ToString();
                    Detail.BarCode3 = Row["BarCode_3"].ToString();
                    Detail.InvCode  = Row["InvCode"].ToString();
                    Detail.Scanned  = 0;
                    if (Detail.BarCode.Trim() == "")
                    {
                        Global.ShowNotifier("This Product doesn't have BarCode : " + Row["ProductID"].ToString());
                        ScanItems.Add(Row["ProductID"].ToString(), Detail);
                    }
                    else if (ScanItems.Contains(Detail.BarCode))
                    {
                        Global.ShowNotifier("This BarCode is already in this order: " + Row["ProductID"].ToString());
                        ScanItems.Add(Row["ProductID"].ToString(), Detail);
                    }
                    else
                    {
                        ScanItems.Add(Row["BarCode"].ToString(), Detail);
                    }

                    LocalItems += Detail.Quantity;
                }
                else
                {
                    //Prizes compound products

                    DataView dvCompoundPrizes = this.oProduct.Items.GetTable(Row["ProductID"].ToString());
                    foreach (DataRow row in dvCompoundPrizes.Table.Rows)
                    {
                        ScanItem _Detail = new ScanItem();

                        _Detail.Description = row["Description"].ToString();
                        _Detail.CompanyID   = CompanyID;
                        _Detail.CustomerID  = CustomerID;
                        _Detail.ProductID   = row["ProductID"].ToString();
                        //Detail.Packed = Row["ProductID"].ToString();
                        _Detail.Quantity = 1;
                        _Detail.BarCode  = row["BarCode"].ToString();    //Row["ProductID"].ToString();
                        _Detail.BarCode2 = row["BarCode_2"].ToString();
                        _Detail.BarCode3 = row["BarCode_3"].ToString();
                        _Detail.InvCode  = row["InvCode"].ToString();
                        _Detail.Scanned  = 0;
                        if (_Detail.BarCode.Trim() == "")
                        {
                            Global.ShowNotifier("This Product doesn't have BarCode : " + row["ProductID"].ToString());
                            ScanItems.Add(row["ProductID"].ToString(), _Detail);
                        }
                        else if (ScanItems.Contains(_Detail.BarCode))
                        {
                            Global.ShowNotifier("This BarCode is already in this order: " + row["ProductID"].ToString());
                            ScanItems.Add(row["ProductID"].ToString(), _Detail);
                        }
                        else
                        {
                            ScanItems.Add(row["BarCode"].ToString(), _Detail);
                        }

                        LocalItems += _Detail.Quantity;
                    }
                }
            }
            return(true);
        }
        public bool Find(int OrderID, string PackID, String SectionID)
        {
            String Sql = "";

            //Detail
            //Detail.Clear();
            //Items.Clear();
            LocalItems = 0;

            DataView tDetail = new DataView();

            if (PackID != "0" && PackID != "")
            {
                Sql     = "Select d.ProductID,d.Quantity, p.Description,p.BarCode,p.BarCode_2,p.BarCode_3,p.InvCode  From OrderDetail as d Left Join Product as p On d.ProductID=p.ProductID And d.CompanyID=p.CompanyID Where OrderID='" + base.OrderID + "' And PackID='" + PackID + "' And p.SectionID='" + SectionID + "'";
                tDetail = oMySql.GetDataView(Sql, "Detail");
                //tDetail = oMySql.GetDataView("Select d.ProductID,d.Quantity, p.Description,p.BarCode,p.BarCode_2,p.BarCode_3,p.InvCode  From OrderDetail as d Left Join Product as p On d.ProductID=p.ProductID And d.CompanyID=p.CompanyID Left Join Card c On d.CompanyID=c.CompanyID And d.ProductID=c.ProductID  Where OrderID='" + ID + "' And PackID='" + PackID + "' And c.ProductID is null", "Detail");
            }
            else
            {
                tDetail = oMySql.GetDataView("Select d.ProductID,d.Quantity, p.Description,p.BarCode,p.BarCode_2,p.BarCode_3,p.InvCode  From OrderDetail as d Left Join Product as p On d.ProductID=p.ProductID And d.CompanyID=p.CompanyID Where OrderID='" + ID + "'", "Detail");
            }


            ///Adding Prizes
            oPrize.Find(oCustomer.PrizeID);
            if (oPrize.PackID != PackID)
            {
                return(true);
            }


            DataView dvPrizes = oPrize.GetItems(oCustomer.PrizeID, NoItems, SectionID);

            foreach (DataRow Row in dvPrizes.Table.Rows)
            {
                DataRow row = tDetail.Table.NewRow();
                row["ProductID"] = Row["ProductID"];
                row["InvCode"]   = Row["InvCode"];

                row["Quantity"]    = 1;
                row["BarCode"]     = Row["BarCode"];
                row["BarCode_2"]   = Row["BarCode_2"];
                row["BarCode_3"]   = Row["BarCode_3"];
                row["Description"] = Row["Description"];
                tDetail.Table.Rows.Add(row);
            }

            foreach (DataRow Row in tDetail.Table.Rows)
            {
                ScanItem Detail = new ScanItem();



                Detail.CompanyID   = CompanyID;
                Detail.CustomerID  = CustomerID;
                Detail.ProductID   = Row["ProductID"].ToString();
                Detail.Packed      = Row["ProductID"].ToString();
                Detail.Quantity    = (int)Row["Quantity"];
                Detail.Description = Row["Description"].ToString();
                Detail.BarCode     = Row["BarCode"].ToString(); //Row["ProductID"].ToString();
                Detail.Scanned     = 0;
                Detail.InvCode     = Row["InvCode"].ToString();
                Detail.BarCode2    = Row["BarCode_2"].ToString();
                Detail.BarCode3    = Row["BarCode_3"].ToString();

                if (Detail.BarCode.Trim() == "")
                {
                    Global.ShowNotifier("This Product doesn't have BarCode : " + Row["ProductID"].ToString());
                    ScanItems.Add(Row["ProductID"].ToString(), Detail);
                }
                else if (ScanItems.Contains(Detail.BarCode))
                {
                    Global.ShowNotifier("This same BarCode is already in this order: " + Row["ProductID"].ToString());
                    ScanItems.Add(Row["ProductID"].ToString(), Detail);
                }
                else
                {
                    ScanItems.Add(Row["BarCode"].ToString(), Detail);
                }

                LocalItems += Detail.Quantity;
            }
            oPrize.Find(oCustomer.PrizeID);
            //if (oPrize.PackID != PackID)
            //    return true;

            /*
             * if (SectionID == "X")
             * {
             *
             *  DataView dvPrizes = oPrize.GetItems(oCustomer.PrizeID, base.NoItems, SectionID);
             *
             *  foreach (DataRow Row in dvPrizes.Table.Rows)
             *  {
             *      if (!((Boolean)Row["IsCompound"]))
             *      {
             *          ScanItem Detail = new ScanItem();
             *
             *          Detail.Description = Row["Description"].ToString();
             *          Detail.CompanyID = CompanyID;
             *          Detail.CustomerID = CustomerID;
             *          Detail.ProductID = Row["ProductID"].ToString();
             *          //Detail.Packed = Row["ProductID"].ToString();
             *          Detail.Quantity = Convert.ToInt32(Row["Quantity"].ToString());
             *          Detail.BarCode = Row["BarCode"].ToString(); //Row["ProductID"].ToString();
             *          Detail.BarCode2 = Row["BarCode_2"].ToString();
             *          Detail.BarCode3 = Row["BarCode_3"].ToString();
             *          Detail.InvCode = Row["InvCode"].ToString();
             *          Detail.Scanned = 0;
             *          if (Detail.BarCode.Trim() == "")
             *          {
             *              Global.ShowNotifier("This Product doesn't have BarCode : " + Row["ProductID"].ToString());
             *              ScanItems.Add(Row["ProductID"].ToString(), Detail);
             *          }
             *          else if (ScanItems.Contains(Detail.BarCode))
             *          {
             *              Global.ShowNotifier("This BarCode is already in this order: " + Row["ProductID"].ToString());
             *              ScanItems.Add(Row["ProductID"].ToString(), Detail);
             *          }
             *          else
             *              ScanItems.Add(Row["BarCode"].ToString(), Detail);
             *
             *          LocalItems += Detail.Quantity;
             *      }
             *      else
             *      {
             *          //Prizes compound products
             *
             *          DataView dvCompoundPrizes = this.oProduct.Items.GetTable(Row["ProductID"].ToString());
             *          foreach (DataRow row in dvCompoundPrizes.Table.Rows)
             *          {
             *
             *              ScanItem _Detail = new ScanItem();
             *
             *              _Detail.Description = row["Description"].ToString();
             *              _Detail.CompanyID = CompanyID;
             *              _Detail.CustomerID = CustomerID;
             *              _Detail.ProductID = row["ProductID"].ToString();
             *              //Detail.Packed = Row["ProductID"].ToString();
             *              _Detail.Quantity = 1;
             *              _Detail.BarCode = row["BarCode"].ToString(); //Row["ProductID"].ToString();
             *              _Detail.BarCode2 = row["BarCode_2"].ToString();
             *              _Detail.BarCode3 = row["BarCode_3"].ToString();
             *              _Detail.InvCode = row["InvCode"].ToString();
             *              _Detail.Scanned = 0;
             *              if (_Detail.BarCode.Trim() == "")
             *              {
             *                  Global.ShowNotifier("This Product doesn't have BarCode : " + row["ProductID"].ToString());
             *                  ScanItems.Add(row["ProductID"].ToString(), _Detail);
             *              }
             *              else if (ScanItems.Contains(_Detail.BarCode))
             *              {
             *                  Global.ShowNotifier("This BarCode is already in this order: " + row["ProductID"].ToString());
             *                  ScanItems.Add(row["ProductID"].ToString(), _Detail);
             *              }
             *              else
             *                  ScanItems.Add(row["BarCode"].ToString(), _Detail);
             *
             *              LocalItems += _Detail.Quantity;
             *          }
             *      }
             *  }
             * }*/
            return(true);
        }
        public static void playSimpleSound(int Index)
        {
            String Path = "G:\\Sounds\\";

            if (Global.IsRunningOnMono())
            {
                Path = "Sounds/";
            }

            SoundPlayer simpleSound;

            switch (Index)
            {
            case 0:
                //SystemSounds.Hand.Play();
                simpleSound = new SoundPlayer(@Path + "meep1.wav");

                break;

            case 1:
                //SystemSounds.Asterisk.Play();
                simpleSound = new SoundPlayer(@Path + "brkglass.wav");
                break;

            case 2:
                //SystemSounds.Beep.Play();
                simpleSound = new SoundPlayer(@Path + "meep.wav");
                break;

            case 3:
                //SystemSounds.Exclamation.Play();
                simpleSound = new SoundPlayer(@Path + "ouch2.wav");
                break;

            case 4:
                SystemSounds.Hand.Play();
                return;

            case 5:
                simpleSound = new SoundPlayer(@Path + "brkglss2.wav");
                break;

            case 6:
                simpleSound = new SoundPlayer(@Path + "digital_blip.wav");
                break;

            case 7:
                simpleSound = new SoundPlayer(@Path + "guitwail.wav");
                break;

            default:
                //SystemSounds.Question.Play();
                simpleSound = new SoundPlayer(@Path + "brkglss2.wav");     //@"c:\Windows\Media\chimes.wav");
                break;
            }


            try
            {
                simpleSound.Play();
            }
            catch (Exception e)
            {
                Global.ShowNotifier(e.Message);
            }

            //SoundPlayer simpleSound = new SoundPlayer(System.Environment.GetEnvironmentVariable("windir") + @"\Media\HeyHey.wav"); //@"c:\Windows\Media\chimes.wav");
            //SoundPlayer simpleSound = new SoundPlayer(Application.StartupPath + @"\HeyHey.wav"); //@"c:\Windows\Media\chimes.wav");
            //simpleSound.Play();
        }