Ejemplo n.º 1
0
    public void CalculateDiscount(double customer, double vatPercent)
    {
        _discountPercent = 0;
        _total = 0;
        _totalVat = 0;
        _totalDiscount = 0;
        _grandTotal = 0;
        SaleFlow sFlow = new SaleFlow();
        DataTable dt = (DataTable)System.Web.HttpContext.Current.Session[sessionName];
        if (dt != null)
        {
            foreach (DataRow dRow in dt.Rows)
            {
                _totalDiscount += Convert.ToDouble(dRow["NORMALDISCOUNT"])*Convert.ToDouble(dRow["QTY"]);
                _grandTotal += Convert.ToDouble(dRow["NETPRICE"]) - (Convert.ToDouble(dRow["NORMALDISCOUNT"]) * Convert.ToDouble(dRow["QTY"]));
            }
            _totalVat = sFlow.CalculateTotalVat(_grandTotal + _totalDiscount, vatPercent);
            _total = _grandTotal + _totalDiscount - _totalVat;

            if (sFlow.GetCustomerDiscount(customer, _total + _totalVat))
                _discountPercent = sFlow.DISCOUNT;
            if (_discountPercent > 0)
            {
                if (_totalDiscount < sFlow.CalcucateDiscount(_total + _totalVat, _discountPercent))
                {
                    _total = 0;
                    _totalVat = 0;
                    _totalDiscount = 0;
                    _grandTotal = 0;
                    foreach (DataRow dRow in dt.Rows)
                    {
                        dRow["DISCOUNT"] = sFlow.CalcucateDiscount(Convert.ToDouble(dRow["PRICE"]), _discountPercent);
                        dRow["NETPRICE"] = sFlow.CalcucateProductTotalItem(Convert.ToDouble(dRow["PRICE"]), Convert.ToDouble(dRow["QTY"]), 0);
                        _totalDiscount += Convert.ToDouble(dRow["DISCOUNT"]) * Convert.ToDouble(dRow["QTY"]);
                        _grandTotal += Convert.ToDouble(dRow["NETPRICE"]) - (Convert.ToDouble(dRow["DISCOUNT"]) * Convert.ToDouble(dRow["QTY"]));
                    }
                    System.Web.HttpContext.Current.Session[sessionName] = dt;
                    _totalVat = sFlow.CalculateTotalVat(_grandTotal + _totalDiscount, vatPercent);
                    _total = _grandTotal + _totalDiscount - _totalVat;
                }
            }
        }
    }
Ejemplo n.º 2
0
 private bool IsDuplicate(RequisitionItemData data)
 {
     bool ret = false;
     DataTable dt = (DataTable)System.Web.HttpContext.Current.Session[sessionName];
     if (dt != null)
     {
         SaleFlow sFlow = new SaleFlow();
         foreach (DataRow dRow in dt.Rows)
         {
             if (Convert.ToDouble(dRow["PRODUCT"]) == data.PRODUCT && Convert.ToDouble(dRow["LOID"]) != data.LOID)
             {
                 dRow["QTY"] = Convert.ToDouble(dRow["QTY"]) + data.QTY;
                 dRow["NETPRICE"] = sFlow.CalcucateProductTotalItem(Convert.ToDouble(dRow["PRICE"]), Convert.ToDouble(dRow["QTY"]), 0);
                 ret = true;
                 break;
             }
         }
         if (ret)
         {
             DataRow[] dRow = dt.Select("LOID = " + data.LOID.ToString());
             if (dRow != null)
             {
                 if (dRow.Length > 0)
                 {
                     dt.Rows.Remove(dRow[0]);
                     ReOrder(dt);
                 }
             }
             System.Web.HttpContext.Current.Session[sessionName] = dt;
         }
     }
     return ret;
 }