예제 #1
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());
        }
예제 #2
0
        protected void rpMachiningInstall_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            InstallLookupDAL dal = new InstallLookupDAL();

            if (e.CommandName == "Add")
            {
                if (e.Item.ItemType == ListItemType.Header)
                {
                    TextBox txtCodeAdd       = e.Item.FindControl("txtCodeAdd") as TextBox;
                    TextBox txtNameAdd       = e.Item.FindControl("txtNameAdd") as TextBox;
                    TextBox txtPriceMAdd     = e.Item.FindControl("txtPriceMAdd") as TextBox;
                    TextBox txtPriceM2Add    = e.Item.FindControl("txtPriceM2Add") as TextBox;
                    TextBox txtPriceOtherAdd = e.Item.FindControl("txtPriceOtherAdd") as TextBox;
                    TextBox txtRemarkAdd     = e.Item.FindControl("txtRemarkAdd") as TextBox;

                    InstallLookup lookup = new InstallLookup()
                    {
                        Code       = txtCodeAdd.Text,
                        Name       = txtNameAdd.Text,
                        PriceM     = double.Parse(txtPriceMAdd.Text),
                        PriceM2    = double.Parse(txtPriceM2Add.Text),
                        PriceOther = double.Parse(txtPriceOtherAdd.Text),
                        Intro      = txtRemarkAdd.Text,
                        IsActive   = true
                    };
                    dal.Add(lookup);
                    dal.Save();
                }
            }
            if (e.CommandName == "Delete")
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    HiddenField hfId = e.Item.FindControl("hfId") as HiddenField;
                    dal.Delete(int.Parse(hfId.Value));
                }
            }
            if (e.CommandName == "Save")
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    TextBox     txtPriceM     = e.Item.FindControl("txtPriceM") as TextBox;
                    TextBox     txtPriceM2    = e.Item.FindControl("txtPriceM2") as TextBox;
                    TextBox     txtPriceOther = e.Item.FindControl("txtPriceOther") as TextBox;
                    TextBox     txtRemark     = e.Item.FindControl("txtRemark") as TextBox;
                    HiddenField hfId          = e.Item.FindControl("hfId") as HiddenField;
                    var         lookup        = dal.GetLookupById(int.Parse(hfId.Value));
                    lookup.PriceM     = double.Parse(txtPriceM.Text);
                    lookup.PriceM2    = double.Parse(txtPriceM2.Text);
                    lookup.PriceOther = double.Parse(txtPriceOther.Text);
                    lookup.Intro      = txtRemark.Text;
                    dal.Save();
                }
            }
            BindRepeater();
        }
        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);
        }
        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);
        }
예제 #5
0
        private void BindRepeater()
        {
            InstallLookupDAL dal = new InstallLookupDAL();

            Utility.BindDataToRepeater(rpMachiningInstall, dal.GetAllLookup());
        }
예제 #6
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));
        }