public override void BindControl()
        {
            Utility.BindDataToDropdown(ddlCatelog, Utility.GetLookupList("分类"));
            Utility.BindDataToDropdown(ddlSubCatelog, Utility.GetLookupList("细类"));
            Utility.BindDataToDropdown(ddlLocation, Utility.GetLookupList("成品位置"));
            Utility.BindDataToDropdown(ddlSupplier, Utility.GetSupplierNameList());

            if (string.Equals(ViewType, "edit", StringComparison.OrdinalIgnoreCase))
            {
                EndProductDAL dal = new EndProductDAL();
                var           ep  = dal.GetEndProductById(EPId);
                txtCode.Text                = ep.Code;
                txtName.Text                = ep.Name;
                ddlCatelog.SelectedValue    = ep.Catelog;
                ddlSubCatelog.SelectedValue = ep.SubCatelog;
                txtLong.Text                = ep.Long == null ? string.Empty : ep.Long.Value.ToString();
                txtWidth.Text               = ep.Width == null ? string.Empty : ep.Width.Value.ToString();
                txtDeep.Text                = ep.Deepth == null ? string.Empty : ep.Deepth.Value.ToString();
                txtMaterial.Text            = ep.Material;
                txtPrice.Text               = ep.Price == null ? string.Empty : ep.Price.Value.ToString();
                txtPriceIn.Text             = ep.PurchasePrice == null ? string.Empty : ep.PurchasePrice.Value.ToString();
                txtQty.Text = ep.Qty == null ? string.Empty : ep.Qty.Value.ToString();
                ddlSupplier.SelectedValue = ep.SupplierName;
                ddlLocation.SelectedValue = ep.Location;
                txtRemark.Text            = ep.Remark;
                if (!string.IsNullOrEmpty(ep.ImgPth))
                {
                    imgPath.ImageUrl = Page.ResolveUrl(ep.ImgPth);
                }
            }
        }
예제 #2
0
        public CascadingDropDownNameValue[] GetProductByProject(
            string knownCategoryValues,
            string category)
        {
            StringDictionary categoryValues = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            string           project        = categoryValues["Project"];

            List <CascadingDropDownNameValue> result = new List <CascadingDropDownNameValue>();

            if (string.Equals(project, "Mach", StringComparison.OrdinalIgnoreCase))
            {
                MachLookupDAL dal   = new MachLookupDAL();
                var           machs = dal.GetAllMach();
                foreach (var item in machs)
                {
                    result.Add(new CascadingDropDownNameValue()
                    {
                        name = item.Name, value = item.Mach_Id.ToString()
                    });
                }
            }
            else if (string.Equals(project, "Install", StringComparison.OrdinalIgnoreCase))
            {
                InstallLookupDAL dal = new InstallLookupDAL();
                var installs         = dal.GetAllLookup();
                foreach (var item in installs)
                {
                    result.Add(new CascadingDropDownNameValue()
                    {
                        name = item.Name, value = item.Install_Id.ToString()
                    });
                }
            }
            else if (string.Equals(project, "Product", StringComparison.OrdinalIgnoreCase))
            {
                ProductDAL dal      = new ProductDAL();
                var        products = dal.GetAllProducts();
                foreach (var item in products)
                {
                    result.Add(new CascadingDropDownNameValue()
                    {
                        name = item.Product_Name, value = item.Product_Id.ToString()
                    });
                }
            }
            else if (string.Equals(project, "EndProduct", StringComparison.OrdinalIgnoreCase))
            {
                EndProductDAL dal         = new EndProductDAL();
                var           endProducts = dal.GetAllEndProductList();
                foreach (var item in endProducts)
                {
                    result.Add(new CascadingDropDownNameValue()
                    {
                        name = item.Name, value = item.EP_Id.ToString()
                    });
                }
            }

            return(result.ToArray());
        }
        private List <NameValueItem> GetProductByProject(string project)
        {
            List <NameValueItem> result = new List <NameValueItem>();

            if (string.Equals(project, "加工", StringComparison.OrdinalIgnoreCase))
            {
                MachLookupDAL dal   = new MachLookupDAL();
                var           machs = dal.GetAllMach();
                foreach (var item in machs)
                {
                    result.Add(new NameValueItem()
                    {
                        Name = item.Name, Value = item.Mach_Id.ToString()
                    });
                }
            }
            else if (string.Equals(project, "安装", StringComparison.OrdinalIgnoreCase))
            {
                InstallLookupDAL dal = new InstallLookupDAL();
                var installs         = dal.GetAllLookup();
                foreach (var item in installs)
                {
                    result.Add(new NameValueItem()
                    {
                        Name = item.Name, Value = item.Install_Id.ToString()
                    });
                }
            }
            else if (string.Equals(project, "材料", StringComparison.OrdinalIgnoreCase))
            {
                ProductDAL dal      = new ProductDAL();
                var        products = dal.GetAllProducts();
                foreach (var item in products)
                {
                    result.Add(new NameValueItem()
                    {
                        Name = item.Product_Name + "/" + item.Product_Code, Value = item.Product_Id.ToString()
                    });
                }
            }
            else if (string.Equals(project, "成品", StringComparison.OrdinalIgnoreCase))
            {
                EndProductDAL dal         = new EndProductDAL();
                var           endProducts = dal.GetAllEndProductList();
                foreach (var item in endProducts)
                {
                    result.Add(new NameValueItem()
                    {
                        Name = item.Name + "/" + item.Code, Value = item.EP_Id.ToString()
                    });
                }
            }

            return(result);
        }
예제 #4
0
        public static IEnumerable <NameValueItem> GetEndProductList()
        {
            EndProductDAL dal = new EndProductDAL();

            return(from ep in dal.GetAllEndProductList()
                   orderby ep.Name
                   select new NameValueItem()
            {
                Name = ep.Name + "/" + ep.Code, Value = ep.EP_Id.ToString()
            });
        }
        private List <EndProduct> GetEndProductList()
        {
            EndProductDAL dal    = new EndProductDAL();
            var           result = dal.SearchEndProduct(Utility.GetSelectedText(ddlCatelog),
                                                        Utility.GetSelectedText(ddlSubCatelog),
                                                        txtCode.Text,
                                                        txtName.Text,
                                                        Utility.GetSelectedText(ddlSupplier),
                                                        Utility.GetSelectedText(ddlLocation),
                                                        !string.IsNullOrEmpty(txtLongFinishProduct.Text) ? int.Parse(txtLongFinishProduct.Text) : -1,
                                                        !string.IsNullOrEmpty(txtWidthFinishProduct.Text) ? int.Parse(txtWidthFinishProduct.Text) : -1,
                                                        !string.IsNullOrEmpty(txtDeepFinishProduct.Text) ? int.Parse(txtDeepFinishProduct.Text) : -1,
                                                        !string.IsNullOrEmpty(txtPrice.Text) ? double.Parse(txtPrice.Text) : -1);

            return(result);
        }
        private PriceInfo GetPriceInfoByProduct(string project, int id)
        {
            PriceInfo price = new PriceInfo();

            if (string.Equals(project, "加工", StringComparison.OrdinalIgnoreCase))
            {
                MachLookupDAL dal  = new MachLookupDAL();
                var           mach = dal.GetMachLookupById(id);
                price.PriceM     = mach.PriceM.Value;
                price.PriceM2    = mach.PriceM2.Value;
                price.PriceOther = mach.PriceOther.Value;
            }
            else if (string.Equals(project, "安装", StringComparison.OrdinalIgnoreCase))
            {
                InstallLookupDAL dal = new InstallLookupDAL();
                var install          = dal.GetLookupById(id);
                price.PriceM     = install.PriceM.Value;
                price.PriceM2    = install.PriceM2.Value;
                price.PriceOther = install.PriceOther.Value;
            }
            else if (string.Equals(project, "材料", StringComparison.OrdinalIgnoreCase))
            {
                ProductDAL dal     = new ProductDAL();
                var        product = dal.GetProductById(id);
                price.PriceM     = product.PriceM.Value;
                price.PriceM2    = product.PriceM2.Value;
                price.PriceOther = product.PriceOther.Value;
            }
            else if (string.Equals(project, "成品", StringComparison.OrdinalIgnoreCase))
            {
                EndProductDAL dal        = new EndProductDAL();
                var           endProduct = dal.GetEndProductById(id);
                price.PriceM     = endProduct.Price.Value;
                price.PriceM2    = endProduct.Price.Value;
                price.PriceOther = endProduct.Price.Value;
            }
            return(price);
        }
 protected void rpProductList_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Footer)
     {
         EndProductDAL dal    = new EndProductDAL();
         var           result = dal.SearchEndProduct(Utility.GetSelectedText(ddlCatelog),
                                                     Utility.GetSelectedText(ddlSubCatelog),
                                                     txtCode.Text,
                                                     txtName.Text,
                                                     Utility.GetSelectedText(ddlSupplier),
                                                     Utility.GetSelectedText(ddlLocation),
                                                     !string.IsNullOrEmpty(txtLongFinishProduct.Text) ? int.Parse(txtLongFinishProduct.Text) : -1,
                                                     !string.IsNullOrEmpty(txtWidthFinishProduct.Text) ? int.Parse(txtWidthFinishProduct.Text) : -1,
                                                     !string.IsNullOrEmpty(txtDeepFinishProduct.Text) ? int.Parse(txtDeepFinishProduct.Text) : -1,
                                                     !string.IsNullOrEmpty(txtPrice.Text) ? double.Parse(txtPrice.Text) : -1);
         double qty              = result.Sum(r => r.Qty).Value;
         double amount           = result.Sum(r => r.Qty * r.Price).Value;
         var    lblTotalQuantity = e.Item.FindControl("lblTotalQuantity") as Label;
         var    lblTotalAmount   = e.Item.FindControl("lblTotalAmount") as Label;
         lblTotalQuantity.Text = Utility.Round(qty).ToString();
         lblTotalAmount.Text   = Utility.Round(amount).ToString();
     }
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            EndProduct ep       = null;
            var        isExists = new EndProductDAL().Exists(txtCode.Text, EPId);

            if (isExists == true)
            {
                Page.RegisterClientScriptBlock("endproduct", "<script language='javascript'>alert('已经有相同的产品!');</script>");
                return;
            }
            if (string.Equals(ViewType, "edit", StringComparison.OrdinalIgnoreCase))
            {
                EndProductDAL dal = new EndProductDAL();
                ep            = dal.GetEndProductById(EPId);
                ep.Code       = txtCode.Text;
                ep.Name       = txtName.Text;
                ep.Catelog    = Utility.GetSelectedText(ddlCatelog);
                ep.SubCatelog = Utility.GetSelectedText(ddlSubCatelog);
                if (!string.IsNullOrEmpty(txtLong.Text))
                {
                    ep.Long = int.Parse(txtLong.Text);
                }
                if (!string.IsNullOrEmpty(txtWidth.Text))
                {
                    ep.Width = int.Parse(txtWidth.Text);
                }
                if (!string.IsNullOrEmpty(txtDeep.Text))
                {
                    ep.Deepth = int.Parse(txtDeep.Text);
                }
                ep.Material = txtMaterial.Text;
                if (!string.IsNullOrEmpty(txtPrice.Text))
                {
                    ep.Price = double.Parse(txtPrice.Text);
                }
                if (!string.IsNullOrEmpty(txtPriceIn.Text))
                {
                    ep.PurchasePrice = double.Parse(txtPriceIn.Text);
                }
                if (!string.IsNullOrEmpty(txtQty.Text))
                {
                    ep.Qty = int.Parse(txtQty.Text);
                }
                ep.SupplierName = Utility.GetSelectedText(ddlSupplier);
                ep.Location     = Utility.GetSelectedText(ddlLocation);
                ep.Remark       = txtRemark.Text;
                if (!string.IsNullOrEmpty(filePic.FileName))
                {
                    string serverFilePath = string.Empty;
                    Utility.UploadFile(filePic, "EndProductImage", SourceNo, ref serverFilePath);
                    ep.ImgPth = serverFilePath;
                }
                dal.Save();
            }
            else if (string.Equals(ViewType, "create", StringComparison.OrdinalIgnoreCase))
            {
                EndProductDAL dal = new EndProductDAL();
                ep            = new EndProduct();
                ep.Code       = txtCode.Text;
                ep.Name       = txtName.Text;
                ep.Catelog    = Utility.GetSelectedText(ddlCatelog);
                ep.SubCatelog = Utility.GetSelectedText(ddlSubCatelog);
                if (!string.IsNullOrEmpty(txtLong.Text))
                {
                    ep.Long = int.Parse(txtLong.Text);
                }
                if (!string.IsNullOrEmpty(txtWidth.Text))
                {
                    ep.Width = int.Parse(txtWidth.Text);
                }
                if (!string.IsNullOrEmpty(txtDeep.Text))
                {
                    ep.Deepth = int.Parse(txtDeep.Text);
                }
                ep.Material = txtMaterial.Text;
                if (!string.IsNullOrEmpty(txtPrice.Text))
                {
                    ep.Price = double.Parse(txtPrice.Text);
                }
                if (!string.IsNullOrEmpty(txtPriceIn.Text))
                {
                    ep.PurchasePrice = double.Parse(txtPriceIn.Text);
                }
                if (!string.IsNullOrEmpty(txtQty.Text))
                {
                    ep.Qty = int.Parse(txtQty.Text);
                }
                ep.SupplierName = Utility.GetSelectedText(ddlSupplier);
                ep.Location     = Utility.GetSelectedText(ddlLocation);
                ep.Remark       = txtRemark.Text;
                if (!string.IsNullOrEmpty(filePic.FileName))
                {
                    string serverFilePath = string.Empty;
                    Utility.UploadFile(filePic, "EndProductImage", SourceNo, ref serverFilePath);
                    ep.ImgPth = serverFilePath;
                }
                dal.AddEndProduct(ep);
                dal.Save();
            }
            //redirect
            if (string.IsNullOrEmpty(CloseAfter))
            {
                Response.Redirect(string.Format("productform.aspx?type=ep&id={0}&viewtype=edit", ep.EP_Id));
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(FinishProductEditControl), "closecreate", "javascript:closeWindow();");
            }
        }
예제 #9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string projecttype = context.Request.QueryString["prj"];
            string productId   = context.Request.QueryString["prd"];
            string unit        = context.Request.QueryString["unit"];
            double price       = 0;

            if (string.Equals(projecttype, "EndProduct", StringComparison.OrdinalIgnoreCase))
            {
                EndProductDAL dal = new EndProductDAL();
                var           ep  = dal.GetEndProductById(int.Parse(projecttype));
                price = ep.Price.Value;
            }
            else if (string.Equals(projecttype, "Product", StringComparison.OrdinalIgnoreCase))
            {
                ProductDAL dal     = new ProductDAL();
                var        product = dal.GetProductById(int.Parse(productId));
                if (string.Equals(unit, "M", StringComparison.OrdinalIgnoreCase))
                {
                    price = product.PriceM.Value;
                }
                else if (string.Equals(unit, "M2", StringComparison.OrdinalIgnoreCase))
                {
                    price = product.PriceM2.Value;
                }
                else
                {
                    price = product.PriceOther.Value;
                }
            }
            else if (string.Equals(projecttype, "Install", StringComparison.OrdinalIgnoreCase))
            {
                InstallLookupDAL dal = new InstallLookupDAL();
                var install          = dal.GetLookupById(int.Parse(productId));
                if (string.Equals(unit, "M", StringComparison.OrdinalIgnoreCase))
                {
                    price = install.PriceM.Value;
                }
                else if (string.Equals(unit, "M2", StringComparison.OrdinalIgnoreCase))
                {
                    price = install.PriceM2.Value;
                }
                else
                {
                    price = install.PriceOther.Value;
                }
            }
            else if (string.Equals(projecttype, "Mach", StringComparison.OrdinalIgnoreCase))
            {
                MachLookupDAL dal  = new MachLookupDAL();
                var           mach = dal.GetMachLookupById(int.Parse(productId));
                if (string.Equals(unit, "M", StringComparison.OrdinalIgnoreCase))
                {
                    price = mach.PriceM.Value;
                }
                else if (string.Equals(unit, "M2", StringComparison.OrdinalIgnoreCase))
                {
                    price = mach.PriceM2.Value;
                }
                else
                {
                    price = mach.PriceOther.Value;
                }
            }
            context.Response.Write(new JavaScriptSerializer().Serialize(price));
        }