예제 #1
0
    private void PopulateGrid()
    {
        try
        {
            if (!(string.IsNullOrEmpty(fromDate.Value) && string.IsNullOrEmpty(toDate.Value)))
            {
                if (txtSearch.Text.Trim() != "Search")
                {
                    objPI.SearchText = txtSearch.Text.Trim();
                }
                else
                {
                    objPI.SearchText = "";
                }



                if (objPI.SortDirection == null && objPI.SortColumnName == null)
                {
                    objPI.SortDirection = Convert.ToString(ViewState[Constants.SORTDERECTION]);
                    objPI.SortColumnName = Convert.ToString(ViewState[Constants.SORTCOLUMNNAME]);
                }
                SaleBLL objSaleBLL = new SaleBLL();

                List<Sale> objData = new List<Sale>();
                objData = objSaleBLL.GetAllSaleDetailsDataByDate(objData, objPI, fromDate.Value, toDate.Value);

                gvGrid.DataSource = objData;
                gvGrid.ExportTemplate = "export_template_4Column.xlsx";
                gvGrid.ExportCaption = "";
                gvGrid.ExcelColumn = "";
                gvGrid.DataBind();

                if (null != objData)
                {
                    decimal sumBanAmount = (from od in objData
                                            select od.BankAmount).Sum();
                    spBanContact.InnerHtml = String.Format("{0:0,0.0}", sumBanAmount);

                    decimal sumCCAmount = (from od in objData
                                            select od.CCAmount).Sum();
                    spVisa.InnerHtml = String.Format("{0:0,0.0}", sumCCAmount);

                    decimal sumCashAmount = (from od in objData
                                            select od.Cash).Sum();
                    spCash.InnerHtml = String.Format("{0:0,0.0}", sumCashAmount);
                }
            }
        }
        catch (Exception ex)
        {
            SendMail.MailMessage("CSWeb > Error > " + (new StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString());
        }
    }
예제 #2
0
    private void PopulateGrid()
    {
        try
        {
            if (!(string.IsNullOrEmpty(fromDate.Value) && string.IsNullOrEmpty(toDate.Value)))
            {
                if (txtSearch.Text.Trim() != "Search")
                {
                    objPI.SearchText = txtSearch.Text.Trim();
                }
                else
                {
                    objPI.SearchText = "";
                }



                if (objPI.SortDirection == null && objPI.SortColumnName == null)
                {
                    objPI.SortDirection = Convert.ToString(ViewState[Constants.SORTDERECTION]);
                    objPI.SortColumnName = Convert.ToString(ViewState[Constants.SORTCOLUMNNAME]);
                }
                SaleBLL objSaleBLL = new SaleBLL();

                List<Sale> objData = new List<Sale>();
                objData = objSaleBLL.GetAllSaleDataByDate(objData, objPI, fromDate.Value, toDate.Value);

                gvGrid.DataSource = objData;
                gvGrid.ExportTemplate = "export_template_4Column.xlsx";
                gvGrid.ExportCaption = "";
                gvGrid.ExcelColumn = "";
                gvGrid.DataBind();

                if (null != spAmount)
                {
                    decimal sumLineTotal = (from od in objData
                                            select od.FinalPayableAmount).Sum();
                    spAmount.InnerHtml =String.Format("{0:0,0.0}", sumLineTotal);
                }
                if (((User)Session["UserData"]).UserTypeID == (int)Constants.UserType.SellingDesk)
                {
                    gvGrid.Columns[6].Visible = false;
                }
            }
        }
        catch (Exception ex)
        {
            SendMail.MailMessage("CSWeb > Error > " + (new StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString());
        }
    }
예제 #3
0
    protected void gvGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Delete")
            {

                Message vobjMsg = new Message();
                int intUserID = ((User)Session["UserData"]).UserID;
                int intSaleID = Convert.ToInt32(e.CommandArgument.ToString());
                Sale objSale = new Sale();
                SaleBLL objUBLL = new SaleBLL();

                vobjMsg = objUBLL.DeleteSale(intSaleID, intUserID);

                if (vobjMsg.ReturnValue > 0)
                {
                    divMess.Visible = true;
                    lblMsg.Text = Constants.Deleted;
                    divMess.Attributes.Add("class", "Deleted");
                    lblMsg.Style.Add("color", "Black");
                }
                else
                {
                    divMess.Visible = true;
                    lblMsg.Style.Add("color", "Red");
                    divMess.Attributes.Add("class", "error");
                    lblMsg.Text = vobjMsg.ReturnMessage;
                }
            }



        }
        catch (Exception ex)
        {
            SendMail.MailMessage("CSWeb > Error > " + (new StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString());
        }
    }
예제 #4
0
    private void PopulateBarCode(int PurchaseID)
    {
        try
        {
            StringBuilder sbBarcode = new StringBuilder();
            string thisBarcode = string.Empty;
            if (txtSearch.Text.Trim() != "Search")
            {
                objPI.SearchText = txtSearch.Text.Trim();
            }
            else
            {
                objPI.SearchText = "";
            }


            SaleBLL objSaleBLL = new SaleBLL();

            List<Sale> objData = new List<Sale>();
            objData = objSaleBLL.GetAllProductBarCode(objPI, PurchaseID);

            if (objData != null)
            {
                int Kounter = 0;
                for (int i = 0; i < objData.Count; i++)
                {
                    int PurchaseQuantity =(int)objData[i].Quantity;
                    
                    for (int ii = 0; ii < PurchaseQuantity; ii++)
                    {
                        thisBarcode = BarcodeHTML;
                        thisBarcode = thisBarcode.Replace("[brandname]", objData[i].Brand);
                        thisBarcode = thisBarcode.Replace("[productname]", objData[i].ProductName);
                        thisBarcode = thisBarcode.Replace("[productsize]", objData[i].SizeName);
                        thisBarcode = thisBarcode.Replace("[sellingprice]", string.Format("{0:0.00}", objData[i].Price));
                        string BarCode = objData[i].BarCode;
                        thisBarcode = thisBarcode.Replace("[dvbarcode]", "dvbarcode" + (Kounter + 1).ToString());
                        thisBarcode = thisBarcode.Replace("[barcode]", BarCode);
                        thisBarcode = thisBarcode.Replace("[dvbarcodePrint]", "dvbarcodePrint" + (Kounter + 1).ToString());
                        thisBarcode = thisBarcode.Replace("[barcodePrint]", "[barcodePrint" + (Kounter + 1).ToString() + "]");
                        thisBarcode = thisBarcode.Replace("[QuantityID]", "txtQuantity" + (Kounter + 1).ToString());
                        //thisBarcode = thisBarcode.Replace("[chkPrint]", "chkPrint" + (Kounter + 1).ToString());
                        thisBarcode = thisBarcode.Replace("[imageID]", "PrinterID" + (Kounter + 1).ToString());
                        thisBarcode = thisBarcode.Replace("[thisID]", (Kounter + 1).ToString());
                        sbBarcode.Append(thisBarcode);
                        Kounter++;
                    }
                    
                }
            }

            dvBarcodes.InnerHtml = sbBarcode.ToString();
        }
        catch (Exception ex)
        {
            SendMail.MailMessage("CSWeb > Error > " + (new StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString());
        }
    }
    private void SaveData()
    {

        try
        {

            Sale objSale = new Sale();
            SaleBLL objSBLL = new SaleBLL();
            objSale.SaleID = SaleID;
            objSale.CustomerID = (string.IsNullOrEmpty(Customerid.Value.Trim()) ? 0 : Convert.ToInt32(Customerid.Value.Trim()));
            objSale.CFirstName = Customer.Text.Trim();
            objSale.Address = txtAddress.Text.Trim();
            objSale.City = txtCity.Text.Trim();
            objSale.ZIP = txtZIP.Text.Trim();
            objSale.Country = txtCountry.Text.Trim();
            objSale.Email = txtEmailID.Text.Trim();
            objSale.SaleNote = txtSaleNote.Text.Trim();
            objSale.TeleNumber = txtPhone.Text.Trim();
            objSale.CCAmount = (string.IsNullOrEmpty(txtAmountPaid.Text.Trim()) ? 0 : Convert.ToDecimal(txtAmountPaid.Text.Trim()));
            objSale.BankAmount = (string.IsNullOrEmpty(txtBCash.Text.Trim()) ? 0 : Convert.ToDecimal(txtBCash.Text.Trim()));
            objSale.Cash = (string.IsNullOrEmpty(txtCash.Text.Trim()) ? 0 : Convert.ToDecimal(txtCash.Text.Trim()));
            objSale.Discount = (string.IsNullOrEmpty(txtDiscount.Text.Trim()) ? 0 : Convert.ToDecimal(txtDiscount.Text.Trim()));
            objSale.FinalDiscountType = ddlFdiscount.SelectedValue.ToString();
            objSale.FinalDiscount = Convert.ToDecimal(txtFDiscount.Text.Trim());
            objSale.FinalPayableAmount = Convert.ToDecimal(txtFinalAmount.Text.Trim());
            objSale.SaleMadeBy = ((User)Session["UserData"]).UserID;
            objSale.ThisSaleDate = SaleDate;

            Message objMessage = objSBLL.InsertUpdateSaleMaster(objSale);
            if (objMessage.ReturnValue > 0)
            {
                objSale.SaleID = objMessage.ReturnValue;
                objMessage = objSBLL.DeleteExistingSalesDetails(objSale);
                for (int i = 0; i < dtProductDetail.Rows.Count; i++)
                {

                    objSale.ProductID = Convert.ToInt32(dtProductDetail.Rows[i]["ProductID"].ToString());
                    objSale.SizeID = Convert.ToInt32(dtProductDetail.Rows[i]["SizeID"].ToString());
                    objSale.Quantity = Convert.ToDecimal(dtProductDetail.Rows[i]["Quantity"].ToString());
                    objSale.Discount = Convert.ToDecimal(dtProductDetail.Rows[i]["PDiscount"].ToString());
                    objSale.DiscountType = dtProductDetail.Rows[i]["DiscountType"].ToString();
                    objSale.Price = Convert.ToDecimal(dtProductDetail.Rows[i]["Unit"].ToString());

                    objMessage = objSBLL.InsertUpdateSaleDetail(objSale);
                }

            }
        }
        catch (Exception ex)
        {
            SendMail.MailMessage("CSWeb > Error > " + (new System.Diagnostics.StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString());
        }
    }
 private void PopulateCustomer()
 {
     try
     {
         SaleBLL objSaleBLL = new SaleBLL();
         DataTable dtData = objSaleBLL.GetAllCustomerNameForAutoComplete();
         if (null != dtData && dtData.Rows.Count > 0)
         {
             hdnCustData.Value = "";
             for (int i = 0; i < dtData.Rows.Count; i++)
             {
                 hdnCustData.Value += dtData.Rows[i]["CustomerID"].ToString() + "##" + dtData.Rows[i]["CustomerName"].ToString() + "##" + dtData.Rows[i]["Address"].ToString() + "@@";
             }
             if (hdnCustData.Value.Length > 0)
             {
                 hdnCustData.Value = hdnCustData.Value.Substring(0, hdnCustData.Value.Length - 2);
             }
         }
     }
     catch (Exception ex)
     {
         SendMail.MailMessage("CSWeb > Error > " + (new System.Diagnostics.StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString());
     }
 }
    private void PopulateFinalSaleDetail(int SaleID)
    {
        Sale objSale = new Sale();
        objSale.SaleID = SaleID;
        SaleBLL objSBLL = new SaleBLL();
        objSale = objSBLL.GetFinalCheckOutDeatils(ref objSale);

        Customer.Text = objSale.CFirstName;
        txtAddress.Text = objSale.Address;
        txtZIP.Text = objSale.ZIP;
        txtCity.Text = objSale.City;
        txtCountry.Text = objSale.Country;
        txtPhone.Text = objSale.TeleNumber;
        txtEmailID.Text = objSale.Email;
        txtAmountPaid.Text = objSale.CCAmount.ToString();
        txtBCash.Text = objSale.BankAmount.ToString();
        txtCash.Text = objSale.Cash.ToString();
        txtDiscount.Text = txtDiscount.Text = string.Format("{0:0.00}", objSale.Discount);
        txtSaleNote.Text = objSale.SaleNote;

        ddlFdiscount.SelectedValue = objSale.FinalDiscountType.ToString();
        txtFDiscount.Text = objSale.FinalDiscount.ToString();

        txtFinalAmount.Text = objSale.FinalPayableAmount.ToString();
    }
 private void PopulateAutoCompleteDataTable()
 {
     SaleBLL objSaleBLL = new SaleBLL();
     dtAutoComplete = objSaleBLL.SearchProductAutoCompleteForPurchase();
     PopulateAutoCompleteProductInformation();
 }
예제 #9
0
    private void PopulateBarCode(int PurchaseID)
    {
        //Rectangle pageSize = new Rectangle(842, 595);
        Rectangle pageSize = new Rectangle(62,29);
        //Document document = new Document(PageSize.A4_LANDSCAPE, 10, 10, 10, 10);
        Document document = new Document(pageSize, 0, 0, 2, 0);
        string TimeStamp = DateTime.Now.Ticks.ToString();
        try
        {
            StringBuilder sbBarcode = new StringBuilder();
            string thisBarcode = string.Empty;

            objPI.SearchText = "";

            SaleBLL objSaleBLL = new SaleBLL();

            List<Sale> objData = new List<Sale>();
            objData = objSaleBLL.GetAllProductBarCode(objPI, PurchaseID);


            PdfWriter pdfWriter = PdfWriter.GetInstance(document, new FileStream(Server.MapPath("~") + "/Handler/BarCode_" + TimeStamp + ".pdf", FileMode.Create));
            document.Open();
            PdfContentByte pdfContentByte = pdfWriter.DirectContent;
            iTextSharp.text.Image img;

            if (objData != null)
            {
                int Kounter = 0;
                for (int i = 0; i < objData.Count; i++)
                {
                    int PurchaseQuantity = (int)objData[i].Quantity;

                    for (int ii = 0; ii < PurchaseQuantity; ii++)
                    {
                        if (Kounter > 0)
                            document.NewPage();

                        PdfPTable table = new PdfPTable(2);
                        //table.TotalWidth = 176f;
                        //fix the absolute width of the table
                        //table.LockedWidth = true;

                        //relative col widths in proportions
                        //float[] widths = new float[] { 1f, 1f };
                        //table.SetWidths(widths);
                        table.HorizontalAlignment = 1;
                        //leave a gap before and after the table
                        //table.SpacingBefore = 1f;
                        //table.SpacingAfter = 1f;
                        table.WidthPercentage = 95;

                        PdfPCell cell = new PdfPCell(new Phrase(objData[i].Brand, new Font(Font.FontFamily.HELVETICA, 3f, Font.BOLD)));
                        cell.Colspan = 2;
                        cell.Border = 0;
                        cell.Padding = 0f;
                        cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                        table.AddCell(cell);

                        cell = new PdfPCell(new Phrase(objData[i].ProductName, new Font(Font.FontFamily.HELVETICA, 2f, Font.NORMAL)));
                        cell.Colspan = 2;
                        cell.Border = 0;
                        cell.Padding = 0f;
                        cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                        table.AddCell(cell);

                        cell = new PdfPCell(AddSize(objData[i].SizeName));
                        cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                        cell.Border = 0;
                        cell.Padding = 0f;
                        table.AddCell(cell);

                        cell = new PdfPCell(new Phrase("€ " + string.Format("{0:0.00}", objData[i].Price), new Font(Font.FontFamily.HELVETICA, 4f, Font.BOLD)));
                        cell.HorizontalAlignment = 2; //0=Left, 1=Centre, 2=Right
                        cell.Border = 0;
                        cell.Padding = .5f;
                        table.AddCell(cell);

                        pdfContentByte = pdfWriter.DirectContent;
                        img = GetBarcode128(pdfContentByte, objData[i].BarCode, false, Barcode.CODE128);

                        cell = new PdfPCell(); //new Phrase(new Chunk(img, 0, 0)));
                        cell.AddElement(img);
                        cell.Colspan = 2;
                        cell.Border = 0;
                        cell.Padding = 0f;
                        //cell.FixedHeight = img.Height + 200;
                        cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                        table.AddCell(cell);

                        document.Add(table);

                        Kounter++;
                    }

                }
                document.Close();

            }

            HttpContext context = HttpContext.Current;
            Response.Clear();
            Response.ContentType = "application/pdf";
            Response.AppendHeader("Content-Disposition", "attachment; filename=Barcode_" + TimeStamp + ".pdf");
            Response.WriteFile(Server.MapPath("~/Handler/BarCode_" + TimeStamp + ".pdf"));
            Response.Flush();
            Response.Close();
            if (File.Exists(Server.MapPath("~/Handler/BarCode_" + TimeStamp + ".pdf")))
            {
                File.Delete(Server.MapPath("~/Handler/BarCode_" + TimeStamp + ".pdf"));
            }

        }
        catch (Exception ex)
        {
            if (document.IsOpen())
                document.Close();
            SendMail.MailMessage("CSWeb > Error > " + (new StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString());
            Response.Write(ex.ToString());
        }
    }
예제 #10
0
    private void AddDataToDataTable()
    {
        try
        {
            SaleBLL objSBLL = new SaleBLL();
            //List<Sale> objSale = objSBLL.GetProductDetailByBarCode(Productid.Value.Trim());
            List<Sale> objSale = objSBLL.GetProductInfoByBarCode(txtProductBarCode.Text.Trim());
            RepopulateDataTableWithDiscountPrice();
            if (null != objSale && objSale.Count > 0)
            {
                InsertDataintoTempDataTable(objSale[0], true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "PopulateType", "Populate('1')", true);

                lblError.InnerHtml = "Product Bar Code not found";
            }
        }
        catch (ConstraintException ex)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "PopulateType", "Populate('1')", true);
            lblError.InnerHtml = "Product already added or select different size";
        }
        catch (Exception ex)
        {
            SendMail.MailMessage("CSWeb > Error > " + (new System.Diagnostics.StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString());
        }
    }
예제 #11
0
    private void PopulateSaleDetail(int intSaleID)
    {
        Sale objSale = new Sale();
        objSale.SaleID = intSaleID;
        SaleBLL objSBLL = new SaleBLL();
        List<Sale> objLSale = new List<Sale>();
        objLSale = objSBLL.GetSaleDetailBySaleID(objSale);
        if (null != objLSale)
        {
            for (int i = 0; i < objLSale.Count; i++)
            {
                InsertDataintoTempDataTable(objLSale[i], false);
            }
        }
        PopulateProductDetail();
        CalculateTotalPrice();
        txtProductBarCode.Text = "";
        txtQuantity.Text = "";
        ScriptManager.RegisterStartupScript(this, this.GetType(), "PopulateType", "Populate('1')", true);

    }