/// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Save_Click(object sender, ImageClickEventArgs e) { int num = 0; if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null) { int id = Convert.ToInt32(Request.QueryString["id"]); mod = PriceManageBLL.GetmodByid(id); if (txtprice.Text.Trim() != "") { mod.Price = Convert.ToDecimal(txtprice.Text.Trim()); } num = PriceManageBLL.Updatemod(mod); } else { mod = new PriceManageMOD(); mod.CustomNo = txtcustomerNo.Text.Trim(); if (txtprice.Text.Trim() != "") { mod.Price = Convert.ToDecimal(txtprice.Text.Trim()); } mod.ProductNo = txtproductNO.Text.Trim(); num = PriceManageBLL.Insertmod(mod); } if (num > 0) { ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "DetailsPageControl.CloseBox();alert('提交成功');DetailsPageControl.ReflushList('CustomerManage/PriceManage.aspx');", true); } else { ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "alert('提交失败');", true); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null) { int id = Convert.ToInt32(Request.QueryString["id"]); mod = PriceManageBLL.GetmodByid(id); if (mod != null) { //加载客户信息 txtcustomerNo.Text = mod.CustomNo; txtprice.Text = mod.Price.ToString(); txtproductNO.Text = mod.ProductNo; } //客户编号不允许修改 txtcustomerNo.Enabled = false; txtproductNO.Enabled = false; } } }
/// <summary> /// 根据主键id查询信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public static PriceManageMOD GetmodByid(int id) { PriceManageMOD mod = new PriceManageMOD(); string sqlcommandString = "select * from PriceManage where priceId=" + id; try { SqlDataReader reader = SqlHelper.ExecuteReader(sqlcommandString); if (reader.Read()) { mod.ProductNo = reader["ProductNo"].ToString(); mod.CustomNo = reader["CustomNo"].ToString(); mod.PriceId = Convert.ToInt32(reader["PriceId"].ToString()); mod.Price =Convert.ToDecimal( reader["Price"].ToString()); } reader.Close(); return mod; } catch (Exception e) { throw e; } }
/// <summary> /// 更新 /// </summary> /// <param name="dtomodList">数据对象</param> /// <returns></returns> public static int Updatemod(PriceManageMOD mod) { return PriceManageDAO.Updatemod(mod); }
/// <summary> /// 添加 /// </summary> /// <param name="dtomodList">对象</param> /// <returns></returns> public static int Insertmod(PriceManageMOD mod) { return PriceManageDAO.Insertmod(mod); }
/// <summary> /// 更新 /// </summary> /// <param name="dtomodList">数据对象</param> /// <returns></returns> public static int Updatemod(PriceManageMOD mod) { string sqlCommandString = "Update PriceManage Set price=@price Where priceId=@priceId"; SqlParameter[] arParams = new SqlParameter[2]; arParams[0] = new SqlParameter("@priceId", mod.PriceId); arParams[1] = new SqlParameter("@price", mod.Price); return SqlHelper.ExecuteNonQuery(CommandType.Text, sqlCommandString, arParams); }
/// <summary> /// 添加 /// </summary> /// <param name="dtomodList">对象</param> /// <returns></returns> public static int Insertmod(PriceManageMOD mod) { string sqlCommandString = "Insert Into PriceManage(customNo,productNo,price)Values(@customNo,@productNo,@price)"; SqlParameter[] arParams = new SqlParameter[3]; arParams[0] = new SqlParameter("@customNo", mod.CustomNo); arParams[1] = new SqlParameter("@productNo", mod.ProductNo); arParams[2] = new SqlParameter("@price", mod.Price); return SqlHelper.ExecuteNonQuery(CommandType.Text, sqlCommandString, arParams); }
/// <summary> /// 根据主键id查询信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public static PriceManageMOD GetmodByid(string CustomNo,string proType) { PriceManageMOD mod = new PriceManageMOD(); string sqlcommandString = "select * from PriceManage where CustomNo='"+CustomNo+"' and ProductNo='"+proType+"'"; try { SqlDataReader reader = SqlHelper.ExecuteReader(sqlcommandString); if (reader.Read()) { mod.ProductNo = reader["ProductNo"].ToString(); mod.CustomNo = reader["CustomNo"].ToString(); mod.PriceId = Convert.ToInt32(reader["PriceId"].ToString()); mod.Price = Convert.ToDecimal(reader["Price"].ToString()); reader.Close(); return mod; } else { reader.Close(); return null; } } catch (Exception e) { throw e; } }