private void BindrptProduct()
        {
            if (_ivStorage.Id <= 0)
            {
                _ivStorage = Module.GetById <IvStorage>(Convert.ToInt32(ddlStorage.SelectedValue));
            }
            var list     = Module.GetProductWarningByStorage(_ivStorage);
            var products = new List <IvProduct>();

            foreach (IvProductWarning productWarning in list)
            {
                var    product      = productWarning.Product;
                int    sumImport    = Module.SumProductImport(_ivStorage, product);
                double sumExport    = Module.SumProductExport(_ivStorage, product);
                var    result       = Convert.ToDouble(sumImport) - Convert.ToDouble(sumExport);
                double warningLimit = Module.GetWarningLimit(_ivStorage, product);
                if (warningLimit > 0 && warningLimit >= result)
                {
                    product.WarningLimit  = Convert.ToInt32(warningLimit);
                    product.NumberInStock = result;
                    products.Add(product);
                }
            }
            rptProductList.DataSource = products;
            rptProductList.DataBind();
        }
Пример #2
0
        /// <summary>
        /// lấy toàn bộ giá sản phẩm
        /// </summary>
        /// <param name="cruiseId"></param>
        /// <returns></returns>
        public IList <IvProductPrice> IvGetProductPrices(int cruiseId)
        {
            var       queryOver = _commonDao.OpenSession().QueryOver <IvProductPrice>();
            IvStorage storage   = null;

            queryOver = queryOver.JoinAlias(x => x.Storage, () => storage);
            queryOver.Where(r => storage.Cruise.Id == cruiseId);
            return(queryOver.List <IvProductPrice>());
        }
 protected virtual void Page_Load(object sender, EventArgs e)
 {
     Page.Title = @"Danh sách sản phẩm";
     pagerProduct.AllowCustomPaging = true;
     pagerProduct.PageSize          = 20;
     if (!string.IsNullOrWhiteSpace(Request["storageId"]))
     {
         IvStorage = Module.GetById <IvStorage>(Convert.ToInt32(Request["storageId"]));
     }
     if (!IsPostBack)
     {
         LoadStorage();
         FillQueryToForm();
         BindrptProduct();
     }
 }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.Title = "Kho";
     if (!string.IsNullOrWhiteSpace(Request["id"]))
     {
         _storage = Module.IvStorageGetById(Convert.ToInt32(Request["id"]));
     }
     if (!IsPostBack)
     {
         FillParentData();
         if (_storage.Id > 0)
         {
             FillInfo();
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.Title = "Sản phẩm";
     pagerProduct.AllowCustomPaging = true;
     pagerProduct.PageSize          = 20;
     if (!string.IsNullOrWhiteSpace(Request["storageId"]))
     {
         _ivStorage      = Module.GetById <IvStorage>(Convert.ToInt32(Request["storageId"]));
         litStorage.Text = _ivStorage.Name;
     }
     if (!IsPostBack)
     {
         FillCateData();
         FillSearchData();
         FillProduct();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.Title = @"Cảnh báo sản phẩm sắp hết";
     if (!string.IsNullOrWhiteSpace(Request["storageId"]))
     {
         _ivStorage = Module.GetById <IvStorage>(Convert.ToInt32(Request["storageId"]));
     }
     if (!IsPostBack)
     {
         LoadStorage();
         FillQueryToForm();
         if (!string.IsNullOrWhiteSpace(ddlStorage.SelectedValue))
         {
             BindrptProduct();
         }
     }
 }
Пример #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.Title = "Sản phẩm";
     if (!string.IsNullOrWhiteSpace(Request["id"]))
     {
         _product = Module.IvProductGetById(Convert.ToInt32(Request["id"]));
     }
     if (!string.IsNullOrWhiteSpace(Request["storageId"]))
     {
         _ivStorage = Module.IvStorageGetById(Convert.ToInt32(Request["storageId"]));
     }
     if (!IsPostBack)
     {
         FillData();
         if (_product.Id > 0)
         {
             FillInfo();
         }
     }
 }
Пример #8
0
 public void RaiseCallbackEvent(string eventArgument)
 {
     if (!string.IsNullOrEmpty(eventArgument))
     {
         var       str     = eventArgument.Split('|');
         IvStorage storage = null;
         if (!string.IsNullOrEmpty(str[1]))
         {
             storage = Module.GetById <IvStorage>(Convert.ToInt32(str[1]));
         }
         IvProduct product = Module.IvProductGetByCode(str[0], storage);
         if (product != null)
         {
             _callbackResult = product.Name + "#" + 0 + "#" + product.Id;
         }
         else
         {
             _callbackResult = "Không tồn tại sản phẩm#0";
         }
     }
 }
Пример #9
0
        protected void btnAddNewProduct_Click(object sender, EventArgs e)
        {
            IList     data    = new ArrayList();
            IvStorage storage = null;

            //            if (!string.IsNullOrEmpty(ddlStorage.SelectedValue))
            //                storage = Module.GetById<IvStorage>(Convert.ToInt32(ddlStorage.SelectedValue));
            foreach (RepeaterItem item in rptProductList.Items)
            {
                IvProductExport productExport = new IvProductExport();

                HiddenField hddProductExportId = item.FindControl("hddProductExportId") as HiddenField;
                HiddenField hddProductId       = (HiddenField)item.FindControl("hddProductId");

                TextBox txtCodeProduct  = item.FindControl("txtCodeProduct") as TextBox;
                TextBox txtQuantity     = item.FindControl("txtQuantity") as TextBox;
                TextBox txtUnitPrice    = item.FindControl("txtUnitPrice") as TextBox;
                TextBox txtItemTotal    = item.FindControl("txtTotal") as TextBox;
                var     ddlUnit         = (DropDownList)item.FindControl("ddlUnit");
                TextBox txtDiscount     = item.FindControl("txtDiscount") as TextBox;
                var     ddlDiscountType = item.FindControl("ddlDiscountType") as DropDownList;

                if (!string.IsNullOrEmpty(hddProductExportId.Value))
                {
                    productExport.Id = Convert.ToInt32(hddProductExportId.Value);
                }
                if (!string.IsNullOrEmpty(txtCodeProduct.Text))
                {
                    productExport.Product = Module.IvProductGetByCode(txtCodeProduct.Text.Trim(), storage);
                }
                if (!string.IsNullOrEmpty(hddProductId.Value))
                {
                    productExport.Product = Module.GetById <IvProduct>(Convert.ToInt32(hddProductId.Value));
                }
                if (!string.IsNullOrEmpty(txtUnitPrice.Text))
                {
                    productExport.UnitPrice = Convert.ToDouble(txtUnitPrice.Text);
                }
                if (!string.IsNullOrEmpty(txtQuantity.Text))
                {
                    productExport.Quantity = Convert.ToInt32(txtQuantity.Text);
                }
                if (!string.IsNullOrEmpty(txtItemTotal.Text))
                {
                    productExport.Total = Convert.ToDouble(txtItemTotal.Text);
                }
                if (!string.IsNullOrEmpty(ddlUnit.SelectedValue))
                {
                    productExport.Unit = Module.GetById <IvUnit>(Convert.ToInt32(ddlUnit.SelectedValue));
                }
                if (!string.IsNullOrEmpty(txtDiscount.Text))
                {
                    productExport.Discount = Convert.ToInt32(txtDiscount.Text);
                }
                if (!string.IsNullOrEmpty(ddlDiscountType.SelectedValue))
                {
                    productExport.DiscountType = Convert.ToInt32(ddlDiscountType.SelectedValue);
                }
                productExport.Export = _currentExport;
                data.Add(productExport);
            }

            data.Add(new IvProductExport());
            rptProductList.DataSource = data;
            _total = 0;
            rptProductList.DataBind();
            rptProductListItems.Value = data.Count.ToString();
        }
Пример #10
0
        protected void btnSaveProductExport_Click(object sender, EventArgs e)
        {
            try
            {
                #region ---Save Customer Infomation--

                IvStorage storage = null;
                //if (!string.IsNullOrEmpty(ddlStorage.SelectedValue))
                //    storage = Module.GetById<IvStorage>(Convert.ToInt32(ddlStorage.SelectedValue));
                _currentExport.Storage = storage;

                _currentExport.CustomerName = txtCustomerName.Text;

                #endregion

                #region --- Save Current Export---

                _currentExport.Name = txtName.Text;
                int flag = Module.CountExportGetByCode(txtCode.Text);
                if (flag > 0 && _currentExport.Id <= 0)
                {
                    ShowErrors("Mã phiếu đã tồn tại");
                    return;
                }
                _currentExport.Code       = txtCode.Text;
                _currentExport.Detail     = txtDetail.Text;
                _currentExport.ExportedBy = UserIdentity.UserName;
                if (chkIsDebt.Checked)
                {
                    _currentExport.IsDebt = true;
                    _currentExport.Agency = txtAgency.Text;
                }
                if (!string.IsNullOrEmpty(txtExportedDate.Text))
                {
                    _currentExport.ExportDate = DateTime.ParseExact(txtExportedDate.Text, "dd/MM/yyyy",
                                                                    CultureInfo.InvariantCulture);
                }
                else
                {
                    _currentExport.ExportDate = DateTime.Now;
                }
                if (!string.IsNullOrWhiteSpace(txtPay.Text))
                {
                    _currentExport.Pay = Convert.ToDouble(txtPay.Text);
                }
                if (_bookingRoom != null && _bookingRoom.Id > 0)
                {
                    _currentExport.BookingRoom = _bookingRoom;
                    _currentExport.Room        = _bookingRoom.Room;
                }
                Module.SaveOrUpdate(_currentExport, UserIdentity);

                ShowErrors("Cập nhật dữ liệu thành công");

                #endregion

                double sum = 0;

                foreach (RepeaterItem item in rptProductList.Items)
                {
                    HiddenField hddProductExportId = item.FindControl("hddProductExportId") as HiddenField;
                    HiddenField hddProductId       = (HiddenField)item.FindControl("hddProductId");

                    TextBox txtCodeProduct  = item.FindControl("txtCodeProduct") as TextBox;
                    TextBox txtQuantity     = item.FindControl("txtQuantity") as TextBox;
                    TextBox txtUnitPrice    = item.FindControl("txtUnitPrice") as TextBox;
                    TextBox txtTotal        = item.FindControl("txtTotal") as TextBox;
                    var     ddlUnit         = (DropDownList)item.FindControl("ddlUnit");
                    TextBox txtDiscount     = item.FindControl("txtDiscount") as TextBox;
                    var     ddlDiscountType = item.FindControl("ddlDiscountType") as DropDownList;

                    if (!string.IsNullOrEmpty(hddProductExportId.Value))
                    {
                        int             id            = Convert.ToInt32(hddProductExportId.Value);
                        IvProductExport productExport = Module.GetById <IvProductExport>(id);

                        IvProduct proCheck = Module.IvProductGetByCode(txtCodeProduct.Text.Trim(), storage);
                        if (!string.IsNullOrWhiteSpace(hddProductId.Value))
                        {
                            proCheck = Module.GetById <IvProduct>(Convert.ToInt32(hddProductId.Value));
                        }
                        if (proCheck != null && proCheck.Id > 0)
                        {
                            productExport.Product = proCheck;
                            if (!string.IsNullOrWhiteSpace(txtQuantity.Text))
                            {
                                productExport.Quantity = Convert.ToInt32(txtQuantity.Text);
                            }
                            if (!string.IsNullOrWhiteSpace(txtUnitPrice.Text))
                            {
                                productExport.UnitPrice = Convert.ToDouble(txtUnitPrice.Text);
                            }
                            if (!string.IsNullOrWhiteSpace(txtQuantity.Text) && !string.IsNullOrWhiteSpace(txtUnitPrice.Text))
                            {
                                productExport.Total = Convert.ToInt32(txtQuantity.Text) * Convert.ToDouble(txtUnitPrice.Text);
                            }
                            productExport.Export  = _currentExport;
                            productExport.Storage = storage;
                            if (!string.IsNullOrWhiteSpace(txtDiscount.Text))
                            {
                                if (ddlDiscountType.SelectedValue == "0")
                                {
                                    productExport.Total = productExport.Total - ((productExport.Total / 100) * Convert.ToInt32((txtDiscount.Text)));
                                }
                                else
                                {
                                    productExport.Total = productExport.Total - Convert.ToInt32(txtDiscount.Text);
                                }
                            }
                            sum += productExport.Total;
                            if (!string.IsNullOrWhiteSpace(ddlUnit.SelectedValue))
                            {
                                productExport.Unit = Module.GetById <IvUnit>(Convert.ToInt32(ddlUnit.SelectedValue));
                                productExport.QuanityRateParentUnit =
                                    IvProductUtil.ConvertRateParentUnit(productExport.Quantity, productExport.Unit);
                            }
                            if (!string.IsNullOrWhiteSpace(txtDiscount.Text))
                            {
                                productExport.Discount     = Convert.ToInt32(txtDiscount.Text);
                                productExport.DiscountType = Convert.ToInt32(ddlDiscountType.SelectedValue);
                            }
                            Module.SaveOrUpdate(productExport, UserIdentity);
                        }
                    }
                    else
                    {
                        IvProductExport productExport = new IvProductExport();

                        IvProduct proCheck = Module.IvProductGetByCode(txtCodeProduct.Text.Trim(), storage);
                        if (!string.IsNullOrWhiteSpace(hddProductId.Value))
                        {
                            proCheck = Module.GetById <IvProduct>(Convert.ToInt32(hddProductId.Value));
                        }
                        if (proCheck != null && proCheck.Id > 0)
                        {
                            productExport.Product = proCheck;
                            if (!string.IsNullOrWhiteSpace(txtQuantity.Text))
                            {
                                productExport.Quantity = Convert.ToInt32(txtQuantity.Text);
                            }
                            if (!string.IsNullOrWhiteSpace(txtUnitPrice.Text))
                            {
                                productExport.UnitPrice = Convert.ToDouble(txtUnitPrice.Text);
                            }
                            if (!string.IsNullOrWhiteSpace(txtQuantity.Text) && !string.IsNullOrWhiteSpace(txtUnitPrice.Text))
                            {
                                productExport.Total = Convert.ToInt32(txtQuantity.Text) * Convert.ToDouble(txtUnitPrice.Text);
                            }
                            productExport.Export = _currentExport;
                            if (!string.IsNullOrWhiteSpace(txtDiscount.Text))
                            {
                                if (ddlDiscountType.SelectedValue == "0")
                                {
                                    productExport.Total = productExport.Total - ((productExport.Total / 100) * Convert.ToInt32((txtDiscount.Text)));
                                }
                                else
                                {
                                    productExport.Total = productExport.Total - Convert.ToInt32(txtDiscount.Text);
                                }
                            }
                            sum += productExport.Total;
                            productExport.Storage = storage;
                            if (!string.IsNullOrWhiteSpace(ddlUnit.SelectedValue))
                            {
                                productExport.Unit = Module.GetById <IvUnit>(Convert.ToInt32(ddlUnit.SelectedValue));
                                productExport.QuanityRateParentUnit =
                                    IvProductUtil.ConvertRateParentUnit(productExport.Quantity, productExport.Unit);
                            }
                            if (!string.IsNullOrWhiteSpace(txtDiscount.Text))
                            {
                                productExport.Discount     = Convert.ToInt32(txtDiscount.Text);
                                productExport.DiscountType = Convert.ToInt32(ddlDiscountType.SelectedValue);
                            }
                            Module.SaveOrUpdate(productExport, UserIdentity);
                        }
                    }
                }
                _currentExport.Total = sum;
                if (_currentExport.Pay >= _currentExport.Total && _currentExport.Total > 0)
                {
                    _currentExport.Status = IvExportType.Paid;
                }
                else
                {
                    _currentExport.Status = IvExportType.Pay;
                }
                Module.SaveOrUpdate(_currentExport, UserIdentity);
                LoadInfoExport();
                BindrptProductList();

                PageRedirect(string.Format("IvExportAdd.aspx?NodeId={0}&SectionId={1}&ExportId={2}", Node.Id,
                                           Section.Id, _currentExport.Id));
            }
            catch (Exception ex)
            {
                ShowErrors(ex.Message);
            }
        }
Пример #11
0
        protected void btnSaveProductImport_Click(object sender, EventArgs e)
        {
            try
            {
                #region ---Save Current Export---

                CurrentImport.Name = txtName.Text;
                int flag = Module.CountImportGetByCode(Request.QueryString, UserIdentity, txtCode.Text);
                if (flag > 0 && CurrentImport.Id <= 0)
                {
                    ShowError("Mã phiếu đã tồn tại");
                    return;
                }
                _currentImport.Code   = txtCode.Text;
                _currentImport.Detail = txtDetail.Text;
                if (!string.IsNullOrWhiteSpace(ddlAgency.SelectedValue))
                {
                    _currentImport.Agency = Module.AgencyGetById(Convert.ToInt32(ddlAgency.SelectedValue));
                }
                _currentImport.ImportedBy = txtImportBy.Text;
                if (!string.IsNullOrEmpty(txtImportedDate.Text))
                {
                    _currentImport.ImportDate = DateTime.ParseExact(txtImportedDate.Text, "dd/MM/yyyy",
                                                                    CultureInfo.InvariantCulture);
                }
                else
                {
                    _currentImport.ImportDate = DateTime.Now;
                }
                IvStorage storage = null;
                if (!string.IsNullOrEmpty(ddlStorage.SelectedValue))
                {
                    storage = Module.GetById <IvStorage>(Convert.ToInt32(ddlStorage.SelectedValue));
                }
                _currentImport.Storage = storage;
                if (storage != null && storage.Cruise != null)
                {
                    _currentImport.Cruise = storage.Cruise;
                }
                Module.SaveOrUpdate(_currentImport, UserIdentity);

                #endregion

                double sum = 0;

                foreach (RepeaterItem item in rptProductList.Items)
                {
                    HiddenField hddProductImportId = (HiddenField)item.FindControl("hddProductImportId");
                    HiddenField hddProductId       = (HiddenField)item.FindControl("hddProductId");
                    TextBox     txtCodeProduct     = (TextBox)item.FindControl("txtCodeProduct");
                    TextBox     txtQuantity        = (TextBox)item.FindControl("txtQuantity");
                    TextBox     txtUnitPrice       = (TextBox)item.FindControl("txtUnitPrice");
                    var         ddlUnit            = (DropDownList)item.FindControl("ddlUnit");

                    if (!string.IsNullOrEmpty(hddProductImportId.Value))
                    {
                        int             id            = Convert.ToInt32(hddProductImportId.Value);
                        IvProductImport productImport = Module.GetById <IvProductImport>(id);

                        productImport.Product = Module.IvProductGetByCode(txtCodeProduct.Text.Trim(), _currentImport.Storage);
                        if (!string.IsNullOrWhiteSpace(hddProductId.Value))
                        {
                            productImport.Product = Module.GetById <IvProduct>(Convert.ToInt32(hddProductId.Value));
                        }
                        if (!string.IsNullOrWhiteSpace(ddlUnit.SelectedValue))
                        {
                            productImport.Unit = Module.GetById <IvUnit>(Convert.ToInt32(ddlUnit.SelectedValue));
                        }
                        if (!string.IsNullOrWhiteSpace(txtQuantity.Text))
                        {
                            productImport.Quantity = Convert.ToInt32(txtQuantity.Text);
                        }
                        if (!string.IsNullOrWhiteSpace(txtUnitPrice.Text))
                        {
                            productImport.UnitPrice = Convert.ToDouble(txtUnitPrice.Text);
                        }
                        if (!string.IsNullOrWhiteSpace(txtQuantity.Text) && !string.IsNullOrWhiteSpace(txtUnitPrice.Text))
                        {
                            productImport.Total = Convert.ToInt32(txtQuantity.Text) * Convert.ToDouble(txtUnitPrice.Text);
                        }
                        productImport.Import  = CurrentImport;
                        productImport.Storage = storage;
                        sum += productImport.Total;

                        if (productImport.Product != null && productImport.Product.Id > 0)
                        {
                            Module.SaveOrUpdate(productImport, UserIdentity);
                        }
                    }
                    else
                    {
                        IvProductImport productImport = new Domain.IvProductImport();

                        productImport.Product = Module.IvProductGetByCode(txtCodeProduct.Text.Trim(), _currentImport.Storage);
                        if (!string.IsNullOrWhiteSpace(hddProductId.Value))
                        {
                            productImport.Product = Module.GetById <IvProduct>(Convert.ToInt32(hddProductId.Value));
                        }
                        if (ddlUnit != null && !string.IsNullOrWhiteSpace(ddlUnit.SelectedValue))
                        {
                            productImport.Unit = Module.GetById <IvUnit>(Convert.ToInt32(ddlUnit.SelectedValue));
                        }
                        if (!string.IsNullOrWhiteSpace(txtQuantity.Text))
                        {
                            productImport.Quantity = Convert.ToInt32(txtQuantity.Text);
                        }
                        if (!string.IsNullOrWhiteSpace(txtUnitPrice.Text))
                        {
                            productImport.UnitPrice = Convert.ToDouble(txtUnitPrice.Text);
                        }
                        if (!string.IsNullOrWhiteSpace(txtQuantity.Text) && !string.IsNullOrWhiteSpace(txtUnitPrice.Text))
                        {
                            productImport.Total = Convert.ToInt32(txtQuantity.Text) * Convert.ToDouble(txtUnitPrice.Text);
                        }
                        productImport.Import  = CurrentImport;
                        productImport.Storage = storage;

                        sum += productImport.Total;

                        if (productImport.Product != null && productImport.Product.Id > 0)
                        {
                            Module.SaveOrUpdate(productImport, UserIdentity);
                        }
                    }
                }

                CurrentImport.Total = sum;
                Module.SaveOrUpdate(CurrentImport, UserIdentity);

                BindrptProductImportList();

                PageRedirect(string.Format("IvImportAdd.aspx?NodeId={0}&SectionId={1}&ImportId={2}", Node.Id, Section.Id,
                                           _currentImport.Id));
            }
            catch (Exception ex)
            {
                ShowErrors(ex.Message);
            }
        }