Exemplo n.º 1
0
        /* public void ConvertHTMLtoPDF(PurchaseOrdersItem response, Warehouses wh)
         * {
         *  var readFile = AppDomain.CurrentDomain.BaseDirectory + @"Bill\Page.html";
         *
         *  var html = System.IO.File.ReadAllText(readFile);
         *  var warehouse = wh.Items.Count > 0 ? wh.Items.SingleOrDefault() : new Warehouse();
         *
         *
         *  var logoPath = AppDomain.CurrentDomain.BaseDirectory + @"bill\customhtml.html";
         *  string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
         *  string requiredDate = string.Empty;
         *  string orderDate = string.Empty;
         *  string orderNumber = string.Empty;
         *  string supplierCode = string.Empty;
         *  string referenceNumber = string.Empty;
         *  //string subTotal = string.Empty;
         *  //string taxTotal = string.Empty;
         *  //string completeTotal = string.Empty;
         *  StringBuilder sBuilder = new StringBuilder();
         *  var item = response;
         *
         *  requiredDate = item.RequiredDate.ToString("dd/MM/yyyy");
         *  orderDate = item.OrderDate.ToString("dd/MM/yyyy");
         *  orderNumber = item.OrderNumber;
         *  supplierCode = item.Supplier == null ? "" : item.Supplier.SupplierCode;
         *  referenceNumber = item.Guid;
         *  double subTotal = item.SubTotal ?? 0;
         *  double taxTotal = item.TaxTotal ?? 0;
         *  double completeTotal = item.Total ?? 0;
         *
         *  html = html.Replace("##DeliveryName##", warehouse == null ? "" : warehouse.StreetNo);
         *  html = html.Replace("##StreetAddress##", warehouse == null ? "" : warehouse.AddressLine1);
         *  html = html.Replace("##Suburb##", warehouse == null ? "" : warehouse.AddressLine2);
         *  html = html.Replace("##State##", warehouse == null ? "" : warehouse.Region);
         *  html = html.Replace("##PostalCode##", warehouse == null ? "" : warehouse.PostCode);
         *  html = html.Replace("##SupCode##", supplierCode);
         *  html = html.Replace("##PhoneNumber##", warehouse == null ? "" : warehouse.PhoneNumber);
         *
         *  foreach (var item1 in item.PurchaseOrderLines)
         *  {
         *      var Product = CommonCode.GetProductInformation(item1.Product != null ? item1.Product.ProductCode : "");
         *      var suppCode = (Product.Items.Count > 0 && Product.Items.FirstOrDefault().Supplier != null) ? Product.Items.FirstOrDefault().Supplier.SupplierProductCode : "";
         *      string lineNumber = item1.LineNumber.ToString();
         *      string productCode = item1.Product.ProductCode;
         *      string productDescription = item1.Product.ProductDescription;
         *      string quantity = item1.OrderQuantity.ToString();
         *      string units = item1.Product != null && item1.Product.UnitOfMeasure != null ? item1.Product.UnitOfMeasure.Name : "";
         *      double unitPrice = item1.UnitPrice ?? 0;
         *      double amount = item1.LineTotal ?? 0;
         *      double tax = item1.LineTax ?? 0;
         *      string htmlFormat = string.Format("<tr style='border-bottom:2px solid #ddd;'><th style = 'padding: 5px 0; border-bottom:1px solid #ddd;'><p style = 'margin:0; font-weight:normal; font-size: 13px;' >{0}</p></th>"
         + "<th style = 'padding:5px 0; border-bottom:1px solid #ddd;'><p style = 'margin:0; font-weight:normal;font-size: 13px;'>{1}</p></th>"
         + "<th style = 'padding:5px 0; border-bottom:1px solid #ddd;'><p style = 'margin:0; font-weight:normal;font-size: 13px;'> {2} </p></th>"
         + "<th style = 'padding:5px 0; border-bottom:1px solid #ddd;'><p style = 'margin:0; font-weight:normal;font-size: 13px;'> {3}</p></th>"
         + "<th style = 'padding:5px 0; border-bottom:1px solid #ddd;'><p style = 'margin:0; font-weight:normal;font-size: 13px;'> {4} </p></th>"
         + "<th style = 'padding:5px 0; border-bottom:1px solid #ddd;'><p style = 'margin:0; font-weight:normal;font-size: 13px;'> {5} </p></th>"
         + "<th style = 'padding:5px 0; border-bottom:1px solid #ddd;'><p style = 'margin:0; font-weight:normal;font-size: 13px;'> {6} </p></th>"
         + "<th style = 'padding:5px 0; border-bottom:1px solid #ddd;'><p style = 'margin:0; font-weight:normal;font-size: 13px;'> {7} </p></th>"
         + "<th style = 'padding:5px 0; border-bottom:1px solid #ddd;'><p style = 'margin:0; font-weight:normal;font-size: 13px;'> {8} </p></th></tr>", lineNumber, suppCode, productCode, productDescription, quantity, units, unitPrice.ToString("0.00"), amount.ToString("0.00"), tax.ToString("0.00")
         +                             );
         +      sBuilder.Append(htmlFormat);
         +  }
         +
         +  html = html.Replace("##RequiredDate##", requiredDate);
         +  html = html.Replace("##OrderDate##", orderDate);
         +  html = html.Replace("##OrderNumber##", orderNumber);
         +  html = html.Replace("##SupplierCode##", supplierCode);
         +  html = html.Replace("##ReferenceNumber##", referenceNumber);
         +  html = html.Replace("##ReplaceBodyContent##", sBuilder.ToString());
         +
         +  html = html.Replace("##SubTotal##", subTotal.ToString("0.00"));
         +  html = html.Replace("##TaxTotal##", taxTotal.ToString("0.00"));
         +  html = html.Replace("##CompleteTotal##", completeTotal.ToString("0.00"));
         +  html = html.Replace("##Instruments##", item.Supplier.SupplierName);
         +  html = html.Replace("##Comments##", item.Comments);
         +  System.IO.File.WriteAllText(logoPath, html);
         +
         +  SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf();
         +  converter.Options.MarginRight = 5;
         +  converter.Options.MarginLeft = 5;
         +  SelectPdf.PdfDocument doc = converter.ConvertUrl(logoPath);
         +  string WriteExcel = path + "//Purchase Orders";
         +  if (!Directory.Exists(WriteExcel))
         +  {
         +      Directory.CreateDirectory(WriteExcel);
         +  }
         +  //string excelFile = WriteExcel + "//Purchase Order_" + item.OrderNumber + "_" + DateTime.Now.ToShortDateString().Replace("/", ".") + "_" + DateTime.Now.ToShortTimeString().Replace(":", ".").Replace(" ", "") + "_Excel" + ".pdf";
         +  string excelFile = WriteExcel + "//Purchase Order_" + item.OrderNumber + "_" + DateTime.Now.ToString("yyyy.dd.MM").Replace("/", ".") + "-" + item.Supplier.SupplierName.Replace("/", "_") + ".pdf";
         +  doc.Save(excelFile);
         +  doc.Close();
         + } */

        private void UnleashedData_CurrentCellDirtyStateChanged(object sender, EventArgs e)
        {
            if (UnleashedData.IsCurrentCellDirty)
            {
                UnleashedData.CommitEdit(System.Windows.Forms.DataGridViewDataErrorContexts.Commit);
            }
        }
Exemplo n.º 2
0
        private void UnleashedData_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            System.Windows.Forms.DataGridView.HitTestInfo testInfo = UnleashedData.HitTest(e.X, e.Y);

            //Need to check to make sure that the row index is 0 or greater as the first
            //row is a zero and where there is no rows the row index is a -1
            if (testInfo.RowIndex >= 0 && testInfo.RowIndex != previousRow)
            {
                //UnleashedData.Rows[previousRow].Selected = false;
                //UnleashedData.Rows[testInfo.RowIndex].Selected = true;
                //previousRow = testInfo.RowIndex;
                //UnleashedData.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.Blue;
            }
        }
Exemplo n.º 3
0
        private void UnleashedData_CellValueChanged(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 4 && e.RowIndex != -1)
            {
                // Handle checkbox state change here
                if (UnleashedData.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "True")
                {
                    //do something
                    string supplier     = UnleashedData.Rows[e.RowIndex].Cells[6].Value.ToString();
                    string productgroup = UnleashedData.Rows[e.RowIndex].Cells[14].Value.ToString();
                    if (glbSupplier == string.Empty || glbSupplier == supplier)
                    {
                        glbSupplier = supplier;
                    }
                    else
                    {
                        MessageBox.Show("Please choose same supplier.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                        UnleashedData.Rows[e.RowIndex].Cells[4].Value = false;
                        UnleashedData.CancelEdit();
                    }

                    if (glbProduct == string.Empty || glbProduct == productgroup)
                    {
                        switch (productgroup)
                        {
                        case "Meters":
                            glbWarehouse = "MWF";
                            break;

                        case "Sensors":
                            glbWarehouse = "MWQ";
                            break;

                        case "Projects":
                            glbWarehouse = "Projects";
                            break;

                        default:
                            break;
                        }
                        glbProduct = productgroup;
                    }
                    else
                    {
                        MessageBox.Show("Please choose same product group.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                        UnleashedData.Rows[e.RowIndex].Cells[4].Value = false;
                        UnleashedData.CancelEdit();
                    }
                }
                else
                {
                    //do something
                    int encountercheck = 0;
                    foreach (System.Windows.Forms.DataGridViewRow row in UnleashedData.Rows)
                    {
                        System.Windows.Forms.DataGridViewCheckBoxCell chk = (System.Windows.Forms.DataGridViewCheckBoxCell)row.Cells[4];
                        if (chk.Value != null)
                        {
                            bool checkTrue = (bool)chk.Value; //because chk.Value is initialy null
                            if (checkTrue)
                            {
                                encountercheck = 1;
                            }
                        }
                    }
                    if (encountercheck == 0)
                    {
                        glbSupplier = string.Empty;
                        glbProduct  = string.Empty;
                    }
                }
            }
        }
Exemplo n.º 4
0
 private void UnleashedData_CellContentClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
 {
     UnleashedData.CommitEdit(System.Windows.Forms.DataGridViewDataErrorContexts.Commit);
 }