/// <summary> /// 增加一条数据 /// </summary> public bool Add(EtNet_Models.ProductType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ProductType("); strSql.Append("ProdTypeNo,ProdTypeName,ParentId,ProdClass,TargetTypeId)"); strSql.Append(" values ("); strSql.Append("@ProdTypeNo,@ProdTypeName,@ParentId,@ProdClass,@TargetTypeId)"); SqlParameter[] parameters = { new SqlParameter("@ProdTypeNo", SqlDbType.VarChar, 30), new SqlParameter("@ProdTypeName", SqlDbType.NVarChar, 60), new SqlParameter("@ParentId", SqlDbType.VarChar, 30), new SqlParameter("@ProdClass", SqlDbType.VarChar, 4), new SqlParameter("@TargetTypeId", SqlDbType.Int, 4) }; parameters[0].Value = model.ProdTypeNo; parameters[1].Value = model.ProdTypeName; parameters[2].Value = model.ParentId; parameters[3].Value = model.ProdClass; parameters[4].Value = model.TargetTypeId; int rows = DBHelper.ExecuteCommand(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(EtNet_Models.ProductType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ProductType set "); strSql.Append("ProdTypeName=@ProdTypeName,"); strSql.Append("ParentId=@ParentId,"); strSql.Append("ProdClass=@ProdClass,"); strSql.Append("TargetTypeId=@TargetTypeId"); strSql.Append(" where ProdTypeNo=@ProdTypeNo "); SqlParameter[] parameters = { new SqlParameter("@ProdTypeName", SqlDbType.NVarChar, 60), new SqlParameter("@ParentId", SqlDbType.VarChar, 30), new SqlParameter("@ProdClass", SqlDbType.VarChar, 4), new SqlParameter("@TargetTypeId", SqlDbType.Int, 4), new SqlParameter("@ProdTypeNo", SqlDbType.VarChar, 30) }; parameters[0].Value = model.ProdTypeName; parameters[1].Value = model.ParentId; parameters[2].Value = model.ProdClass; parameters[3].Value = model.TargetTypeId; parameters[4].Value = model.ProdTypeNo; int rows = DBHelper.ExecuteCommand(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <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 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(); } }
//修改险种 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; }
/// <summary> /// 点击新增按钮时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { if (stvProType.SelectedValue == string.Empty) { return; } //btnAdd.Enabled = btnChange.Enabled = false; //btnSave.Enabled = true; txtName.Text = ""; EtNet_Models.ProductType proTypeModel = GetParent(stvProType.SelectedValue); txtParent.Text = proTypeModel.ProdTypeNo + "-" + proTypeModel.ProdTypeName; //btnSave.CommandName = "ADD"; }
//添加险种 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; }
/// <summary> /// 得到一个对象实体 /// </summary> public EtNet_Models.ProductType GetModel(string ProdTypeNo) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ProdTypeNo,ProdTypeName,ParentId,ProdClass,TargetTypeId from ProductType "); strSql.Append(" where ProdTypeNo=@ProdTypeNo "); SqlParameter[] parameters = { new SqlParameter("@ProdTypeNo", SqlDbType.VarChar, 30) }; parameters[0].Value = ProdTypeNo; EtNet_Models.ProductType model = new EtNet_Models.ProductType(); DataTable ds = DBHelper.GetDataSet(strSql.ToString(), parameters); if (ds.Rows.Count > 0) { if (ds.Rows[0]["ProdTypeNo"] != null && ds.Rows[0]["ProdTypeNo"].ToString() != "") { model.ProdTypeNo = ds.Rows[0]["ProdTypeNo"].ToString(); } if (ds.Rows[0]["ProdTypeName"] != null && ds.Rows[0]["ProdTypeName"].ToString() != "") { model.ProdTypeName = ds.Rows[0]["ProdTypeName"].ToString(); } if (ds.Rows[0]["ParentId"] != null && ds.Rows[0]["ParentId"].ToString() != "") { model.ParentId = ds.Rows[0]["ParentId"].ToString(); } if (ds.Rows[0]["ProdClass"] != null && ds.Rows[0]["ProdClass"].ToString() != "") { model.ProdClass = ds.Rows[0]["ProdClass"].ToString(); } if (ds.Rows[0]["TargetTypeId"] != null && ds.Rows[0]["TargetTypeId"].ToString() != "") { model.TargetTypeId = int.Parse(ds.Rows[0]["TargetTypeId"].ToString()); } return(model); } 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"); }
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; } }