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 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 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)); }