Ejemplo n.º 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());
        }
        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);
        }
        protected void rpItems_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            MachSummaryDAL dal  = new MachSummaryDAL();
            MachLookupDAL  lDAL = new MachLookupDAL();

            if (e.CommandName == "Add")
            {
                TextBox      txtMachIntroAdd = e.Item.FindControl("txtMachIntroAdd") as TextBox;
                DropDownList ddlMachNameAdd  = e.Item.FindControl("ddlMachNameAdd") as DropDownList;
                DropDownList ddlMachUnitAdd  = e.Item.FindControl("ddlMachUnitAdd") as DropDownList;
                TextBox      txtQtyAdd       = e.Item.FindControl("txtQtyAdd") as TextBox;
                TextBox      txtRemarkAdd    = e.Item.FindControl("txtRemarkAdd") as TextBox;


                MachSummary summary = new MachSummary();
                summary.MachId    = MachId;
                summary.MachIntro = txtMachIntroAdd.Text;
                summary.MachName  = Utility.GetSelectedText(ddlMachNameAdd);
                summary.Unit      = Utility.GetSelectedText(ddlMachUnitAdd);
                summary.Qty       = !string.IsNullOrEmpty(txtQtyAdd.Text) ? int.Parse(txtQtyAdd.Text) : 0;
                summary.Remark    = txtRemarkAdd.Text;
                summary.ImagePath = lDAL.GetMachLookupById(int.Parse(Utility.GetSelectedValue(ddlMachNameAdd))).MachIdentity;
                dal.AddMachSummary(summary);
                dal.Save();
            }
            else if (e.CommandName == "Save")
            {
                HiddenField hdId    = e.Item.FindControl("hdId") as HiddenField;
                MachSummary summary = dal.GetSummaryById(int.Parse(hdId.Value));

                TextBox      txtMachIntro = e.Item.FindControl("txtMachIntro") as TextBox;
                DropDownList ddlMachName  = e.Item.FindControl("ddlMachName") as DropDownList;
                DropDownList ddlMachUnit  = e.Item.FindControl("ddlMachUnit") as DropDownList;
                TextBox      txtQty       = e.Item.FindControl("txtQty") as TextBox;
                TextBox      txtRemark    = e.Item.FindControl("txtRemark") as TextBox;

                summary.MachIntro = txtMachIntro.Text;
                summary.MachName  = Utility.GetSelectedText(ddlMachName);
                summary.Unit      = Utility.GetSelectedText(ddlMachUnit);
                summary.Qty       = !string.IsNullOrEmpty(txtQty.Text) ? int.Parse(txtQty.Text) : 0;
                summary.Remark    = txtRemark.Text;
                summary.ImagePath = lDAL.GetMachLookupById(int.Parse(Utility.GetSelectedValue(ddlMachName))).MachIdentity;

                dal.Save();
            }
            else if (e.CommandName == "Delete")
            {
                HiddenField hdId = e.Item.FindControl("hdId") as HiddenField;
                dal.DeleteSummary(int.Parse(hdId.Value));
            }

            BindControl();
            SetFocus(btnLoc);
        }
Ejemplo n.º 4
0
        public static List <NameValueItem> GetMachTypeList()
        {
            MachLookupDAL dal    = new MachLookupDAL();
            var           result = from m in dal.GetAllMach()
                                   select new NameValueItem()
            {
                Name  = m.Name,
                Value = m.Mach_Id.ToString()
            };

            return(result.ToList());
        }
        protected void rpMachiningInstall_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            MachLookupDAL dal = new MachLookupDAL();

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

                var machLookup = new MachLookUp();
                machLookup.Code            = txtCodeAdd.Text;
                machLookup.IdentityImgPath = string.Empty;
                machLookup.Intro           = txtRemarkAdd.Text;
                machLookup.IsActive        = true;
                machLookup.MachIdentity    = txtMachIdentityAdd.Text;
                machLookup.Name            = txtNameAdd.Text;
                machLookup.PriceM          = double.Parse(txtPriceMAdd.Text);
                machLookup.PriceM2         = double.Parse(txtPriceM2Add.Text);
                machLookup.PriceOther      = double.Parse(txtPriceOtherAdd.Text);

                dal.AddMachLookup(machLookup);
                dal.Save();
            }
            else if (e.CommandName == "Save")
            {
                var hdId       = e.Item.FindControl("hdId") as HiddenField;
                var machLookup = dal.GetMachLookupById(int.Parse(hdId.Value));
                machLookup.PriceM       = double.Parse((e.Item.FindControl("txtPriceM") as TextBox).Text);
                machLookup.PriceM2      = double.Parse((e.Item.FindControl("txtPriceM2") as TextBox).Text);
                machLookup.PriceOther   = double.Parse((e.Item.FindControl("txtPriceOther") as TextBox).Text);
                machLookup.MachIdentity = (e.Item.FindControl("txtMachIdentity") as TextBox).Text;
                machLookup.Intro        = (e.Item.FindControl("txtRemark") as TextBox).Text;
                dal.Save();
            }
            else if (e.CommandName == "Delete")
            {
                var hdId = e.Item.FindControl("hdId") as HiddenField;
                dal.DeleteMachLookup(int.Parse(hdId.Value));
            }
            BindControl();
        }
        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);
        }
        public void BindControl()
        {
            MachLookupDAL dal = new MachLookupDAL();

            Utility.BindDataToRepeater(rpMachiningInstall, dal.GetAllMach());
        }
Ejemplo n.º 8
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));
        }
Ejemplo n.º 9
0
        protected void btnImport_Click(object sender, EventArgs e)
        {
            DeliveryDAL    dal   = new DeliveryDAL();
            LineItemDAL    lDal  = new LineItemDAL();
            MachSummaryDAL mDAL  = new MachSummaryDAL();
            MachLookupDAL  mlDAL = new MachLookupDAL();

            var                delivery        = dal.GetDeliveryByNo(DeliveryNo);
            StringBuilder      sb              = new StringBuilder(256);
            List <MachSummary> machSummaryList = new List <MachSummary>();

            foreach (ListItem item in cblMach.Items)
            {
                if (item.Selected)
                {
                    sb.Append(item.Text).Append("|");
                    machSummaryList.AddRange(mDAL.GetSummaryByMachId(int.Parse(item.Value)));
                }
            }
            delivery.MachList = sb.ToString();
            dal.Save();


            var lineItems = lDal.GetLineItemsBySource(this.DeliveryId, SysConst.SourceTypeDelivery);

            foreach (var item in lineItems)
            {
                lDal.DeleteItem(item.LineItem_Id);
            }

            foreach (var item in machSummaryList)
            {
                var machLook = mlDAL.GetMachLookupByName(item.MachName);
                var lineItem = new LineItem();
                lineItem.Intro      = item.MachIntro;
                lineItem.Name       = "加工";
                lineItem.Project    = item.MachName;
                lineItem.Quantity   = item.Qty;
                lineItem.Remark     = item.Remark;
                lineItem.SourceId   = DeliveryId;
                lineItem.SourceType = SysConst.SourceTypeDelivery;
                lineItem.Spec       = string.Empty;
                lineItem.Unit       = item.Unit;
                if (string.Equals(item.Unit, "米"))
                {
                    lineItem.UnitPrice = machLook.PriceM;
                }
                else if (string.Equals(item.Unit, "平方米"))
                {
                    lineItem.UnitPrice = machLook.PriceM2;
                }
                else
                {
                    lineItem.UnitPrice = machLook.PriceOther;
                }
                lDal.AddLineItem(lineItem);
            }

            lDal.Save();

            UIUtility.BindUserControl(lineItemControl, SysConst.SourceTypeDelivery, DeliveryId);
        }