Exemplo n.º 1
0
        public static List <PrintProduct> GetYTProdcut(List <Item> lstProducts)
        {
            List <PrintProduct> listPro   = new List <PrintProduct>();
            PrintProduct        printItem = null;
            product_response    response  = new product_response();

            if (lstProducts != null & lstProducts.Count > 0)
            {
                response.item = new List <PrintProduct>();
                foreach (Item product in lstProducts)
                {
                    printItem            = new PrintProduct();
                    printItem.num_iid    = product.NumIid.ToString(); //商品编码
                    printItem.outer_id   = product.OuterId;           //商家编码
                    printItem.goods_code = "";                        //货号
                    printItem.model_code = "";                        //品牌型号
                    printItem.bar_code   = product.Barcode;           //商品条码,编码格式为128码
                    //用货号填充商家编码
                    printItem.price       = product.Price;            //
                    printItem.weight      = "";
                    printItem.seller_cids = product.SellerCids;       //商家分类
                    printItem.title       = product.Title;
                    printItem.pic_path    = product.PicUrl;
                    listPro.Add(printItem);
                    response.item.Add(printItem);
                }
                //response.total_results = listPro.Count.ToString();
            }
            return(listPro);
        }
Exemplo n.º 2
0
        private void repositoryItemSpinEditDiscountsFirstRow_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            if (e.Button.Index != 1)
            {
                return;
            }
            advBandedGridViewPublication.CloseEditor();
            double temp;
            var    value = advBandedGridViewPublication.GetFocusedRowCellValue(advBandedGridViewPublication.FocusedColumn);

            if (value == null)
            {
                return;
            }
            if (!double.TryParse(value.ToString(), out temp))
            {
                return;
            }
            if (advBandedGridViewPublication.FocusedColumn == gridColumnDiscounts)
            {
                PrintProduct.CopyDiscounts(temp);
            }
            else if (advBandedGridViewPublication.FocusedColumn == gridColumnColorPricingPercent)
            {
                PrintProduct.CopyColorRatePercent(temp);
            }
            LoadInserts();
        }
		public PublicationSnapshotControl(PrintProduct printProduct)
		{
			InitializeComponent();
			Dock = DockStyle.Top;
			_printProduct = printProduct;
			UpdateData();
		}
Exemplo n.º 4
0
        public void CloneInsert()
        {
            if (PrintProduct.Inserts.Count <= 0 || advBandedGridViewPublication.FocusedRowHandle < 0)
            {
                return;
            }
            var originalInsert = PrintProduct.Inserts[advBandedGridViewPublication.GetDataSourceRowIndex(advBandedGridViewPublication.FocusedRowHandle)];

            if (originalInsert.Date.HasValue)
            {
                if (!(originalInsert.Comments.Any() || originalInsert.Sections.Any() || !String.IsNullOrEmpty(originalInsert.Deadline) || !String.IsNullOrEmpty(originalInsert.Mechanicals)))
                {
                    if (Utilities.Instance.ShowWarningQuestion(String.Format("The Ad you are Cloning does not have any Unique Ad-notes or Comments.{0}{0}Do you still want to CLONE this Ad?", Environment.NewLine)) != DialogResult.Yes)
                    {
                        return;
                    }
                }
                using (var form = new FormCloneInsert(originalInsert))
                {
                    form.checkEditPCIRate.Text = PrintProduct.AdPricingStrategy == AdPricingStrategies.StandartPCI ? gridBandPCIRate.Caption : gridBandADRate.Caption;
                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    PrintProduct.CloneInsert(originalInsert, form.SelectedDates, form.checkEditPCIRate.Checked, form.checkEditDiscount.Checked, PrintProduct.ColorOption != ColorOptions.BlackWhite && form.checkEditColorRate.Checked, form.checkEditComment.Checked, form.checkEditSections.Checked, form.checkEditDeadline.Checked, form.checkEditMechanicals.Checked);
                    LoadInserts();
                    Controller.Instance.PrintProductContainer.SettingsNotSaved = true;
                }
            }
            else
            {
                Utilities.Instance.ShowWarning("You need to select Date first.");
            }
        }
Exemplo n.º 5
0
 public PublicationSnapshotControl(PrintProduct printProduct)
 {
     InitializeComponent();
     Dock          = DockStyle.Top;
     _printProduct = printProduct;
     UpdateData();
 }
        private void lblPrintBarCode_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                PrintProduct product   = new PrintProduct();
                var          productId = Convert.ToInt64(lblProductID.Text);
                if (productId > 0)
                {
                    // lblProductID.Text = row.Cells["ProductID"].Value.ToString();
                    product.EmissionNorms = cmbEmission.SelectedValue.ToString();      //= row.Cells["EmissionNorms"].Value;
                    product.Color         = cmbColor1.SelectedValue.ToString();        //= row.Cells["Color"].Value;
                    product.MajorVariant  = cmbMajorVariant1.SelectedValue.ToString(); // = row.Cells["MajorVariant"].Value;
                    product.Type          = cmbType.SelectedValue.ToString();          //= row.Cells["Type"].Value;
                    product.CustomerCode  = txtCustCode1.Text;                         //= row.Cells["CustomerCode"].Value.ToString();
                    product.BarCode       = txtBarCode1.Text;                          //= row.Cells["BarCode"].Value.ToString();

                    PrintBarcode(product);
                }
                //else {
                ////do

                //}
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
        }
Exemplo n.º 7
0
 public void AddInsert()
 {
     PrintProduct.AddInsert();
     LoadInserts();
     advBandedGridViewPublication.FocusedRowHandle  = advBandedGridViewPublication.RowCount - 1;
     Controller.Instance.PrintProductDelete.Enabled = PrintProduct.Inserts.Count > 0;
     Controller.Instance.PrintProductClone.Enabled  = PrintProduct.Inserts.Count > 0;
 }
Exemplo n.º 8
0
        public void SetPrintStatus(PrintProduct order)
        {
            //new CustomerOrderRepository

            // new CustomerOrderRepository().ChangePrintStatus(OrderID);

            //var barcode = "select * from tbl"

            frmBarcodePrinting barcodePrint = new frmBarcodePrinting(order, this);
            // barcodePrint.ShowDialog();
        }
Exemplo n.º 9
0
        public void DeleteInsert()
        {
            var selectedRowIds = advBandedGridViewPublication.GetSelectedRows().ToList();

            if (Utilities.Instance.ShowWarningQuestion("Are you sure you want to delete selected line{0}?", selectedRowIds.Count > 1 ? "s" : String.Empty) != DialogResult.Yes)
            {
                return;
            }
            advBandedGridViewPublication.DeleteSelectedRows();
            PrintProduct.RebuildInserts();
            LoadInserts();
            Controller.Instance.PrintProductContainer.SettingsNotSaved = true;
            Controller.Instance.PrintProductDelete.Enabled             = PrintProduct.Inserts.Count > 0;
            Controller.Instance.PrintProductClone.Enabled = PrintProduct.Inserts.Count > 0;
        }
Exemplo n.º 10
0
 private void repositoryItemSpinEditPCIRateFirstRow_ButtonClick(object sender, ButtonPressedEventArgs e)
 {
     if (e.Button.Index == 1)
     {
         advBandedGridViewPublication.CloseEditor();
         double temp;
         var    value = advBandedGridViewPublication.GetFocusedRowCellValue(advBandedGridViewPublication.FocusedColumn);
         if (value == null)
         {
             return;
         }
         if (double.TryParse(value.ToString(), out temp))
         {
             PrintProduct.CopyPCIRate(temp);
             LoadInserts();
         }
     }
 }
 public frmBarcodePrinting(PrintProduct _product, frmDashboard parent)
 {
     try
     {
         InitializeComponent();
         //if(barCode.
         //  string barCode = txtCode.Text;
         product    = _product;
         _orderId   = product.OrderID;
         parentForm = parent;
         DrawBarcode();
         InitiatePrint();
         this.Hide();
     }
     catch (Exception ex)
     {
         LogException(ex);
     }
 }
Exemplo n.º 12
0
        private void DoPrintProduct()
        {
            try
            {
                if (!UserService.AllowToPerform(Resources.PermissionPrintProductCode))
                {
                    const string briefMsg  = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                    var          detailMsg = Resources.MsgUserPermissionDeny;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                //Generate product to print
                var selectedProductList = new BindingList <Product>();
                foreach (var product in
                         _productList.Where(product => product != null).Where(product => product.PrintCheck))
                {
                    selectedProductList.Add(product);
                }

                PrintProduct.InializePrinting(selectedProductList);
                SetFocusToProductList();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 13
0
        private void dgBackBumpers_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                if (e.RowIndex >= 0)
                {
                    var row = dgBackBumpers.Rows[e.RowIndex]; //dgFrontBumpers.se

                    var cell     = row.Cells["OrderStatusID"];
                    var statusId = (long)cell.Value;

                    if (e.RowIndex == rearRowToProcess || (statusId == (long)OrderStatus.Rejected || statusId == (long)OrderStatus.Skip))
                    {
                        RearRowIndex = e.RowIndex + 1;
                        var rejectColumn = this.dgBackBumpers.Columns["Reject"];
                        if (rejectColumn != null)
                        {
                            var rejectIndex = rejectColumn.Index;

                            //        print.DefaultCellStyle.Font =
                            if (e.ColumnIndex == rejectIndex)
                            {
                            }
                            else
                            {
                                //var connectionString = e.RowIndex +1 ;



                                //green
                                //  row.DefaultCellStyle.BackColor = Color.FromArgb(127, 186, 0);

                                // dgFrontBumpers.ClearSelection();
                                dgBackBumpers.ClearSelection();


                                // dgBackBumpers.Rows[e.RowIndex].Selected = true;
                                //dgBackBumpers.FirstDisplayedScrollingRowIndex = e.RowIndex;
                                if (statusId == (long)OrderStatus.New || statusId == (long)OrderStatus.Rejected || statusId == (long)OrderStatus.Skip)
                                {
                                    //  var row = dgBackBumpers.Rows[e.RowIndex]; //dgFrontBumpers.se

                                    //  row.DefaultCellStyle.BackColor = Color.FromArgb(127, 186, 0);
                                    //  row.DefaultCellStyle.BackColor = Color.FromArgb(127, 186, 0);
                                    var order = new PrintProduct();
                                    order.OrderID       = Convert.ToInt64(row.Cells["OrderID"].Value.ToString());
                                    order.BarCode       = row.Cells["BarCode"].Value.ToString();
                                    order.CustomerCode  = row.Cells["CustomerCode"].Value.ToString();
                                    order.EmissionNorms = row.Cells["EmissionNorms"].Value.ToString();
                                    order.Color         = row.Cells["Color"].Value.ToString();
                                    order.MajorVariant  = row.Cells["MajorVariant"].Value.ToString();
                                    order.Type          = "Rear";

                                    //set print status
                                    SetPrintStatus(order);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogException(ex, true);
            }
        }
Exemplo n.º 14
0
        private void dgBackBumpers_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right)
                {
                    e.Handled = true;
                }

                if (e.KeyCode == Keys.Enter && dgBackBumpers.SelectedCells.Count > 0)
                {
                    var cell = dgBackBumpers.SelectedCells[0];
                    //dgFrontBumpers.se



                    if (cell != null && cell.RowIndex >= 0 && cell.RowIndex == rearRowToProcess)
                    {
                        //                    dgFrontBumpers.ClearSelection();
                        dgBackBumpers.ClearSelection();

                        //  RearRowIndex = cell.RowIndex +1;
                        var row = dgBackBumpers.Rows[cell.RowIndex];
                        // dgBackBumpers.Rows[cell.RowIndex].Selected = true;
                        e.Handled = true;
                        var cell1    = row.Cells["OrderStatusID"];
                        var statusId = (long)cell1.Value;
                        //    row.Selected = true;
                        //dgFrontBumpers.FirstDisplayedScrollingRowIndex = cell.RowIndex;

                        if (statusId == (long)OrderStatus.New || statusId == (long)OrderStatus.Rejected || statusId == (long)OrderStatus.Skip)
                        {
                            //  var row = dgBackBumpers.Rows[e.RowIndex]; //dgFrontBumpers.se

                            //  row.DefaultCellStyle.BackColor = Color.FromArgb(127, 186, 0);
                            //  row.DefaultCellStyle.BackColor = Color.FromArgb(127, 186, 0);
                            var order = new PrintProduct();
                            order.OrderID       = Convert.ToInt64(row.Cells["OrderID"].Value.ToString());
                            order.BarCode       = row.Cells["BarCode"].Value.ToString();
                            order.CustomerCode  = row.Cells["CustomerCode"].Value.ToString();
                            order.EmissionNorms = row.Cells["EmissionNorms"].Value.ToString();
                            order.Color         = row.Cells["Color"].Value.ToString();
                            order.MajorVariant  = row.Cells["MajorVariant"].Value.ToString();
                            order.Type          = "Rear";

                            //set print status
                            SetPrintStatus(order);
                        }
                        // row.DefaultCellStyle.BackColor = Color.FromArgb(255, 140, 0);
                        // LoadGridData();
                        //if (cell.RowIndex < dgBackBumpers.Rows.Count)
                        //{
                        //    var nextRow = dgBackBumpers.Rows[cell.RowIndex + 1];
                        //    nextRow.Selected = true;
                        //}
                        // MessageBox.Show("Barcode printed successfully");
                        // MessageBox.Show(row.Cells["OrderID"].Value.ToString());
                    }


                    //MessageBox.Show(cell.Value.ToString());
                    //MessageBox.Show(cell.RowIndex.ToString());
                }
            }
            catch (Exception ex)
            {
                LogException(ex, true);
            }
        }
Exemplo n.º 15
0
        public ClassPrintCheck(XContainer rootElement, bool duplicate)
        {
            Duplicate = duplicate;
            var listProduct = new List <PrintGroupProduct>();

            _tva = new List <string>();
            foreach (var p in RepositoryTypePay.TypePays)
            {
                var money = rootElement.GetXAttribute("check", p.NameCourt.Trim());

                if (money != null)
                {
                    _attr.Add(new PrintTypePay(p, money.Value.ToDecimal()));
                }
            }

            Rendu = rootElement.GetXAttributeValue("check", "Rendu").ToDecimal();

            var xe = rootElement.GetXElements("check", "product");

            var sum          = 0.0m;
            var sumDiscounts = 0.0m;

            foreach (var e in xe)
            {
                var discount    = e.GetXElementValue("Discount").ToDecimal();
                var sumDiscount = -e.GetXElementValue("sumDiscount").ToDecimal();
                var codebare    = e.GetXElementValue("CodeBare").Trim();
                var qty         = e.GetXElementValue("qty").ToDecimal();
                var name        = e.GetXElementValue("Name");
                var total       = e.GetXElementValue("total").ToDecimal() - sumDiscount;
                var price       = e.GetXElementValue("price").ToDecimal();
                var categories  = RepositoryGroupProduct.GetGroupNameById(e.GetXElementValue("grp").ToInt());
                var tva         = e.GetXElementValue("tva").ToInt();
                var customerId  = e.GetXElementValue("CustomerId").ToGuid();

                var p = new PrintProduct(customerId, categories, codebare, name, qty, total, price, tva, discount, sumDiscount);

                #region DISCOUNT

                if (discount > 0)
                {
                    var discountcategories = "Remise " + p.ProcentDiscount + "%";

                    var discountIndx = listProduct.FindIndex(l => l.Categories == discountcategories);
                    if (discountIndx == -1)
                    {
                        var pn = new PrintProduct(Guid.Empty, discountcategories, Barcode, name, qty, total, price, tva, discount, sumDiscount);
                        listProduct.Add(new PrintGroupProduct(discountcategories, pn));
                    }
                    else
                    {
                        //  groupProduct.product pn = new groupProduct.product(Guid.Empty, discountcategories, "", name, 1, sumDiscount, 0, tva_, Discount, sumDiscount);
                        var pn = new PrintProduct(Guid.Empty, discountcategories, Barcode, name, qty, total, price, tva, discount, sumDiscount);

                        var repeat = listProduct[discountIndx].Products.FindIndex(l => l.Name == name);

                        if (repeat != -1)
                        {
                            listProduct[discountIndx].Products[repeat].Total       += pn.SumDiscount;
                            listProduct[discountIndx].Products[repeat].Price        = pn.Price;
                            listProduct[discountIndx].Products[repeat].TvaTotal    += pn.TvaTotal;
                            listProduct[discountIndx].Products[repeat].Ht          += pn.Ht;
                            listProduct[discountIndx].Products[repeat].SumDiscount += pn.SumDiscount;
                        }
                        else
                        {
                            listProduct[discountIndx].Products.Add(pn);
                        }
                    }

                    sumDiscounts -= sumDiscount;
                }

                #endregion

                var indx = listProduct.FindIndex(l => l.Categories == p.Categories);

                if (indx != -1)
                {
                    var f = listProduct[indx].Products.FindIndex(l => (l.CustomerId == p.CustomerId) && l.Price == p.Price);

                    if (f == -1)
                    {
                        listProduct[indx].Products.Add(p);
                    }
                    else
                    {
                        if (listProduct[indx].Products[f].Categories != "Remise " + p.ProcentDiscount + "%")
                        {
                            listProduct[indx].Products[f].Qty         += p.Qty;
                            listProduct[indx].Products[f].Total       += p.Total;
                            listProduct[indx].Products[f].Price        = p.Price;
                            listProduct[indx].Products[f].TvaTotal    += p.TvaTotal;
                            listProduct[indx].Products[f].Ht          += p.Ht;
                            listProduct[indx].Products[f].SumDiscount += p.SumDiscount;
                        }
                    }
                }
                else
                {
                    listProduct.Add(new PrintGroupProduct(categories, p));
                }


                sum += total;
            }

            listProduct = listProduct.OrderBy(l => l.Categories).ToList();

            var listProductDiscount = listProduct.FindAll(l => l.Categories.IndexOf("Discount") != -1);
            listProduct.RemoveAll(l => l.Categories.IndexOf("Discount") != -1);

            var listProductDiscountRemise = listProduct.FindAll(l => l.Categories.IndexOf("Remise") != -1);
            listProduct.RemoveAll(l => l.Categories.IndexOf("Remise") != -1);

            listProduct.AddRange(listProductDiscount);
            listProduct.AddRange(listProductDiscountRemise);

            Head   = File.ReadAllText(PathH);
            Footer = File.ReadAllText(PathF);

            Barcode = rootElement.GetXAttributeValue("check", "barcodeCheck");

            Totals      = (sum - sumDiscounts).ToString("0.00");
            SumDiscount = sumDiscounts.ToString("0.00");

            #region DiscountPoints

            var a0 = rootElement.GetXAttribute("check", "DCBC");
            var a1 = rootElement.GetXAttribute("check", "DCBC_BiloPoints");
            var a2 = rootElement.GetXAttribute("check", "DCBC_DobavilePoints");
            var a3 = rootElement.GetXAttribute("check", "DCBC_OtnayliPoints");
            var a4 = rootElement.GetXAttribute("check", "DCBC_OstalosPoints");
            var a5 = rootElement.GetXAttribute("check", "DCBC_name");

            var bcdc = a0?.Value;

            if (!string.IsNullOrEmpty(bcdc))
            {
                C = new PrintClientInfo
                {
                    Dcbc               = a0.Value,
                    DcbcBiloPoints     = a1.Value,
                    DcbcDobavilePoints = a2.Value,
                    DcbcOtnayliP       = a3.Value,
                    DcbcOstalosPoints  = a4.Value,
                    DcbcName           = a5.Value
                }
            }
            ;

            #endregion

            DotLiquidService.Print(Barcode, Head, listProduct, Totals, SumDiscount, _attr, Rendu, Footer, C, duplicate);
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            //anonymous method to take a string(sentence)
            Print print = delegate(string sentence)
            {
                //split the sentence using " "--space and store in array of string
                string[] words = sentence.Split(" ");

                Console.WriteLine("After splitting");
                //printing each word on the console
                foreach (string word in words)
                {
                    Console.WriteLine(word);
                }
            };

            //Take string input from user
            Console.Write("Enter sentence : ");
            string str = Console.ReadLine();

            print(str);

            Console.WriteLine("************************************************************\n");
            //anonymous method to take 2 int values
            PrintProduct prod = delegate(int num1, int num2)
            {
                Console.WriteLine($"Product of {num1} and {num2} is {num1 * num2}");
            };

            //Take string input from user
            Console.Write("Enter First Number : ");
            int n1 = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter Second Number : ");
            int n2 = Convert.ToInt32(Console.ReadLine());

            prod(n1, n2);

            Console.WriteLine("************************************************************\n");

            //Create a List of Employees
            List <Employee> listEmployees = new List <Employee>();

            listEmployees.Add(new Employee("John", 100000));
            listEmployees.Add(new Employee("Rahul", 300000));
            listEmployees.Add(new Employee("Patel", 200000));
            listEmployees.Add(new Employee("Meera", 400000));
            listEmployees.Add(new Employee("Alice", 500000));

            Employee emps = new Employee();

            //Predicate
            Predicate <List <Employee> > empWithHigherSalary = emps.findEmployee;
            bool result = empWithHigherSalary(listEmployees);

            //if emp found call method to print result
            if (result == true)
            {
                emps.printResult();
            }
            else
            {
                Console.WriteLine("No employee with salary > 200k found");
            }

            Console.WriteLine("************************************************************\n");
            //Create directory
            string root = @"C:\00_Temp";

            // If directory does not exist, create it.
            if (!Directory.Exists(root))
            {
                Directory.CreateDirectory(root);
            }

            string fileName = @"c:\00_Temp\MyTextFile.txt";

            //call to method
            FileWriteAndRead f = new FileWriteAndRead();

            f.writeAndRead(fileName);

            Console.WriteLine("************************************************************\n");
            Console.WriteLine("?? Example");
            List <string> names = null;
            string?       a     = null;
            string?       b     = "Meera";

            /*
             * Available in C# 8.0 and later, so if old version add <LangVersion>8.0</LangVersion> in .csproj file
             * The null -coalescing assignment operator ??= assigns the value of its right-hand operand to its
             * left-hand operand only if the left-hand operand evaluates to null.
             * The ??= operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-null
             */
            (names ??= new List <string>()).Add("Paul");
            foreach (string name in names)
            {
                Console.WriteLine(name);
            }
            Console.WriteLine("");
            names.Add(a ??= "John");
            names.Add(b ??= "Bob");
            foreach (string name in names)
            {
                Console.WriteLine(name);
            }

            Console.WriteLine("************************************************************\n");
            Console.WriteLine("Nullable Example");
            string?bookName = null;
            double?price    = null;

            //Console.WriteLine(price.GetValueOrDefault());
            if (price.HasValue)
            {
                Console.WriteLine("Price is " + price.Value);
            }
            else
            {
                Console.WriteLine("Price is Null");
            }

            string book  = bookName ?? "Nimona";
            double value = price ?? 50.55;

            Console.WriteLine("Book : " + book);
            Console.WriteLine("Value : " + value);

            NullableClassEx myClass = new NullableClassEx();

            if (myClass.val == null)
            {
                Console.WriteLine("NullableClass variable is null");
            }

            //Null is considered to be less than any value. So comparison operators won't work against null.
            if (price < value)
            {
                Console.WriteLine("price < value");
            }
            else if (price > value)
            {
                Console.WriteLine("price > value");
            }
            else if (price == value)
            {
                Console.WriteLine("price == value");
            }
            else
            {
                Console.WriteLine("Could not compare price and Value");
            }

            //Nullable static class is a helper class for Nullable types.
            //It provides a compare method to compare nullable types.

            /*
             * if (Nullable.Compare<double>(price, value) < 0)
             *  Console.WriteLine("price < value");
             * else if (Nullable.Compare<double>(price, value) > 0)
             *  Console.WriteLine("price > value");
             * else
             *  Console.WriteLine("price = value");
             */
        }
Exemplo n.º 17
0
 public void SortInserts()
 {
     PrintProduct.SortInserts();
     LoadInserts();
 }
Exemplo n.º 18
0
 public void PrintBarcode(PrintProduct order)
 {
     frmBarcodePrinting barcodePrint = new frmBarcodePrinting(order, null);
     // barcodePrint.ShowDialog();
 }
Exemplo n.º 19
0
        public static void AssmPrintWriter(DatasetRAW dsr)
        {
            int count = 0;

            if (File.Exists(Paths.ExportAssemblyData))
            {
                File.Delete(Paths.ExportAssemblyData);
            }
            if (File.Exists(Paths.ExportDaily7))
            {
                File.Delete(Paths.ExportDaily7);
            }
            string dailyhours = Math.Round((dsr.AnnualAssemblyHours / 250), 2, MidpointRounding.AwayFromZero).ToString();

            try
            {
                using (StreamWriter sw = new StreamWriter(Paths.ExportRequired)) sw.Write(dailyhours);
                using (StreamWriter sw = File.CreateText(Paths.ExportAssemblyData))
                {
                    Util.SourceOfflineWarning(sw);
                    Util.JobberOfflineWarning(sw);
                    sw.WriteLine($"Assembly Schedule for {DateTime.Now.ToShortDateString()}{Br}{Util.Getj30} Days since June 30th, {Util.GetFiscalYear}{Br}");
                    sw.WriteLine("* Low Part quantity 0");
                    foreach (ProductCode code in dsr.ProductCodes)
                    {
                        count += 1;
                        int count2 = 0;
                        if (code.Products != null && code.Products.Count > 0)
                        {
                            sw.WriteLine($"These Items have less than {code.DayLimit} days supply.");
                            sw.WriteLine($" _{code.Productcode}________________________________________________________________________________________");
                            sw.WriteLine($"|Product|________________________|_Years_|__On__|__Days__|_Do_Not_|__Low___|_For_{code.DayLimit}{(code.DayLimit.ToString().Length > 3 ? string.Empty : "___".Remove(3 - code.DayLimit.ToString().Length))}|_________|");
                            sw.WriteLine("|__No.__|______Description_______|__Use__|_Hand_|_Supply_|_Exceed_|_Part #_|Day_Sply|__Hours__|");
                            foreach (ProductModel prod in code.Products)
                            {
                                PP      = new PrintProduct();
                                count2 += 1;
                                PP.Prod = Justify(prod.Number.ToString(), 0, S, 7, JustifyIs.center);
                                if (prod.ExtraData.LowPart != null)
                                {
                                    PP.Part = string.Format((prod.ExtraData.LowPart.Part.QuantityOnHand <= 0) ? "*{0}{1}*" : "{0}{1}", prod.ExtraData.LowPart.Part.PartTypePrefix, prod.ExtraData.LowPart.Part.PartNumber);
                                }
                                else
                                {
                                    PP.Part = "None";
                                }
                                PP.Part        = Justify(PP.Part, 0, S, 8, JustifyIs.center);
                                PP.Desc        = Justify(prod.Description, 0, S, 24, JustifyIs.left);
                                PP.YearsUse    = Justify(prod.AnnualUse.ToString("######0"), 0, S, 7, JustifyIs.right);
                                PP.OnHand      = Justify(prod.QuantityOnHand.ToString("#####0"), 0, S, 6, JustifyIs.right);
                                PP.DaysSupply  = Justify(prod.ExtraData.DaysSupply.ToString("#######0"), 0, S, 8, JustifyIs.right);
                                PP.DoNotExceed = Justify(prod.ExtraData.DoNotExceed.ToString("#######0"), 0, S, 8, JustifyIs.right);
                                PP.Need        = Justify(prod.ExtraData.Needed.ToString("#######0"), 0, S, 8, JustifyIs.right);
                                PP.Hour        = Justify(prod.ExtraData.NeededAssemblyHours.ToString("####0.##0"), 0, S, 9, JustifyIs.right);
                                sw.WriteLine($"|{PP.Prod}|{PP.Desc}|{PP.YearsUse}|{PP.OnHand}|{PP.DaysSupply}|{PP.DoNotExceed}|{PP.Part}|{PP.Need}|{PP.Hour}|");
                            }
                            sw.WriteLine($"|_{code.Productcode}___________________________|Hours_Assembled:{Justify(code.HoursAssembled.ToString("####0.0"), 0, L, 7, JustifyIs.right)}|________|_Total:_|{Justify(code.TotalNeeded.ToString(), 0, L, 7, JustifyIs.right)}_|{Justify(code.XdaysSupply.ToString(), 1, L, 9, JustifyIs.right)}|");
                            sw.WriteLine();
                        }
                    }
                    sw.WriteLine($"Hours of Assembled Inventory: {dsr.AssembledHours}         Hours to Assemble Years Use: {dsr.AnnualAssemblyHours:####0.0}{Br}Hours to produce needed products for a {dsr.ProductCodes[0].DayLimit}-Day supply: {dsr.XdaysSupply}");
                    sw.WriteLine(Environment.NewLine + Environment.NewLine);
                    sw.WriteLine($"Yesterday's Production Hours: {dsr.YesterdaysProductionHours}");
                    //TODO: Repiar Get Daily avg function, as used below.
                    //sw.WriteLine("Last Year, This Month, Daily Avg: " + Utilities.GetDailyAvg());
                    sw.WriteLine($"Required Daily Hours to Produce a 1-year Supply: {dailyhours.Trim()}");
                }
                if (dsr.ProductCodes.Count > 1)
                {
                    using (StreamWriter sw = new StreamWriter(Paths.ExportDaily7))
                    {
                        Util.SourceOfflineWarning(sw);
                        Util.JobberOfflineWarning(sw);
                        sw.WriteLine($"THESE PARTS ARE NOT MADE BY US BUT HAVE CYCLE TIMES.{Br}");
                        foreach (string part in dsr.Daily7Data.PartNumbers)
                        {
                            sw.Write($"{part} ");
                        }
                        sw.WriteLine($"{Br}{Br}{dsr.Daily7Data.HoursForYearsSales.Trim()} HOURS TO PRODUCE ALL PARTS FOR ESTIMATED SALES {Today}");
                        sw.WriteLine($"THERE MUST BE {dsr.Daily7Data.ProdHoursPerDay.Trim()} PRODUCTION HOURS PER DAY");
                        sw.WriteLine("THIS DOES NOT INCLUDE THE ASSEMBLY HOURS");
                        sw.WriteLine($"{dsr.Daily7Data.TotalHours.Trim()} TOTAL HOURS OF PARTS ON HAND {dsr.Daily7Data.AssembledHours.Trim()} ASSEMBLED.");
                        sw.WriteLine(Br + " ________________PARTS__________________       ________________PRODUCTS_______________");
                        sw.WriteLine("|_DAYS_|__HOURS_NEEDED__|_SURPLUS_HOURS_|     |_DAYS_|__HOURS_NEEDED__|_SURPLUS_HOURS_|");
                        sw.WriteLine($"| -30- | {Justify(dsr.Daily7Data.HoursNeeded30, S, 14, JustifyIs.right)} | {Justify(dsr.Daily7Data.SurplusHours30, S, 13, JustifyIs.right)} |     | -30- | {Justify(dsr.ProdHrNeedThirty.ToString(), S, 14, JustifyIs.right)} | {Justify(dsr.ProdSurplusHr30.ToString(), S, 13, JustifyIs.right)} |");
                        sw.WriteLine($"| -60- | {Justify(dsr.Daily7Data.HoursNeeded60, S, 14, JustifyIs.right)} | {Justify(dsr.Daily7Data.SurplusHours60, S, 13, JustifyIs.right)} |     | -60- | {Justify(dsr.ProdHrNeedSixty.ToString(), S, 14, JustifyIs.right)} | {Justify(dsr.ProdSurplusHr60.ToString(), S, 13, JustifyIs.right)} |");
                        sw.WriteLine($"| -90- | {Justify(dsr.Daily7Data.HoursNeeded90, S, 14, JustifyIs.right)} | {Justify(dsr.Daily7Data.SurplusHours90, S, 13, JustifyIs.right)} |     | -90- |                | {Justify(dsr.ProdSurplusHr90.ToString(), S, 13, JustifyIs.right)} |");
                        sw.WriteLine("|______|________________|_______________|     |______|________________|_______________|");
                        sw.WriteLine(" _______________________ _______________________");
                        sw.WriteLine("|   Daily Production    | Yesterdays Production |");
                        sw.WriteLine("|   Hours Required to   |         Hours         |");
                        sw.WriteLine("|Produce a 1-Year Supply|                       |");
                        sw.WriteLine($"| {Justify(dailyhours, S, 21, JustifyIs.center)} | {Justify(dsr.YesterdaysProductionHours.ToString("####.##"), S, 21, JustifyIs.center)} | ");
                        sw.WriteLine("|_______________________|_______________________|");
                        sw.WriteLine(Br + "SEE INVENTORY PRINTOUT FOR ITEMS THAT ARE IN SURPLUS" + Br);
                        sw.WriteLine($"Hours of Assembled Inventory: {dsr.AssembledHours}         Hours to Assemble Years Use: {dsr.AnnualAssemblyHours}{Br}Hours to produce needed products for a {dsr.ProductCodes[0].DayLimit}-Day supply: {dsr.XdaysSupply}");
                    }
                    if (File.Exists(Paths.ExportDaily7))
                    {
                        Process.Start("notepad.exe", Paths.ExportDaily7);
                        Thread.Sleep(100);
                    }
                }
                if (File.Exists(Paths.ExportAssemblyData))
                {
                    Process.Start("notepad.exe", Paths.ExportAssemblyData);
                }
            }
            catch (Exception e) { ErrorWriter("At Writer." + Environment.NewLine + e.Message + Br + e.StackTrace); Environment.Exit(0); }
        }
Exemplo n.º 20
0
        private void repositoryItemSpinEditADRate_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            switch (e.Button.Index)
            {
            case 1:
            {
                advBandedGridViewPublication.CloseEditor();
                double temp;
                var    value = advBandedGridViewPublication.GetFocusedRowCellValue(advBandedGridViewPublication.FocusedColumn);
                if (value == null)
                {
                    return;
                }
                if (!double.TryParse(value.ToString(), out temp))
                {
                    return;
                }
                PrintProduct.CopyAdRate(temp);
                LoadInserts();
            }
            break;

            case 2:
            {
                advBandedGridViewPublication.CloseEditor();
                var selectedInsert = advBandedGridViewPublication.GetFocusedRow() as Insert;
                if (selectedInsert == null)
                {
                    return;
                }
                using (var form = new FormAdNotes())
                {
                    form.laID.Text        = selectedInsert.ID;
                    form.laDate.Text      = selectedInsert.Date.HasValue ? selectedInsert.Date.Value.ToString("ddd, MM/dd/yy") : String.Empty;
                    form.Date             = selectedInsert.Date.HasValue ? selectedInsert.Date.Value : DateTime.MinValue;
                    form.laFinalRate.Text = selectedInsert.FinalRate.ToString("$#,###.00");
                    form.CustomComment    = selectedInsert.CustomComment;
                    form.Comments         = selectedInsert.Comments.ToArray();
                    form.CustomSection    = selectedInsert.CustomSection;
                    form.Sections         = selectedInsert.Sections.ToArray();
                    form.Deadline         = selectedInsert.Deadline;
                    form.Mechanicals      = selectedInsert.Mechanicals;

                    if (PrintProduct.Inserts.Count > 1)
                    {
                        var selectDays = new Action <AdNotesDaysSelector, string, string>((daysSelectorContainer, formCaption, header) =>
                            {
                                using (var dateSelector = new FormDateSelector())
                                {
                                    dateSelector.Text         = formCaption;
                                    dateSelector.laTitle.Text = header;
                                    foreach (var insert in PrintProduct.Inserts.Where(i => i != selectedInsert && i.Date.HasValue))
                                    {
                                        dateSelector.checkedListBoxControlDates.Items.Add(insert.Date.Value, String.Format("{0}   {1}", insert.Date.Value.ToString("ddd, MM/dd/yy"), insert.FinalRate.ToString("$#,###.00")), form.adNotesDaysSelectorComments.SelectedDays.Contains(insert.Date.Value) ? CheckState.Checked : CheckState.Unchecked, true);
                                    }
                                    if (dateSelector.ShowDialog() != DialogResult.OK)
                                    {
                                        return;
                                    }
                                    daysSelectorContainer.SelectedDays.Clear();
                                    foreach (var item in dateSelector.checkedListBoxControlDates.Items.Cast <CheckedListBoxItem>().Where(item => item.CheckState == CheckState.Checked))
                                    {
                                        daysSelectorContainer.SelectedDays.Add((DateTime)item.Value);
                                    }
                                }
                            });
                        form.adNotesDaysSelectorComments.buttonXApplyOtherDays.Click += (obj, args) => selectDays(form.adNotesDaysSelectorComments,
                                                                                                                  "Comments & Publications",
                                                                                                                  "Do you want to add these comments to other days in your schedule?"
                                                                                                                  );
                        form.adNotesDaysSelectorSections.buttonXApplyOtherDays.Click += (obj, args) => selectDays(form.adNotesDaysSelectorSections,
                                                                                                                  "Sections",
                                                                                                                  "Do you want to add these sections to other days in your schedule?"
                                                                                                                  );
                        form.adNotesDaysSelectorDeadlines.buttonXApplyOtherDays.Click += (obj, args) => selectDays(form.adNotesDaysSelectorDeadlines,
                                                                                                                   "Deadlines",
                                                                                                                   "Do you want to add these deadlines to other days in your schedule?"
                                                                                                                   );
                        form.adNotesDaysSelectorMechanicals.buttonXApplyOtherDays.Click += (obj, args) => selectDays(form.adNotesDaysSelectorMechanicals,
                                                                                                                     "Mechanicals",
                                                                                                                     "Do you want to add these mechanicals to other days in your schedule?"
                                                                                                                     );
                    }
                    else
                    {
                        form.adNotesDaysSelectorComments.Visible    = false;
                        form.adNotesDaysSelectorSections.Visible    = false;
                        form.adNotesDaysSelectorDeadlines.Visible   = false;
                        form.adNotesDaysSelectorMechanicals.Visible = false;
                    }

                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    selectedInsert.CustomComment = form.CustomComment;
                    selectedInsert.Comments.Clear();
                    selectedInsert.Comments.AddRange(form.Comments);
                    if (form.adNotesDaysSelectorComments.SelectedDays.Any())
                    {
                        var selectedDays = form.adNotesDaysSelectorComments.SelectedDays;
                        foreach (var insert in PrintProduct.Inserts.Where(insert => insert.Date.HasValue && selectedDays.Contains(insert.Date.Value)))
                        {
                            insert.CustomComment = form.CustomComment;
                            insert.Comments.Clear();
                            insert.Comments.AddRange(form.Comments);
                        }
                    }

                    selectedInsert.CustomSection = form.CustomSection;
                    selectedInsert.Sections.Clear();
                    selectedInsert.Sections.AddRange(form.Sections);
                    if (form.adNotesDaysSelectorSections.SelectedDays.Any())
                    {
                        var selectedDays = form.adNotesDaysSelectorSections.SelectedDays;
                        foreach (var insert in PrintProduct.Inserts.Where(insert => insert.Date.HasValue && selectedDays.Contains(insert.Date.Value)))
                        {
                            insert.CustomSection = form.CustomSection;
                            insert.Sections.Clear();
                            insert.Sections.AddRange(form.Sections);
                        }
                    }

                    selectedInsert.Deadline = form.Deadline;
                    if (form.adNotesDaysSelectorDeadlines.SelectedDays.Any())
                    {
                        var selectedDays = form.adNotesDaysSelectorDeadlines.SelectedDays;
                        foreach (var insert in PrintProduct.Inserts.Where(insert => insert.Date.HasValue && selectedDays.Contains(insert.Date.Value)))
                        {
                            insert.Deadline = form.Deadline;
                        }
                    }

                    selectedInsert.Mechanicals = form.Mechanicals;
                    if (form.adNotesDaysSelectorMechanicals.SelectedDays.Any())
                    {
                        var selectedDays = form.adNotesDaysSelectorMechanicals.SelectedDays;
                        foreach (var insert in PrintProduct.Inserts.Where(insert => insert.Date.HasValue && selectedDays.Contains(insert.Date.Value)))
                        {
                            insert.Mechanicals = form.Mechanicals;
                        }
                    }

                    LoadInserts();

                    Controller.Instance.PrintProductContainer.SettingsNotSaved = true;
                }
            }
            break;
            }
        }