Пример #1
0
        protected void rptProductList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header)
            {
                //    RepeaterOrder.FILE_NAME = "IvProductSelectorPage.aspx";
                //    RepeaterOrder.SetOrderLink(e, "Name", Request.QueryString);
                //    RepeaterOrder.SetOrderLink(e, "BarCode", Request.QueryString);
                //    RepeaterOrder.SetOrderLink(e, "Manufacturer", Request.QueryString);
                //    RepeaterOrder.SetOrderLink(e, "SalePrice", Request.QueryString);
                return;
            }

            IvProduct product = (IvProduct)e.Item.DataItem;

            HyperLink aName = e.Item.FindControl("hplName") as HyperLink;

            if (aName != null)
            {
                aName.Text = product.Name;
                aName.Attributes.CssStyle.Add("cursor", "pointer");
                aName.NavigateUrl = "javascript:;";
                string script = string.Format("Done('{0}','{1}')", product.Name.Trim().Replace("'", @"\'").Replace("\"", ""), product.Id);
                aName.Attributes.Add("onclick", script);
            }
            Label lblCode = e.Item.FindControl("lblCode") as Label;

            if (lblCode != null)
            {
                lblCode.Text = product.Code;
            }
        }
Пример #2
0
        protected void rptProductList_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName.ToLower())
            {
            case "delete":
                IvProduct product = Module.GetById <IvProduct>(Convert.ToInt32(e.CommandArgument));
                Module.Delete(product);
                BindrptProduct();
                break;

            default:
                break;
            }
        }
Пример #3
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();
         }
     }
 }
Пример #4
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";
         }
     }
 }
        protected void rptProductList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header)
            {
                //RepeaterOrder.FILE_NAME = "SaleProductInStock.aspx";
                //RepeaterOrder.SetOrderLink(e, "Name", Request.QueryString);
                //RepeaterOrder.SetOrderLink(e, "BarCode", Request.QueryString);
                //RepeaterOrder.SetOrderLink(e, "Manufacturer", Request.QueryString);
                //RepeaterOrder.SetOrderLink(e, "SalePrice", Request.QueryString);

                return;
            }

            IvProduct product = (IvProduct)e.Item.DataItem;

            HyperLink hplName = e.Item.FindControl("hplName") as HyperLink;

            if (hplName != null)
            {
                hplName.Text        = product.Name;
                hplName.NavigateUrl = string.Format("IvProductAdd.aspx?NodeId={0}&SectionID={1}&ProductID={2}", Node.Id,
                                                    Section.Id, product.Id);
            }
            var lblName = e.Item.FindControl("lblName") as Label;

            if (lblName != null)
            {
                lblName.Text = product.Name;
            }


            Label lblCode = e.Item.FindControl("lblCode") as Label;

            if (lblCode != null)
            {
                lblCode.Text = product.Code;
            }
            HyperLink hplEdit = e.Item.FindControl("hplEdit") as HyperLink;

            if (hplEdit != null)
            {
                hplEdit.NavigateUrl = string.Format("IvProductAdd.aspx?NodeId={0}&SectionId={1}&ProductId={2}", Node.Id,
                                                    Section.Id, product.Id);
            }

            //Check Hàng tồn kho

            var trItem = e.Item.FindControl("trItem") as HtmlControl;

            if (trItem != null)
            {
                trItem.Attributes.Add("style", "background: #ff572291;color: #fff;");
            }
            Label lblUnitInstock = e.Item.FindControl("lblUnitInstock") as Label;

            if (lblUnitInstock != null)
            {
                lblUnitInstock.Text = product.NumberInStock.ToString("#,0.#");
            }
            Label lblWarningLimit = e.Item.FindControl("lblWarningLimit") as Label;

            if (lblWarningLimit != null)
            {
                lblWarningLimit.Text = product.WarningLimit.ToString();
            }
            Label lblUnit = e.Item.FindControl("lblUnit") as Label;

            if (lblUnit != null)
            {
                if (product.Unit != null)
                {
                    lblUnit.Text = product.Unit.Name;
                }
            }
        }
Пример #6
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);
            }
        }