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