/// <summary> /// 根据险种ID绑定右侧数据 /// </summary> /// <param name="prodTypeID"></param> private void ReadyProductData(string prodTypeID) { EtNet_Models.ProductType productTypeModel = new EtNet_Models.ProductType(); ProductTypeManager productTypeBLL = new ProductTypeManager(); productTypeModel = productTypeBLL.GetModel(prodTypeID); txtName.Text = productTypeModel.ProdTypeName; hidNum.Value = productTypeModel.ProdTypeNo; if (productTypeModel.ParentId.Trim() != "0") { StringBuilder parentName = new StringBuilder(); parentName.Append(GetParent(productTypeModel.ParentId).ProdTypeNo); parentName.Append("-"); parentName.Append(GetParent(productTypeModel.ParentId).ProdTypeName); txtParent.Text = parentName.ToString(); //lblParentNo.Text = GetParent(productTypeModel.ParentId).ProdTypeNo; } else { txtParent.Text = ""; //lblParentNo.Text = ""; } hidParent.Value = productTypeModel.ProdTypeNo + "-" + productTypeModel.ProdTypeName; SetDdlTargetSelectIndex(productTypeModel.TargetTypeId.ToString()); SetDdlTypeSelectIndex(productTypeModel.ProdClass); }
//绑定险种树 private void StvProTypeBindData(TreeNodeCollection nds, string parentId) { ProductTypeManager proType = new ProductTypeManager(); TreeNode tn = null; DataTable dt = proType.GetAllList(); DataRow[] rows = dt.Select(string.Format("ParentId='{0}'", parentId)); int comid = Convert.ToInt32(Request.QueryString["id"].ToString()); IList <CompanyProd> cplist = CompanyProdManager.GetListByPro(comid); foreach (DataRow row in rows) { tn = new TreeNode(row["ProdTypeName"].ToString(), row["ProdTypeNo"].ToString()); foreach (CompanyProd item in cplist) { if (tn.Value == item.ProdTypeId) { tn.Checked = true; } } nds.Add(tn); StvProTypeBindData(tn.ChildNodes, row["ProdTypeNo"].ToString()); } }
public JsonResult Create(ProductType model) { try { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." })); } var productTypeCount = ProductTypeManager.GetCountDuplicate(model.sDescription.Trim()); if (productTypeCount.Count >= 1) { return(Json(new { Result = "ERROR", Message = "Item Exists." })); } model.dtDateAdd = DateTime.Now; model.kProductTypeId = Guid.NewGuid(); ProductTypeManager.Create(model); return(Json(new { Result = "OK", Record = 1 })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
private void InitData() { ProductTypeManager proBLL = new ProductTypeManager(); EtNet_Models.ProductType proModel = new EtNet_Models.ProductType(); object id = Request.QueryString["id"]; if (id == null || id.ToString() == string.Empty) { return; } object action = Request.QueryString["action"]; if (action != null && action.ToString() == "MODIFY") { proModel = proBLL.GetModel(Request.QueryString["id"].ToString().Split('-')[0]); txtName.Text = proModel.ProdTypeName; SetDdlTargetSelectIndex(proModel.TargetTypeId.ToString()); SetDdlTypeSelectIndex(proModel.ProdClass); if (proBLL.GetModel(proModel.ParentId) != null) { txtParent.Text = proBLL.GetModel(proModel.ParentId).ProdTypeName; } } else if (action != null && action.ToString() == "ADD") { txtParent.Text = Request.QueryString["id"].ToString(); } }
public JsonResult Edit(ProductType model) { try { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." })); } ProductType itemFound = ProductTypeManager.GetById(model.kProductTypeId); if (itemFound == null) { return(Json(new { Result = "ERROR", Message = "Item Not Found" })); } model.dtDateAdd = itemFound.dtDateAdd; model.dtDateUpdate = DateTime.Now; ProductTypeManager.Edit(model); return(Json(new { Result = "OK" })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public ProductManagerShould() { _db = new DatabaseInterface("BANGAZON_CLI_DB"); _productManager = new ProductManager(_db); _productTypeManager = new ProductTypeManager(_db); _db.RunCheckForTable(); }
private bool HasChildren(object pid) { ProductTypeManager proType = new ProductTypeManager(); DataTable dt = proType.GetList(string.Format("ParentId='{0}'", pid)); return(dt.Rows.Count > 0 ? true : false); }
public ActionResult Confirm(BookingClaimViewModel model, FormCollection collection) { // initial a reference number // model.Claim.sClaimNo = String.Format("{0}{1}", CharBooking.C.ToString(), ClaimNextItemNoManager.GetNextItemNo()); if (model.Product != null) { model.Product.Brand = BrandManager.GetById(model.Product.kBrandId); } model.Product.ProductType = ProductTypeManager.GetById(model.Product.kProductTypeId); string keyname; string keyvalue; int countvalue = 0; for (int i = 0; i <= collection.Count - 1; i++) { keyname = collection.AllKeys[i]; keyvalue = collection[i]; if (keyname.Contains("cause")) { countvalue++; } } if (countvalue > 1) { model.ClaimCauses = new List <ClaimCause>(); for (int i = 1; i <= countvalue / 4; i++) { ClaimCause claimCause = new ClaimCause(); claimCause.kClaimCauseId = Guid.NewGuid(); claimCause.sDescription = collection[String.Format("cause_description_{0}", i)]; claimCause.sNote = collection[String.Format("cause_note_{0}", i)]; if (!String.IsNullOrEmpty(claimCause.sDescription)) { int qty = 0; if (int.TryParse(collection[String.Format("cause_qty_{0}", i)], out qty)) { claimCause.iQty = qty; } Decimal price = 0; if (Decimal.TryParse(collection[String.Format("cause_price_{0}", i)], out price)) { claimCause.dPrice = price; } model.ClaimCauses.Add(claimCause); } } } this.HttpContext.Session["BookingViewModel"] = model; return(PartialView("Confirm", model)); }
/// <summary> /// 判断是否存在该险种 /// </summary> /// <param name="num"></param> /// <returns></returns> private bool ExitsNum(string num) { ProductTypeManager productTypeBLL = new ProductTypeManager(); productTypeBLL.GetList(string.Format("ProdTypeNo = '{0}'", num)); DataTable dt = productTypeBLL.GetList(string.Format("ProdTypeNo = '{0}'", num)); return(dt.Rows.Count > 0 ? true : false); }
public ActionResult Create() { ViewBag.ClaimCreate = "first active"; ViewBag.ProductTypes = ProductTypeManager.GetAll(); ViewBag.Brands = BrandManager.GetAll(); BookingClaimViewModel model = new BookingClaimViewModel(); return(View(model)); }
public JsonResult Search(string term) { try { var items = ProductTypeManager.GetBySearch(term); return(Json(items.Select(m => m.sDescription), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public JsonResult GetAll() { try { var items = ProductTypeManager.GetAll(); return(Json(new { Result = "OK", Options = items.Select(m => new { DisplayText = m.sDescription, Value = m.kProductTypeId }) })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public JsonResult Delete(Guid kProductTypeId) { try { //Thread.Sleep(50); ProductTypeManager.Delete(kProductTypeId); return(Json(new { Result = "OK" })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public JsonResult Search2(string term) { try { var items = ProductTypeManager.GetBySearch(term.Trim()); return(Json(items.Select(m => new { label = String.Format("{0}", m.sDescription), id = m.kProductTypeId }) , JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
//修改险种 private void ModifyProType(string proID) { ProductTypeManager productTypeBLL = new ProductTypeManager(); EtNet_Models.ProductType productTypeModel = new EtNet_Models.ProductType(); productTypeModel = productTypeBLL.GetModel(proID); productTypeModel.ProdClass = ddlType.SelectedValue; productTypeModel.ProdTypeName = txtName.Text; productTypeModel.TargetTypeId = Convert.ToInt32(ddlTarget.SelectedValue); productTypeBLL.Update(productTypeModel); hidId.Value = "MODIFY" + "$" + productTypeModel.ProdTypeName; }
//添加险种 private void AddProdType(string parent) { ProductTypeManager productTypeBLL = new ProductTypeManager(); EtNet_Models.ProductType productTypeModel = new EtNet_Models.ProductType(); productTypeModel.ParentId = parent; productTypeModel.ProdClass = ddlType.SelectedValue; productTypeModel.ProdTypeName = txtName.Text; productTypeModel.ProdTypeNo = MakeNum(parent); productTypeModel.TargetTypeId = Convert.ToInt32(ddlTarget.SelectedValue); productTypeBLL.Add(productTypeModel); hidId.Value = "ADD" + "$" + productTypeModel.ProdTypeNo + "$" + productTypeModel.ProdTypeName; }
public void AddProductToOrderShould() { CustomerManager _customerManager = new CustomerManager(_db); ActiveCustomer _activeManager = new ActiveCustomer(); ProductManager _productManager = new ProductManager(_db); ProductTypeManager _productTypeManager = new ProductTypeManager(_db); var newCustomerId = _customerManager.AddCustomer(new Customer("Bob", "Some Street", "City", "TN", 12345, "5555555555")); _activeManager.setActiveCustomerId(newCustomerId); var newProductTypeId = _productTypeManager.AddProductType(new ProductType("taco")); var newProductId = _productManager.CreateProduct(new Product(newProductTypeId, "taco", 25, "string description", 25, newCustomerId)); var orderId = _orderManager.CreateOrder(); var orderProductId = _orderManager.AddProductToOrder(newProductId, orderId); Assert.IsType <int>(orderProductId); }
public JsonResult Lists(string jtSearching = null, int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null) { try { //Thread.Sleep(200); var itemCount = ProductTypeManager.GetCountByFiltering(jtSearching); var items = ProductTypeManager.GetByFilterings(jtSearching, jtStartIndex, jtPageSize, jtSorting).ToList(); return(Json(new { Result = "OK", Records = items, TotalRecordCount = itemCount }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
private int?GetTargetType(string proTypeID) { TargetTypeManager targetType = new TargetTypeManager(); ProductTypeManager proTypeBLL = new ProductTypeManager(); ProductType proTypeModel = proTypeBLL.GetModel(proTypeID); if (proTypeModel != null) { TargetType tgModel = targetType.GetModel(Convert.ToInt32(proTypeModel.TargetTypeId)); if (tgModel != null) { ltrTargetType.Text = tgModel.TypeName; } return(proTypeModel.TargetTypeId); } else { return(null); } }
/// <summary> /// 添加险种 /// </summary> private void AddProType() { ProductTypeManager productTypeBLL = new ProductTypeManager(); EtNet_Models.ProductType productTypeModel = new EtNet_Models.ProductType(); productTypeModel.ParentId = stvProType.SelectedValue.Trim() == string.Empty ? "0" : stvProType.SelectedValue; productTypeModel.ProdClass = ddlType.SelectedValue; productTypeModel.ProdTypeName = txtName.Text; productTypeModel.ProdTypeNo = MakeNum(); productTypeModel.TargetTypeId = Convert.ToInt32(ddlTarget.SelectedValue); if (productTypeBLL.Add(productTypeModel)) { stvProType.Nodes.Clear(); StvProTypeBindData(stvProType.Nodes, "0"); stvProType.ExpandAll(); } StvProTypeBindData(stvProType.Nodes, "0"); }
/// <summary> /// 删除险种 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { if (stvProType.CheckedNodes.Count == 0) { ScriptManager.RegisterClientScriptBlock(this, GetType(), "key", "alert('请选择要删除的险种')", true); return; } EtNet_BLL.ProductManager product = new EtNet_BLL.ProductManager(); EtNet_BLL.ProductTypeManager productType = new ProductTypeManager(); foreach (TreeNode node in stvProType.CheckedNodes) { string where = string.Format("ProdTypeID='{0}'", node.Value); if (product.GetList(where).Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this, GetType(), "key", "alert('所选险种下含有项目数据,不能删除')", true); return; } } StringBuilder ids = new StringBuilder(); foreach (TreeNode node in stvProType.CheckedNodes) { ids.Append("'"); ids.Append(node.Value); ids.Append("'"); ids.Append(","); } if (ids.ToString().EndsWith(",")) { ids.Remove(ids.Length - 1, 1); } if (productType.DeleteList(ids.ToString())) { stvProType.Nodes.Clear(); StvProTypeBindData(stvProType.Nodes, "0"); stvProType.ExpandAll(); } }
/// <summary> /// 绑定险种树 /// </summary> /// <param name="nds">结点集合</param> /// <param name="parentId">父结点id</param> private void StvProTypeBindData(TreeNodeCollection nds, string parentId) { ProductTypeManager proType = new ProductTypeManager(); TreeNode tn = null; DataTable dt = proType.GetAllList(); //得到险种类别数据列表 DataRow[] rows = dt.Select(string.Format("ParentId='{0}'", parentId)); foreach (DataRow row in rows) { tn = new TreeNode(row["ProdTypeName"].ToString(), row["ProdTypeNo"].ToString()); //if (parentId.Trim() != string.Empty) //{ // tn.ShowCheckBox = true; //} nds.Add(tn); StvProTypeBindData(tn.ChildNodes, row["ProdTypeNo"].ToString()); } }
public ActionResult Edit(Guid id) { ViewBag.ClaimCreate = "first active"; ViewBag.SuperUser = StaffManager.GetAll().Where(m => m.vStaffPositionDescription == "หัวหน้าช่าง"); ViewBag.ProductTypes = ProductTypeManager.GetAll(); ViewBag.Brands = BrandManager.GetAll(); BookingClaimViewModel model = new BookingClaimViewModel(); var claim = ClaimManager.GetById(id); if (claim.dtInsuranceExpire.HasValue) { claim.dtInsuranceExpire = claim.dtInsuranceExpire.Value.AddYears(543); } model.Claim = claim; //model.Repair.RepairCauses = repair.RepairCauses; model.Insurance = claim.Insurance; model.Product = claim.Product; return(View(model)); }
private string MakeNum() { ProductTypeManager productTypeBLL = new ProductTypeManager(); EtNet_Models.ProductType productTypeModel = new EtNet_Models.ProductType(); productTypeModel = GetParent(stvProType.SelectedValue); StringBuilder num = new StringBuilder(); for (int i = 1; i < 1000; i++) { num.Append(productTypeModel.ProdTypeNo); switch (i.ToString().Length) { case 1: num.Append("00"); break; case 2: num.Append("0"); break; default: break; } num.Append(i.ToString()); if (!ExitsNum(num.ToString())) { break; } else { num.Clear(); } } return(num.ToString()); }
/// <summary> /// 修改险种 /// </summary> private void ModifyProType() { ProductTypeManager productTypeBLL = new ProductTypeManager(); EtNet_Models.ProductType productTypeModel = new EtNet_Models.ProductType(); if (stvProType.SelectedValue.Trim() != string.Empty) { productTypeModel.ParentId = stvProType.SelectedNode.Parent.Value; } else { productTypeModel.ParentId = " "; } productTypeModel.ProdClass = ddlType.SelectedValue; productTypeModel.ProdTypeName = txtName.Text; productTypeModel.ProdTypeNo = GetParent(stvProType.SelectedValue).ProdTypeNo; productTypeModel.TargetTypeId = Convert.ToInt32(ddlTarget.SelectedValue); if (productTypeBLL.Update(productTypeModel)) { stvProType.SelectedNode.Text = txtName.Text; } }
//Also need to pass in customer ID as an argument //Does the add product for a customer to sell. //Needs a product manager and a product type manager public static void DoAction(ProductManager products, ProductTypeManager ptm) { Console.Clear(); Console.WriteLine("What is the name of the product you are selling?"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); string name = Console.ReadLine(); //checks to make sure a name is entered name = NoEmptyAnswers.notAOne(name, "Please enter a name for the product you are selling"); Console.Clear(); Console.WriteLine($"Please provide a short description of {name}:"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); string desc = Console.ReadLine(); desc = NoEmptyAnswers.notAOne(desc, "Please enter a description for your product"); Double doublePrice = 0; //do loop will check that value is an integer do { Console.Clear(); Console.WriteLine($"How much do you wish to sell {name} for?"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); string price = Console.ReadLine(); price = NoEmptyAnswers.notAOne(price, "Please enter a price for your product"); try{ doublePrice = Convert.ToDouble(price); } catch { Console.WriteLine("Please enter a number for a price"); price = Console.ReadLine(); Double.TryParse(price, out doublePrice); } }while(doublePrice == 0); Console.Clear(); int intChoice = 0; int counter = 1; int selectedTypeIndex; productTypeList = ptm.GetProductTypeList(); //Checks to make sure the selection is in the range of the availble product types //Check the selected value agains the length of the list do { do { Console.WriteLine($"What kind of product is {name}?"); counter = 1; foreach (ProductType item in productTypeList) { Console.WriteLine($"{counter}. {item.name}"); counter++; } string choice = Console.ReadLine(); choice = NoEmptyAnswers.notAOne(choice, "Please select a number for a value type"); try{ intChoice = Convert.ToInt32(choice); } catch { Console.WriteLine("Please enter a number"); } }while(intChoice == 0); selectedTypeIndex = intChoice - 1; }while(selectedTypeIndex + 1 > productTypeList.Count); Console.Clear(); Console.WriteLine($"How many are you posting for sale?"); String quantity = Console.ReadLine(); int intQuantity = 0; quantity = NoEmptyAnswers.notAOne(quantity, "Please enter a quantity"); do { try{ intQuantity = Convert.ToInt32(quantity); } catch { Console.WriteLine("Please enter a quantity"); quantity = Console.ReadLine(); Int32.TryParse(quantity, out intQuantity); } }while(intQuantity == 0); Product newProduct = new Product(); newProduct.name = name; newProduct.description = desc; newProduct.price = doublePrice; newProduct.dateCreated = DateTime.Today; newProduct.quantity = intQuantity; newProduct.customerID = CustomerManager.currentCustomer.customerID; newProduct.productTypeID = productTypeList[selectedTypeIndex].productTypeID; products.AddNewProduct(newProduct); Console.Clear(); Console.WriteLine($"{newProduct.name} was successfully added! Press any key to continue"); Console.ReadKey(); }
public ActionResult Create(BookingClaimViewModel model, FormCollection collection) { try { //initial working status var workingStatusId = WorkingStatusManager.GetAll().Where(m => m.iDefault == (int)Working.Claiming).SingleOrDefault(); if (model.Product != null) { model.Product.Brand = BrandManager.GetById(model.Product.kBrandId); } model.Product.ProductType = ProductTypeManager.GetById(model.Product.kProductTypeId); #region SAVE CUSTOMER var insCount = InsuranceManager.GetCountDuplicate(model.Insurance.sInsuranceName.Trim()); if (insCount.Count <= 0) { Insurance insurance = new Insurance { kInsuranceId = Guid.NewGuid(), sInsuranceName = model.Insurance.sInsuranceName, sAddress1 = model.Insurance.sAddress1, sCity = model.Insurance.sCity, sZip = model.Insurance.sZip, sPhone = model.Insurance.sPhone, sMobile = model.Insurance.sMobile, sFax = model.Insurance.sFax, sEmailAddress = model.Insurance.sEmailAddress }; InsuranceManager.Create(insurance); model.Claim.Insurance = insurance; } else { model.Claim.Insurance = insCount[0]; } #endregion #region SAVE Brand var brandCount = BrandManager.GetCountDuplicate(model.Product.Brand.sBrandName.Trim()); if (brandCount.Count <= 0) { Brand brand = new Brand { kBrandId = Guid.NewGuid(), sBrandName = model.Product.Brand.sBrandName }; BrandManager.Create(brand); model.Product.Brand = brand; } else { model.Product.Brand = brandCount[0]; } #endregion #region SAVE Product Type var productTypeCount = ProductTypeManager.GetCountDuplicate(model.Product.ProductType.sDescription.Trim()); if (productTypeCount.Count <= 0) { ProductType productType = new ProductType { kProductTypeId = Guid.NewGuid(), sDescription = model.Product.ProductType.sDescription }; ProductTypeManager.Create(productType); model.Product.ProductType = productType; } else { model.Product.ProductType = productTypeCount[0]; } #endregion #region SAVE PRODUCT var productCount = ProductManager.GetCountDuplicate( model.Product.sProductName.Trim() //, model.Product.Brand.sBrandName.Trim() //, model.Product.ProductType.sDescription.Trim() ); if (productCount.Count <= 0) { Product product = new Product { kProductId = Guid.NewGuid(), kProductTypeId = productTypeCount.SingleOrDefault().kProductTypeId, kBrandId = brandCount.SingleOrDefault().kBrandId, sProductName = model.Product.sProductName, sProductModel = model.Product.sProductModel }; ProductManager.Create(product); model.Product = product; } else { model.Product = productCount[0]; } #endregion #region SAVE CLAIM BOOKING var repair = RepairManager.GetByRepairNo(model.Claim.sRepairNo ?? ""); //initial booking first character string char_number = CharBooking.C.ToString(); Claim claim = new Claim(); claim.dtDateUpdate = DateTime.Now; claim.kClaimId = Guid.NewGuid(); claim.kStaffId = (Guid)Membership.GetUser().ProviderUserKey; claim.kOwnerId = repair.kOwnerId ?? (Guid)Membership.GetUser().ProviderUserKey; claim.kInsuranceId = model.Claim.Insurance.kInsuranceId; claim.kProductId = model.Product.kProductId; claim.sRepairNo = model.Claim.sRepairNo; claim.sClaimNo = String.Format("{0}{1}", char_number, ClaimNextItemNoManager.GetNextItemNo()); claim.sSerial = model.Claim.sSerial; if (model.Claim.dtInsuranceExpire != null) { claim.dtInsuranceExpire = model.Claim.dtInsuranceExpire.Value.AddYears(-543); } model.Claim = claim; ClaimManager.Create(model.Claim); ClaimNextItemNoManager.IncreaseNextItemNo(); #region also pdate repair side repair.dtDateUpdate = DateTime.Now; repair.kStaffId = (Guid)Membership.GetUser().ProviderUserKey; RepairManager.Edit(repair); #endregion #endregion #region SAVE REPAIR WORKING STATUS ClaimStatus claimStatus = new ClaimStatus { kClaimStatusId = Guid.NewGuid(), kWorkingStatusId = workingStatusId.kWorkingStatusId, kStaffId = (Guid)Membership.GetUser().ProviderUserKey, kClaimId = model.Claim.kClaimId }; ClaimStatusManager.Create(claimStatus); #endregion #region UPDATE REPAIR WORKING STATUS if (!String.IsNullOrEmpty(model.Claim.sRepairNo)) { repair = RepairManager.GetByRepairNo(model.Claim.sRepairNo); RepairStatus repairStatus = new RepairStatus { kRepairStatusId = Guid.NewGuid(), kWorkingStatusId = workingStatusId.kWorkingStatusId, kStaffId = (Guid)Membership.GetUser().ProviderUserKey, kRepairId = repair.kRepairId }; RepairStatusManager.Create(repairStatus); } #endregion #region SAVE CAUSE OF CLAIM //initial cause string keyname; string keyvalue; int countvalue = 0; for (int i = 0; i <= collection.Count - 1; i++) { keyname = collection.AllKeys[i]; keyvalue = collection[i]; if (keyname.Contains("cause")) { countvalue++; } } if (countvalue > 1) { model.ClaimCauses = new List <ClaimCause>(); for (int i = 1; i <= countvalue / 4; i++) { ClaimCause claimCause = new ClaimCause(); claimCause.kClaimCauseId = Guid.NewGuid(); claimCause.kClaimId = model.Claim.kClaimId; claimCause.kStaffId = (Guid)Membership.GetUser().ProviderUserKey; claimCause.sDescription = collection[String.Format("cause_description_{0}", i)]; claimCause.sNote = collection[String.Format("cause_note_{0}", i)]; if (!String.IsNullOrEmpty(claimCause.sDescription)) { int qty = 0; if (int.TryParse(collection[String.Format("cause_qty_{0}", i)], out qty)) { claimCause.iQty = qty; } Decimal price = 0; if (Decimal.TryParse(collection[String.Format("cause_price_{0}", i)], out price)) { claimCause.dPrice = price; } model.ClaimCauses.Add(claimCause); ClaimCourseManager.Create(claimCause); } } } if (model.ClaimCauses != null) { foreach (var item in model.ClaimCauses) { var causeCount = CauseManager.GetCountDuplicate(item.sDescription.Trim()); if (causeCount <= 0) { Cause cause = new Cause { kCauseId = Guid.NewGuid(), sDescription = item.sDescription.Trim() }; CauseManager.Create(cause); } } } #endregion } catch (Exception ex) { return(RedirectToAction("Error", "Home")); } Claim model2 = ClaimManager.GetById(model.Claim.kClaimId); //create remind for history RemindHistory remind = new RemindHistory { sRemind = model2.vMessage, kStaffId = model2.kStaffId }; RemindHistoryManager.Create(remind); var clientName = User.Identity.Name; Task.Factory.StartNew(() => { var clients = Hub.GetClients <RealTimeJTableDemoHub>(); clients.RecordCreated(clientName, model2); }); return(RedirectToAction("Index")); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; List <string> treenodes = new List <string>(); //存储列表数据 object id = context.Request.QueryString["id"]; //根据id值查找该公司下的险种数据 if (id == null || id.ToString() == string.Empty) { context.Response.Write("{'id':'1','pid':'0','name':'暂无数据'}"); context.Response.End(); } ProductTypeManager proType = new ProductTypeManager(); DataTable dt = proType.GetAllList(); IList <CompanyProd> comList = CompanyProdManager.GetListByPro(Convert.ToInt32(id)); if (comList.Count == 0) { context.Response.Write("[{'id':'1','pid':'0','name':'暂无数据','nocheck':'true'}]"); context.Response.End(); } StringBuilder ids = new StringBuilder(); foreach (CompanyProd com in comList) { ids.Append("'"); ids.Append(com.ProdTypeId); ids.Append("',"); } DataRow[] rows = dt.Select(string.Format("ProdTypeNo in ({0}) ", ids.ToString().TrimEnd(','))); List <string> parentList = new List <string>(); DataRow[] parents = dt.Select(string.Format("ParentId='0'")); foreach (DataRow parent in parents) { parentList.Add(parent["ProdTypeNo"].ToString().Trim()); string node = string.Format("{{ 'id':'{0}', 'pId':'{1}', 'name':'{2}', 'open':'true','nocheck':'true'}}", parent["ProdTypeNo"].ToString().Trim(), parent["ParentId"].ToString().Trim(), parent["ProdTypeName"]); treenodes.Add(node); } foreach (DataRow row in rows) { if (HasChildren(row["ProdTypeNo"])) { continue; } string parent = ""; foreach (string item in parentList) { if (row["ParentId"].ToString().StartsWith(item)) { parent = item; break; } } string node = string.Format("{{ 'id':'{0}', 'pId':'{1}', 'name':'{2}'}}", row["ProdTypeNo"].ToString().Trim(), parent, row["ProdTypeName"]); treenodes.Add(node); } string NodesData = string.Join(",", treenodes.ToArray()); context.Response.Write("[" + NodesData + "]"); context.Response.End(); }
// Method called from Program.cs switch case: 4 // Accepts 3 arguments, Instance of ProductManager, ProductTypeManager, and an int containing Customer ID // this method prompts user to first define new productType then product // Authored by : Tamela Lerma public static void DoAction(ProductManager prodManager, int custId, ProductTypeManager prodType) { Console.Clear(); int counter = 1; int prodTypeId; int choice; // used to store selected menu key value T.L. bool isANumber = true; // used to check that number value is entered T.L. Product product = new Product(); product.customerId = custId; // set CustomerId on Product from int that is passed in DoAction Method T.L. List <ProductType> prodList = prodType.GetProductTypes(); Console.WriteLine("Select Product Type"); foreach (ProductType item in prodList) { Console.WriteLine($"{counter}. {item.Name}"); counter++; } Console.WriteLine($"{counter}. Add New Product Type"); Console.Write(">"); choice = int.Parse(Console.ReadLine()); if (counter == choice) { Console.Clear(); Console.WriteLine("Enter Type of Product"); prodTypeId = prodType.AddProductType(Console.ReadLine()); } else { prodTypeId = prodList[choice - 1].Id; } product.productTypeId = prodTypeId; // Last Id entered into DB is returned in a ProductTypeManager ClassMethod // AddProductType returns that ID // that ID for the new ProductType is stored in an Int // Authored By : Tamela Lerma // The ProductTypeId property for product is set from this variable T.L. do { // set title Console.WriteLine("Enter Product Name"); product.title = Console.ReadLine(); Console.Write(">"); } while (product.title == ""); do { // set description Console.WriteLine("Enter Product Description"); product.description = Console.ReadLine(); Console.Write(">"); } while (product.description == ""); do { Console.WriteLine("Enter Product Price"); try { // set price product.price = double.Parse(Console.ReadLine()); Console.Write(">"); isANumber = true; } catch (System.FormatException) { Console.Clear(); Program.Warning("Invalid entry, try again."); isANumber = false; } }while (isANumber == false); do { Console.WriteLine("Enter Quantity"); try { // set quantity product.quantity = int.Parse(Console.ReadLine()); Console.Write(">"); isANumber = true; } catch (System.FormatException) { Console.Clear(); Program.Warning("Invalid entry, try again."); isANumber = false; } } while (isANumber == false); Console.Clear(); // Call Method from ProductManager Class and pass in new Product Object to be added to DB T.L. prodManager.AddProduct(product); Program.Warning("Product added."); }
/// <summary> /// 获取父级实体 /// </summary> /// <param name="parentID"></param> /// <returns></returns> private EtNet_Models.ProductType GetParent(string parentID) { ProductTypeManager productTypeBLL = new ProductTypeManager(); return(productTypeBLL.GetModel(parentID)); }