private void onLoadBuy(object sender, EventArgs e)
        {
            try
            {
                bool isExist = ShopDAL.isItemTypeExists();
                if (isExist)
                {
                    ShopDAL dal = new ShopDAL();
                    DataSet ds  = dal.GetItemsType();
                    cmbItemType.DataSource    = ds.Tables[0];
                    cmbItemType.DisplayMember = "Name";
                    cmbItemType.ValueMember   = "Type_ID";
                }

                DataSet dsContractor = ContractorDAL.getContractorsDs();
                DataRow defaultRow   = dsContractor.Tables[0].NewRow();
                defaultRow["ID"]   = "0";
                defaultRow["Name"] = "------ Select Contractor  ------";
                dsContractor.Tables[0].Rows.InsertAt(defaultRow, 0);

                cmbContractor.DataSource    = dsContractor.Tables[0];
                cmbContractor.DisplayMember = "Name";
                cmbContractor.ValueMember   = "ID";
            }
            catch (IndexOutOfRangeException ex)
            {
                MessageBox.Show(this, "Add atleast one item type to add purchase", "Error:Add new stock", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message.ToString(), "Error:Add New Stock", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            String dateofPurchase = txtDateofPurchase.Text;
            float  itemQuantity   = NumberUtils.SafeParse(txtQuantity.Value.ToString());
            long   itemTypeId     = long.Parse(cmbItemType.SelectedValue.ToString());
            int    contractorId   = int.Parse(cmbContractor.SelectedValue.ToString());

            //MessageBox.Show(" Value for DB = " + dateofPurchase + " " + itemQuantity +" "+ itemTypeId);
            try
            {
                if (String.IsNullOrEmpty(dateofPurchase) || itemQuantity < 1 || contractorId == 0)
                {
                    MessageBox.Show(this, "Fill in date of purchase, quantity and Contractor", "Error: Add new stock", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    bool isInserted = ShopDAL.AddPurchasedItem(dateofPurchase, itemTypeId, itemQuantity, contractorId);
                    if (isInserted)
                    {
                        this.Close();
                        MessageBox.Show(this, "New stock inserted successfully.", "Add new stock", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show(this, "New stock insertion failed.", "Error:Add new stock", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message.ToString(), "Error:Add new stock", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        private void onItemTypeValueChange(object sender, EventArgs e)
        {
            ComboBox cb = (ComboBox)sender;

            String selectedItemTypeIndex = cb.SelectedValue.ToString();

            if (selectedItemTypeIndex != "System.Data.DataRowView")
            {
                long itemId = long.Parse(selectedItemTypeIndex);

                if (itemId.ToString() == "0")
                {
                    lblAvailableQuantity.Text = "0";
                    txtSalePrice.Text         = "0";
                    txtQuantity.Maximum       = 0;
                }
                else
                {
                    float  availableQuantity = ShopDAL.getStockInHandQuantity(itemId);
                    float  salePrice         = ShopDAL.getItemTypeSalePrice(itemId);
                    string uomName           = ShopDAL.getItemTypeUoM(itemId);

                    lblAvailableQuantity.Text = quantitiesLeft[itemId.ToString()];
                    lblUoM.Text = uomName;
                    //lblAvailableQuantity.Text = availableQuantity.ToString();
                    txtSalePrice.Text   = salePrice.ToString(CultureInfo.InvariantCulture);
                    txtQuantity.Maximum = Decimal.Parse(quantitiesLeft[itemId.ToString()]);
                    //txtQuantity.Maximum = availableQuantity;
                }
            }
        }
Exemplo n.º 4
0
        private void frmSaleItem_Load(object sender, EventArgs e)
        {
            try
            {
                bool isExist = ShopDAL.isItemTypeExists();
                if (isExist)
                {
                    ShopDAL db = new ShopDAL();
                    DataSet ds = db.GetItemsType();

                    //Creating dictionary to handle available quantity of all items. It's made of pair (Type_ID, Quantity)
                    quantitiesLeft = new Dictionary <string, string>();
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        quantitiesLeft.Add(dr["Type_ID"].ToString(), ShopDAL.getStockInHandQuantity(long.Parse(dr["Type_ID"].ToString())).ToString());
                    }

                    // Inserting Default Row for Selection
                    DataRow defaultRow = ds.Tables[0].NewRow();
                    defaultRow["Type_ID"] = "0";
                    defaultRow["Name"]    = "---------------- Select Item Type ----------------";
                    ds.Tables[0].Rows.InsertAt(defaultRow, 0);

                    cmb_itemType.DataSource    = ds.Tables[0];
                    cmb_itemType.DisplayMember = "Name";
                    cmb_itemType.ValueMember   = "Type_ID";
                    cmb_itemType.SelectedIndex = 0;

                    cmb_itemType.AutoCompleteMode   = AutoCompleteMode.Append;
                    cmb_itemType.AutoCompleteSource = AutoCompleteSource.ListItems;

                    lstView_sales.Columns[0].Width = 0;
                    lblItemCount.Text  = "0";
                    lblTotalPrice.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00";
                    txtSalePrice.Text  = "0";
                }
            }
            catch (IndexOutOfRangeException ex)
            {
                MessageBox.Show(this, "Add atleast one item type to Sale Item(s)", "Error:Sale Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message.ToString(), "Error:Sale Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }


            //string[] row1 = { "CD-Software", "2", "30" };
            //string[] row2 = { "CD-Software", "2", "30" };

            /*lstView_sales.Items.Add("1").SubItems.AddRange(row1);
             * lstView_sales.Items.Add("1").SubItems.AddRange(row2);
             *
             * foreach(ListViewItem lvi in lstView_sales.Items)
             * {
             *  MessageBox.Show(lvi.SubItems[3].Text);
             * }*/
        }
Exemplo n.º 5
0
        public static void Initialize(DataContext context)
        {
            context.Database.EnsureCreated();

            if (context.Shops.Any())
            {
                return;
            }

            var shops = new ShopDAL[]
            {
                new ShopDAL {
                    Name = "eMobile", Schedule = "8:00 - 22:00", Description = "Shop 'eMobile' open 8:00 - 22:00. \n Address: Minsk, Lenina 10/20"
                },
                new ShopDAL {
                    Name = "Патриот", Schedule = "9:00 - 21:00", Description = "Shop 'Патриот' open 9:00 - 21:00. \n Address: Minsk, Kalatyshkina 10/20"
                },
                new ShopDAL {
                    Name = "Hot-Line", Schedule = "10:00 - 22:00", Description = "Shop 'Hot-Line' open 10:00 - 22:00. \n Address: Minsk, Kalatyshkina 10/20"
                },
                new ShopDAL {
                    Name = "MEX", Schedule = "9:00 - 22:00", Description = "Shop 'MEX' open 9:00 - 22:00. \n Address: Minsk, Pyshkina 9/20"
                },
                new ShopDAL {
                    Name = "Кандаловъ", Schedule = "8:00 - 20:00", Description = "Shop 'Кандаловъ' open 8:00 - 20:00. \n Address: Minsk, Kirova 12/10"
                }
            };

            foreach (var item in shops)
            {
                context.Shops.Add(item);
            }

            context.SaveChanges();
        }
Exemplo n.º 6
0
        private void frmSearchItem_Load(object sender, EventArgs e)
        {
            lblTotalProfit.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00";
            try
            {
                bool isExist = ShopDAL.isItemTypeExists();
                if (isExist)
                {
                    ShopDAL db = new ShopDAL();
                    DataSet ds = db.GetItemsType();

                    DataRow defaultRow = ds.Tables[0].NewRow();
                    defaultRow["Type_ID"] = "0";
                    defaultRow["Name"]    = "---------------- Select Item Type ----------------";
                    ds.Tables[0].Rows.InsertAt(defaultRow, 0);

                    cmb_itemType.DataSource    = ds.Tables[0];
                    cmb_itemType.DisplayMember = "Name";
                    cmb_itemType.ValueMember   = "Type_ID";
                    cmb_itemType.SelectedIndex = 0;
                }
            }
            catch (IndexOutOfRangeException ex)
            {
                MessageBox.Show(this, "Add atleast one item type", "Error:Search Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message.ToString(), "Error:Search Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            setupGridColumns();
            setupColumnsWidth();
        }
 internal static ShopBL ToShopModel(this ShopDAL shopEntity)
 {
     return(new ShopBL()
     {
         Index = shopEntity.Id,
         Name = shopEntity.Name,
         Schedule = shopEntity.Schedule,
         Description = shopEntity.Description
     });
 }
Exemplo n.º 8
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            String itemName      = txtItemName.Text;
            String itemPrice     = txtItemPrice.Text;
            String itemBarcode   = txtBarcode.Text;
            String itemSalePrice = txtExpectedSalePrice.Text;
            String uom           = cmbUoM.SelectedValue.ToString();
            String vendorId      = cmbVendor.SelectedValue.ToString();

            try
            {
                if (String.IsNullOrEmpty(itemName) || String.IsNullOrEmpty(itemPrice) || String.IsNullOrEmpty(itemSalePrice) || String.IsNullOrEmpty(uom) || vendorId == "0")
                {
                    MessageBox.Show(this, "Fill in item name, price, sale price,Unit of Measurement and Vendor", "Error:Add Item Type", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    float price     = NumberUtils.SafeParse(itemPrice);     // float.Parse(itemPrice);
                    float saleprice = NumberUtils.SafeParse(itemSalePrice); //float.Parse(itemSalePrice);

                    ItemType item = new ItemType();
                    item.ItemName  = itemName;
                    item.Price     = price;
                    item.SalePrice = saleprice;
                    item.Barcode   = itemBarcode;

                    UoM objUoM = new UoM();
                    objUoM.Id = int.Parse(uom);

                    item.Uom = objUoM;

                    Vendor objVendor = new Vendor();
                    objVendor.Id = int.Parse(vendorId);
                    item.Vendor  = objVendor;



                    bool isInserted = ShopDAL.InsertNewItemType(item);
                    if (isInserted)
                    {
                        this.Close();
                        MessageBox.Show(this, "Itemtype inserted successfully.", "Add Item Type", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show(this, "Itemtype inserted failed.", "Error:Add Item Type", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message.ToString(), "Error:Add Item Type", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public JsonResult getShopInfo([FromQuery] string shop_id)
        {
            ShopDAL shopDal = new ShopDAL();
            Shop    result  = shopDal.getShopById(shop_id);

            if (result == null)
            {
                return(new JsonResult(Return.Error("找不到此店铺", StatusCodes.ShopNotFound)));
            }

            return(new JsonResult(Return.Success(result)));
        }
Exemplo n.º 10
0
        private void setSummaryData()
        {
            double  totalSoldQuantity = 0;
            decimal totalProfit       = 0;
            String  startDate         = dpStartDate.Value.ToShortDateString();
            String  endDate           = dpEndDate.Value.ToShortDateString();
            long    itemTypeId        = long.Parse(cmb_itemType.SelectedValue.ToString());

            totalRecords = ShopDAL.SearchTotalProfitSummary(startDate, endDate, itemTypeId, ref totalSoldQuantity, ref totalProfit);

            lblSoldQuantity.Text = totalSoldQuantity.ToString();
            lblTotalProfit.Text  = ConfigurationDAL.GetCurrentCurrency() + " " + totalProfit.ToString();
        }
Exemplo n.º 11
0
        public JsonResult addFollowedShop([FromBody] JObject data)
        {
            // 登录验证
            string  sessionUserId   = HttpContext.Session.GetString("userId");
            string  sessionPassword = HttpContext.Session.GetString("password");
            UserDAL userDal         = new UserDAL();

            if (sessionUserId == null || userDal.getUserById(sessionUserId)?.password != sessionPassword)
            {
                return(new JsonResult(Return.Error("用户未登录或无权限访问", HttpStatusCodes.Status401Unauthorized)));
            }

            string shopId = data.Value <string>("shop_id"); // 店铺 ID

            if (shopId == null)
            {
                return(new JsonResult(Return.Error("店铺 ID 不能为空", HttpStatusCodes.Status400BadRequest)));
            }

            ShopDAL shopDal = new ShopDAL();
            Shop    shop    = shopDal.getShopById(shopId);

            if (shop == null)
            {
                return(new JsonResult(Return.Error("找不到此店铺", StatusCodes.ShopNotFound)));
            }

            FollowShopDAL followShopDal = new FollowShopDAL();
            bool          isFollowAdded = followShopDal.toggleFollowShop(sessionUserId, shopId);

            // 修改店铺的粉丝数
            if (isFollowAdded)
            {
                shop.followers++;
            }
            else
            {
                shop.followers--;
            }
            shopDal.updateShop(shop);

            var result = new { added = isFollowAdded };

            return(new JsonResult(Return.Success(result)));
        }
        public JsonResult listShops([FromQuery] int page     = 1, [FromQuery] string search     = null,
                                    [FromQuery] string order = null, [FromQuery] bool ascending = true)
        {
            ShopDAL shopDal = new ShopDAL();

            // 将搜索字符串分割成列表
            List <string> keywordList = search != null?Regex.Split(search, @"\s+").ToList() : new List <string>
            {
            };

            if (!(new string[] { "name", "point", "followers" }).Contains(order))
            {
                order = "name";
            }

            List <Shop> result = shopDal.listShops(true, keywordList, order, ascending, page, pageSize);

            return(new JsonResult(Return.Success(result)));
        }
Exemplo n.º 13
0
        private void performSearch(int startRecordNo, int noOfRecords)
        {
            try
            {
                String    startDate   = dpStartDate.Value.ToShortDateString();
                String    endDate     = dpEndDate.Value.ToShortDateString();
                long      itemTypeId  = long.Parse(cmb_itemType.SelectedValue.ToString());
                DataTable resultTable = ShopDAL.SearchTotalProfitDS(startDate, endDate, itemTypeId, startRecordNo, noOfRecords).Tables[0];
                String[]  dataFromTable;
                //DebugUtil.displayDataSetContents(resultTable.DataSet);

                dgSearchResults.Columns.Clear();
                dgSearchResults.Columns.Add("dcNo", "S.No.");
                setupGridColumns();
                setupColumnsWidth();

                int i = startRecordNo + 1;
                foreach (DataRow dr in resultTable.Rows)
                {
                    dataFromTable = new String[] {
                        i.ToString(),
                                 dr[0].ToString(),
                                 dr[1].ToString(),
                                 ConfigurationDAL.GetCurrentCurrency() + " " + decimal.Round(decimal.Parse(dr[2].ToString()), 2).ToString(),
                        ConfigurationDAL.GetCurrentCurrency() + " " + decimal.Round(decimal.Parse(dr[3].ToString()), 2).ToString(),
                        dr[4].ToString(),
                        ConfigurationDAL.GetCurrentCurrency() + " " + decimal.Round(decimal.Parse(dr[5].ToString()), 2).ToString(),
                        ConfigurationDAL.GetCurrentCurrency() + " " + decimal.Round(decimal.Parse(dr[6].ToString()), 2).ToString(),
                        ConfigurationDAL.GetCurrentCurrency() + " " + decimal.Round(decimal.Parse(dr[7].ToString()), 2).ToString()
                    };

                    dgSearchResults.Rows.Add(dataFromTable);
                    i++;
                }
            }
            catch (Exception ex)
            {
                dgSearchResults.ClearSelection();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 14
0
        private void btnSaveAndPrint_Click(object sender, EventArgs e)
        {
            try
            {
                List <Sale> saleItems = this.getListofItemsToBeAdded();
                if (saleItems.Count >= 1)
                {
                    prnDialog.Document = this.prnDocument;
                    DialogResult result = prnDialog.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        String saleDate = dateOfSale.Text;
                        invoiceID = ShopDAL.SaleItems(saleDate, saleItems);

                        prnDialog.Document.Print();

                        this.Close();
                        MessageBox.Show(this, "Item sold successfully. Collect printout from printer.", "Sale Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    throw new Exception("Please add some item(s) in list");
                }
            }
            catch (DocumentException de)
            {
                MessageBox.Show(de.Message);
            }
            catch (IOException ioe)
            {
                MessageBox.Show(ioe.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message.ToString(), "Error: Sale Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 15
0
        public ActionResult Product(int productId)
        {
            var product = new ShopDAL().Product(productId);

            return(View("Product", product));
        }
Exemplo n.º 16
0
        public ActionResult GetProduct(int productId)
        {
            var product = new ShopDAL().Product(productId);

            return(PartialView("AddEditProduct", product));
        }
Exemplo n.º 17
0
        public JsonResult cancelOrCloseOrder([FromBody] JObject data)
        {
            string sessionUserId   = HttpContext.Session.GetString("userId");
            string sessionPassword = HttpContext.Session.GetString("password");

            UserDAL  userDal  = new UserDAL();
            OrderDAL orderDal = new OrderDAL();
            ItemDAL  itemDal  = new ItemDAL();
            ShopDAL  shopDal  = new ShopDAL();

            string orderId = data.Value <string>("order_id");
            Order  order   = orderDal.getOrderById(orderId);

            // 权限验证
            if (sessionUserId == null || userDal.getUserById(sessionUserId)?.password != sessionPassword ||
                order?.userId != sessionUserId)
            {
                return(new JsonResult(Return.Error("用户未登录或无权限访问", HttpStatusCodes.Status401Unauthorized)));
            }

            if (order == null)
            {
                return(new JsonResult(Return.Error("找不到此订单", StatusCodes.OrderNotFound)));
            }

            if (order.close == true)
            {
                return(new JsonResult(Return.Error("订单已被关闭过", StatusCodes.OrderAlreadyClosed)));
            }

            order.close = true;

            if (order.deliveryTime != null && order.paymentTime != null)
            {
                // 如果发货并关闭订单,认为是成交了
                order.receiptTime = DateTime.Now;

                // 增加销量
                foreach (OrderItem item in order.items)
                {
                    item.item.sales += item.count;
                    itemDal.updateItem(item.item);
                }

                // 增加用户积分
                User user = userDal.getUserById(sessionUserId);
                user.point += (int)(order.price * 100);
                user.level  = (int)Math.Floor(0.005 * Math.Pow(user.point, 0.65));
                userDal.updateUserInfo(user);

                // 增加店铺积分
                foreach (OrderItem item in order.items)
                {
                    string shopId = item.item.shopId;
                    Shop   shop   = shopDal.getShopById(shopId);
                    shop.point += (int)(item.count * item.item.price * 100);
                    shop.level  = (int)Math.Floor(0.005 * Math.Pow(shop.point, 0.65));
                    shopDal.updateShop(shop);
                }
            }
            else
            {
                // 否则认为是取消订单,增加库存量
                foreach (OrderItem item in order.items)
                {
                    item.item.quantity += item.count;
                    itemDal.updateItem(item.item);
                }
            }

            int result = orderDal.updateOrder(order);

            return(new JsonResult(Return.Success(result)));
        }
Exemplo n.º 18
0
        private void btnSaveAsPDF_Click(object sender, EventArgs e)
        {
            try
            {
                List <Sale> saleItems = this.getListofItemsToBeAdded();
                if (saleItems.Count >= 1)
                {
                    string path = "";

                    FileDialog dialog = new SaveFileDialog();
                    dialog.Title = "Save file as...";
                    long nextInvoiceId = DBUtil.GetNextID("Sale_ID", "Sales");
                    dialog.FileName         = "Sale_No_" + nextInvoiceId.ToString() + "_Dated_" + System.DateTime.Now.Day.ToString() + "-" + System.DateTime.Now.Month.ToString() + "-" + System.DateTime.Now.Year.ToString();
                    dialog.RestoreDirectory = true;
                    dialog.Filter           = "Adobe Acrobat Reader PDF (*.pdf)|*.*";
                    DialogResult result = dialog.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        String saleDate  = dateOfSale.Text;
                        long   invoiceID = ShopDAL.SaleItems(saleDate, saleItems);

                        path = dialog.FileName;
                        Document myDocument = new Document(PageSize.A4.Rotate());


                        // step 2:
                        // Now create a writer that listens to this doucment and writes the document to desired Stream.

                        PdfWriter.GetInstance(myDocument, new FileStream(path + ".pdf", FileMode.Create));

                        // step 3:  Open the document now using
                        myDocument.Open();

                        // step 4: Now add some contents to the document
                        PdfPTable table = new PdfPTable(6);
                        table.WidthPercentage = 50;

                        dateOfSale.Format = DateTimePickerFormat.Long;
                        String displayDate = dateOfSale.Text;

                        //String displayDate = System.DateTime.Now.ToLongDateString() + " " + System.DateTime.Now.ToLongTimeString();

                        // Printing Header
                        PdfPCell cellShopName = new PdfPCell(new Paragraph(ConfigurationDAL.GetShopName(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 14)));
                        table.HorizontalAlignment        = Element.ALIGN_LEFT;
                        cellShopName.Colspan             = 6;
                        cellShopName.BackgroundColor     = new BaseColor(204, 204, 204);
                        cellShopName.BorderColor         = new BaseColor(204, 204, 204);
                        cellShopName.HorizontalAlignment = Element.ALIGN_CENTER;
                        table.AddCell(cellShopName);


                        PdfPCell cellAddress = new PdfPCell(new Paragraph("Address: " + ConfigurationDAL.GetCurrentAddress()));
                        cellAddress.Colspan             = 6;
                        cellAddress.BackgroundColor     = new BaseColor(204, 204, 204);
                        cellAddress.BorderColor         = new BaseColor(204, 204, 204);
                        cellAddress.HorizontalAlignment = Element.ALIGN_CENTER;
                        table.AddCell(cellAddress);

                        PdfPCell cellCurrentDate = new PdfPCell(new Paragraph("Dated: " + displayDate));
                        cellCurrentDate.Colspan             = 6;
                        cellCurrentDate.BackgroundColor     = new BaseColor(204, 204, 204);
                        cellCurrentDate.BorderColor         = new BaseColor(204, 204, 204);
                        cellCurrentDate.HorizontalAlignment = Element.ALIGN_CENTER;
                        table.AddCell(cellCurrentDate);

                        PdfPCell cellInvoiceID = new PdfPCell(new Paragraph("Invoice ID: " + invoiceID.ToString()));
                        cellInvoiceID.Colspan             = 6;
                        cellInvoiceID.BackgroundColor     = new BaseColor(204, 204, 204);
                        cellInvoiceID.BorderColor         = new BaseColor(204, 204, 204);
                        cellInvoiceID.HorizontalAlignment = Element.ALIGN_LEFT;
                        table.AddCell(cellInvoiceID);



                        // Printing Items

                        PdfPCell cellItemHeader = new PdfPCell(new Paragraph("Item"));
                        cellItemHeader.Colspan = 2;
                        table.AddCell(cellItemHeader);

                        PdfPCell cellQuantityHeader = new PdfPCell(new Paragraph("Quantity"));
                        cellQuantityHeader.Colspan = 2;
                        table.AddCell(cellQuantityHeader);

                        PdfPCell cellPriceHeader = new PdfPCell(new Paragraph("Unit Price"));
                        cellPriceHeader.Colspan = 2;
                        table.AddCell(cellPriceHeader);

                        foreach (Sale item in saleItems)
                        {
                            PdfPCell cellItemName = new PdfPCell(new Paragraph(item.ItemName));
                            cellItemName.Colspan = 2;
                            table.AddCell(cellItemName);

                            PdfPCell cellQuantity = new PdfPCell(new Paragraph(item.Quantity.ToString() + "  " + item.UomName));
                            cellQuantity.Colspan = 2;
                            table.AddCell(cellQuantity);

                            string   pricewithUnit = ConfigurationDAL.GetCurrentCurrency() + " " + string.Format("{0:N2}", item.SalePrice);
                            PdfPCell cellPrice     = new PdfPCell(new Paragraph(pricewithUnit));
                            cellPrice.Colspan = 2;
                            table.AddCell(cellPrice);
                        }

                        // Printing Total Quantity and Price
                        PdfPCell cellTotalQtyHeader = new PdfPCell(new Paragraph("Total Quantity "));
                        cellTotalQtyHeader.Colspan             = 2;
                        cellTotalQtyHeader.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cellTotalQtyHeader.BackgroundColor     = new BaseColor(200, 200, 200);
                        table.AddCell(cellTotalQtyHeader);

                        PdfPCell cellTotalQtyValue = new PdfPCell(new Paragraph(this.saleCounter.ToString()));
                        cellTotalQtyValue.BackgroundColor = new BaseColor(200, 200, 200);
                        table.AddCell(cellTotalQtyValue);


                        PdfPCell cellTotalPriceHeader = new PdfPCell(new Paragraph("Total Price"));
                        cellTotalPriceHeader.BackgroundColor = new BaseColor(200, 200, 200);
                        table.AddCell(cellTotalPriceHeader);

                        PdfPCell cellTotalPriceValue = new PdfPCell(new Paragraph(ConfigurationDAL.GetCurrentCurrency() + " " + this.saleTotalPrice.ToString()));
                        cellTotalPriceValue.Colspan         = 2;
                        cellTotalPriceValue.BackgroundColor = new BaseColor(200, 200, 200);
                        table.AddCell(cellTotalPriceValue);

                        // Printing XtraWebApps Footer
                        PdfPCell cellFooter = new PdfPCell(new Paragraph("Shop Management Solution by www.DeluxeWebApps.com", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10)));
                        cellFooter.Colspan             = 6;
                        cellFooter.HorizontalAlignment = Element.ALIGN_CENTER;
                        table.AddCell(cellFooter);

                        // Add cells to table and close it.
                        myDocument.Add(table);
                        myDocument.Close();

                        //Launch the PDF Generated.
                        System.Diagnostics.Process.Start(path + ".pdf");

                        this.Close();
                        MessageBox.Show(this, "Item sold successfully.", "Sale Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    throw new Exception("Please add some item(s) in list");
                }
            }
            catch (DocumentException de)
            {
                MessageBox.Show(de.Message);
            }
            catch (IOException ioe)
            {
                MessageBox.Show(ioe.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message.ToString(), "Error: Sale Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }