public void Remove(int SaleOrderId)
        {
            //write a common logic to assign value from one type object to other type object in Utils class lib project.
            SALE saleObj = this.extraaEdgeCRMEntities.SALES.Where(x => x.ID == SaleOrderId).FirstOrDefault();

            if (saleObj != null)
            {
                this.extraaEdgeCRMEntities.SALES.Remove(saleObj);
            }
        }
Ejemplo n.º 2
0
        public bool Delete(ProductDetailDTO entity)
        {
            PRODUCT product = new PRODUCT();

            product.ID = entity.ProductID;
            dao.Delete(product);
            SALE sales = new SALE();

            sales.ProductID = entity.ProductID;
            salesdao.Delete(sales);
            return(true);
        }
Ejemplo n.º 3
0
        public bool Delete(CustomerDetailDTO entity)
        {
            CUSTOMER customer = new CUSTOMER();

            customer.ID = entity.ID;
            dao.Delete(customer);
            SALE sales = new SALE();

            sales.CustomerID = entity.ID;
            salesdao.Delete(sales);
            return(true);
        }
Ejemplo n.º 4
0
        public bool Delete(SalesDetailDTO entity)
        {
            SALE sales = new SALE();

            sales.ID = entity.SalesID;
            dao.Delete(sales);
            PRODUCT product = new PRODUCT();

            product.ID          = entity.ProductID;
            product.StockAmount = entity.StockAmount + entity.SalesAmount;
            productdao.Update(product);
            return(true);
        }
        public void Add(SalesDataModel salesDataModel)
        {
            SALE saleObj = new SALE();

            //write a common logic to assign value from one type object to other type object in Utils class lib project.
            saleObj.ID = salesDataModel.ID;
            saleObj.SALES_ORDER_DATE = salesDataModel.SALES_ORDER_DATE;
            saleObj.Company          = salesDataModel.Company;
            saleObj.AMOUNT           = salesDataModel.AMOUNT;
            saleObj.PLANNED          = salesDataModel.PLANNED;
            saleObj.COST             = salesDataModel.COST;
            saleObj.CREATED_BY       = salesDataModel.CREATED_BY;
            saleObj.CREATED_ON       = salesDataModel.CREATED_ON;
            saleObj.UPDATED_BY       = salesDataModel.UPDATED_BY;
            saleObj.UPDATED_ON       = salesDataModel.UPDATED_ON;
            this.extraaEdgeCRMEntities.SALES.Add(saleObj);
        }
        public void Update(SalesDataModel salesDataModel)
        {
            //write a common logic to assign value from one type object to other type object in Utils class lib project.
            SALE saleObj = this.extraaEdgeCRMEntities.SALES.Where(x => x.ID == salesDataModel.ID).FirstOrDefault();

            if (saleObj != null)
            {
                saleObj.SALES_ORDER_DATE = salesDataModel.SALES_ORDER_DATE;
                saleObj.Company          = salesDataModel.Company;
                saleObj.AMOUNT           = salesDataModel.AMOUNT;
                saleObj.PLANNED          = salesDataModel.PLANNED;
                saleObj.COST             = salesDataModel.COST;
                saleObj.CREATED_BY       = salesDataModel.CREATED_BY;
                saleObj.CREATED_ON       = salesDataModel.CREATED_ON;
                saleObj.UPDATED_BY       = salesDataModel.UPDATED_BY;
                saleObj.UPDATED_ON       = salesDataModel.UPDATED_ON;
            }
        }
Ejemplo n.º 7
0
        public bool Insert(SalesDetailDTO entity)
        {
            SALE sales = new SALE();

            sales.CategoryID         = entity.CategoryID;
            sales.ProductID          = entity.ProductID;
            sales.CustomerID         = entity.CustomerID;
            sales.ProductSalesPrice  = entity.Price;
            sales.ProductSalesAmount = entity.SalesAmount;
            sales.SalesDate          = entity.SalesDate;
            dao.Insert(sales);
            PRODUCT product = new PRODUCT();

            product.ID = entity.ProductID;
            int temp = entity.StockAmount - entity.SalesAmount;

            product.StockAmount = temp;
            productdao.Update(product);
            return(true);
        }
Ejemplo n.º 8
0
        private void loadInvoice()
        {
            //display the invoice
            int rowCount = 0;

            //get the details from the db
            try
            {
                //get booking deatils
                SP_GetCustomerBooking BookingDetails = handler.getCustomerPastBookingDetails(SaleID);
                SALE invoice = handler.getSale(SaleID);
                List <SP_getInvoiceDL> invoicDetailLines = handler.getInvoiceDL(SaleID);

                if (invoicDetailLines.Count != 0)
                {
                    #region Company Details / Invoice Date
                    //diaplay a heading
                    TableRow newRow = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);
                    TableCell newCell = new TableCell();
                    newCell.Font.Bold = true;
                    newCell.Font.Bold = true;
                    newCell.Text      = "<a class='navbar-brand js-scroll-trigger' href='#' onClick='window.print()'>Cheveux </a>";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    #region EmptyCells
                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    #endregion
                    newCell           = new TableCell();
                    newCell.Font.Bold = true;
                    newCell.Text      = "Invoice";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    #region Break Line
                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);
                    newCell      = new TableCell();
                    newCell.Text = "<br/>";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    newCell      = new TableCell();
                    newCell.Text = "<br/>";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //increment row count
                    rowCount++;
                    #endregion

                    //from address
                    BUSINESS bUSINESS = handler.getBusinessTable();
                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);
                    newCell      = new TableCell();
                    newCell.Text = bUSINESS.AddressLine1 + "<br/>" + bUSINESS.AddressLine2;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    #region EmptyCells
                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    #endregion

                    #region  date
                    newCell = new TableCell();

                    newCell.Text = invoice.Date.ToString("HH:mm dd MMM yyyy");
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    #endregion

                    //increment row count
                    rowCount++;
                    #endregion

                    #region Billed To
                    //Billed to
                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);
                    newCell           = new TableCell();
                    newCell.Font.Bold = true;
                    newCell.Text      = "Billed To:";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    newCell      = new TableCell();
                    newCell.Text = handler.GetUserDetails(invoice.CustID).FirstName.ToString() + " " +
                                   handler.GetUserDetails(invoice.CustID).LastName.ToString();
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //increment row count
                    rowCount++;
                    #endregion

                    #region Stylist
                    if (BookingDetails != null)
                    {
                        newRow        = new TableRow();
                        newRow.Height = 50;
                        tblInvoice.Rows.Add(newRow);
                        newCell           = new TableCell();
                        newCell.Font.Bold = true;
                        newCell.Text      = "Services Renderd By:";
                        tblInvoice.Rows[rowCount].Cells.Add(newCell);
                        newCell      = new TableCell();
                        newCell.Text = BookingDetails.stylistFirstName;
                        tblInvoice.Rows[rowCount].Cells.Add(newCell);

                        //increment row count
                        rowCount++;
                    }
                    #endregion

                    //calculate total price
                    double total = 0.0;

                    #region Items
                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);

                    #region header
                    //fill in the item
                    newCell           = new TableCell();
                    newCell.Text      = "Item";
                    newCell.Font.Bold = true;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    newCell           = new TableCell();
                    newCell.Text      = "Qty";
                    newCell.Font.Bold = true;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    newCell                 = new TableCell();
                    newCell.Text            = "Unit Price";
                    newCell.Font.Bold       = true;
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //fill in the Qty, unit price & TotalPrice
                    newCell                 = new TableCell();
                    newCell.Text            = "Total";
                    newCell.Font.Bold       = true;
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //increment row count
                    rowCount++;
                    #endregion

                    foreach (SP_getInvoiceDL item in invoicDetailLines)
                    {
                        newRow        = new TableRow();
                        newRow.Height = 50;
                        tblInvoice.Rows.Add(newRow);

                        //fill in the item
                        newCell      = new TableCell();
                        newCell.Text = item.itemName.ToString();
                        tblInvoice.Rows[rowCount].Cells.Add(newCell);

                        newCell      = new TableCell();
                        newCell.Text = item.Qty.ToString();
                        tblInvoice.Rows[rowCount].Cells.Add(newCell);

                        newCell = new TableCell();
                        newCell.HorizontalAlign = HorizontalAlign.Right;
                        newCell.Text            = "R" + string.Format("{0:#.00}", item.price);
                        tblInvoice.Rows[rowCount].Cells.Add(newCell);

                        //fill in the Qty, unit price & TotalPrice
                        newCell = new TableCell();
                        newCell.HorizontalAlign = HorizontalAlign.Right;
                        newCell.Text            = "R" + string.Format("{0:#.00}", item.Qty * item.price);
                        tblInvoice.Rows[rowCount].Cells.Add(newCell);

                        //increment final price
                        total += item.Qty * item.price;

                        //increment row count
                        rowCount++;
                    }
                    #endregion

                    #region Excluding Vat Info
                    // get vat info
                    Tuple <double, double> vatInfo = function.getVat(total);

                    //display total including and Excluding VAT
                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);

                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    newCell = new TableCell();
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    newCell.Text            = "<br/> Excluding VAT: &nbsp; ";
                    newCell.Font.Bold       = true;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    //fill in total ExcludingVAT
                    newCell = new TableCell();
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    newCell.Text            = " <br/> R " + string.Format("{0:#.00}", vatInfo.Item1, 2);
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //increment row count
                    rowCount++;
                    #endregion

                    #region VAT RAte
                    //get the vat rate
                    double VATRate = -1;
                    try
                    {
                        VATRate = handler.GetVATRate().VATRate;
                    }
                    catch (Exception Err)
                    {
                        function.logAnError(Err.ToString());
                    }

                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);

                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //fill in total VAT due
                    newCell = new TableCell();
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    newCell.Text            = "VAT @" + VATRate + "% &nbsp; ";
                    newCell.Font.Bold       = true;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    newCell = new TableCell();
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    newCell.Text            = "R " + string.Format("{0:#.00}", vatInfo.Item2, 2).ToString();
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //increment row count
                    rowCount++;
                    #endregion

                    #region Total
                    //display the total due
                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);

                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //fill in total
                    newCell = new TableCell();
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    newCell.Text            = "<br/> Total Due: &nbsp; ";
                    newCell.Font.Bold       = true;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    newCell = new TableCell();
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    newCell.Text            = "<br/> R " + string.Format("{0:#.00}", total).ToString();
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    #endregion
                }
                else
                {
                    function.logAnError("Error Loading Print Invoice ");
                    Response.Redirect("Error.aspx?Error='An Error Occured Communicating With The Data Base, Try Again Later'");
                }
            }
            catch (Exception Err)
            {
                function.logAnError("Error Loading Print Invoice | Error: " + Err.ToString());
                Response.Redirect("Error.aspx?Error='An Error Occured Communicating With The Data Base, Try Again Later'");
            }
        }
Ejemplo n.º 9
0
        public async Task <ActionResult <BaseResponse> > Post([FromForm] SaleResponse infoEnter)
        {
            // Thêm một hóa đơn mới
            SALE sale = new SALE();

            sale.customerId  = infoEnter.customerId;
            sale.dateCreated = infoEnter.dateCreated;
            sale.isRemove    = false;
            _context.SALES.Add(sale);
            await _context.SaveChangesAsync();

            // Kiểm tra đã nhập thông tin khách hàng - Tên, Ngày lập hóa đơn
            if (string.IsNullOrEmpty(infoEnter.firstName) ||
                string.IsNullOrEmpty(infoEnter.lastName) ||
                infoEnter.dateCreated == null)
            {
                return(new BaseResponse
                {
                    ErrorCode = Roles.Empty_Customer_Input,
                    Message = "Customer info is Empty!"
                });
            }

            // Cập nhật phiếu nhập mới - duyệt từng thông tin sách (Tên, Thể loại, Số lượng, Đơn giá)
            var list = infoEnter.listSaleDetailInfo;

            for (int i = 0; i < list.Count; i++)
            {
                // Kiểm tra dữ liệu nhập bị trống
                if (string.IsNullOrEmpty(list[i].name) ||
                    string.IsNullOrEmpty(list[i].kind) ||
                    list[i].amount == 0 ||
                    list[i].price == 0)
                {
                    return(new BaseResponse
                    {
                        //ErrorCode = Roles.Empty_Book_Input,
                        Message = "Some field is empty!",
                        Data = null
                    });
                }
                else
                {
                    SALEDETAIL saleDetail = new SALEDETAIL();
                    var        bookNeed   = await _context.BOOKS.Where(x => x.name == list[i].name).FirstOrDefaultAsync();

                    saleDetail.stt        = i + 1;
                    saleDetail.bookId     = bookNeed.id;
                    saleDetail.saleId     = list[i].saleId; // Nối saleDetail và sale lại với nhau
                    saleDetail.amount     = list[i].amount;
                    saleDetail.totalPrice = list[i].price * list[i].amount;

                    _context.SALEDETAILS.Add(saleDetail);
                    await _context.SaveChangesAsync();
                }
            }

            return(new BaseResponse
            {
                ErrorCode = Roles.Success,
                Message = "A book sale bill is created!"
            });
        }
Ejemplo n.º 10
0
 public bool createSalesRecord(SALE newSale)
 {
     return(db.createSalesRecord(newSale));
 }