/// <summary> /// 增加一条数据 /// </summary> public bool Add(MyERP.Model.SAL_CUSTOM model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SAL_CUSTOM("); strSql.Append("CompanyCode,CustomerCode,CustomerLevel,Discount,DiscountGrade,TradeAmount,TradeAmountDate,TradeGrade,DueAmount,DueAmountDate,DueGrade,DueTime,DueTimeGrade,DueTimeDate,Remark)"); strSql.Append(" values ("); strSql.Append("@CompanyCode,@CustomerCode,@CustomerLevel,@Discount,@DiscountGrade,@TradeAmount,@TradeAmountDate,@TradeGrade,@DueAmount,@DueAmountDate,@DueGrade,@DueTime,@DueTimeGrade,@DueTimeDate,@Remark)"); SqlParameter[] parameters = { new SqlParameter("@CompanyCode", SqlDbType.NVarChar, 10), new SqlParameter("@CustomerCode", SqlDbType.NVarChar, 20), new SqlParameter("@CustomerLevel", SqlDbType.NVarChar, 20), new SqlParameter("@Discount", SqlDbType.Decimal, 9), new SqlParameter("@DiscountGrade", SqlDbType.Int, 4), new SqlParameter("@TradeAmount", SqlDbType.Decimal, 9), new SqlParameter("@TradeAmountDate", SqlDbType.SmallDateTime), new SqlParameter("@TradeGrade", SqlDbType.Int, 4), new SqlParameter("@DueAmount", SqlDbType.Decimal, 9), new SqlParameter("@DueAmountDate", SqlDbType.SmallDateTime), new SqlParameter("@DueGrade", SqlDbType.Int, 4), new SqlParameter("@DueTime", SqlDbType.Int, 4), new SqlParameter("@DueTimeGrade", SqlDbType.Int, 4), new SqlParameter("@DueTimeDate", SqlDbType.SmallDateTime), new SqlParameter("@Remark", SqlDbType.NVarChar, 200) }; parameters[0].Value = model.CompanyCode; parameters[1].Value = model.CustomerCode; parameters[2].Value = model.CustomerLevel; parameters[3].Value = model.Discount; parameters[4].Value = model.DiscountGrade; parameters[5].Value = model.TradeAmount; parameters[6].Value = model.TradeAmountDate; parameters[7].Value = model.TradeGrade; parameters[8].Value = model.DueAmount; parameters[9].Value = model.DueAmountDate; parameters[10].Value = model.DueGrade; parameters[11].Value = model.DueTime; parameters[12].Value = model.DueTimeGrade; parameters[13].Value = model.DueTimeDate; parameters[14].Value = model.Remark; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void ShowInfo() { MyERP.BLL.SAL_CUSTOM bll = new MyERP.BLL.SAL_CUSTOM(); MyERP.Model.SAL_CUSTOM model = bll.GetModel(); this.lblCompanyCode.Text = model.CompanyCode; this.lblCustomerCode.Text = model.CustomerCode; this.lblCustomerLevel.Text = model.CustomerLevel; this.lblDiscount.Text = model.Discount.ToString(); this.lblDiscountGrade.Text = model.DiscountGrade.ToString(); this.lblTradeAmount.Text = model.TradeAmount.ToString(); this.lblTradeAmountDate.Text = model.TradeAmountDate.ToString(); this.lblTradeGrade.Text = model.TradeGrade.ToString(); this.lblDueAmount.Text = model.DueAmount.ToString(); this.lblDueAmountDate.Text = model.DueAmountDate.ToString(); this.lblDueGrade.Text = model.DueGrade.ToString(); this.lblDueTime.Text = model.DueTime.ToString(); this.lblDueTimeGrade.Text = model.DueTimeGrade.ToString(); this.lblDueTimeDate.Text = model.DueTimeDate.ToString(); this.lblRemark.Text = model.Remark; }
/// <summary> /// 得到一个对象实体 /// </summary> public MyERP.Model.SAL_CUSTOM GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 CompanyCode,CustomerCode,CustomerLevel,Discount,DiscountGrade,TradeAmount,TradeAmountDate,TradeGrade,DueAmount,DueAmountDate,DueGrade,DueTime,DueTimeGrade,DueTimeDate,Remark from SAL_CUSTOM "); strSql.Append(" where "); SqlParameter[] parameters = { }; MyERP.Model.SAL_CUSTOM model = new MyERP.Model.SAL_CUSTOM(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtCompanyCode.Text.Trim().Length == 0) { strErr += "CompanyCode不能为空!\\n"; } if (this.txtCustomerCode.Text.Trim().Length == 0) { strErr += "CustomerCode不能为空!\\n"; } if (this.txtCustomerLevel.Text.Trim().Length == 0) { strErr += "CustomerLevel不能为空!\\n"; } if (!PageValidate.IsDecimal(txtDiscount.Text)) { strErr += "Discount格式错误!\\n"; } if (!PageValidate.IsNumber(txtDiscountGrade.Text)) { strErr += "DiscountGrade格式错误!\\n"; } if (!PageValidate.IsDecimal(txtTradeAmount.Text)) { strErr += "TradeAmount格式错误!\\n"; } if (!PageValidate.IsDateTime(txtTradeAmountDate.Text)) { strErr += "TradeAmountDate格式错误!\\n"; } if (!PageValidate.IsNumber(txtTradeGrade.Text)) { strErr += "TradeGrade格式错误!\\n"; } if (!PageValidate.IsDecimal(txtDueAmount.Text)) { strErr += "DueAmount格式错误!\\n"; } if (!PageValidate.IsDateTime(txtDueAmountDate.Text)) { strErr += "DueAmountDate格式错误!\\n"; } if (!PageValidate.IsNumber(txtDueGrade.Text)) { strErr += "DueGrade格式错误!\\n"; } if (!PageValidate.IsNumber(txtDueTime.Text)) { strErr += "DueTime格式错误!\\n"; } if (!PageValidate.IsNumber(txtDueTimeGrade.Text)) { strErr += "DueTimeGrade格式错误!\\n"; } if (!PageValidate.IsDateTime(txtDueTimeDate.Text)) { strErr += "DueTimeDate格式错误!\\n"; } if (this.txtRemark.Text.Trim().Length == 0) { strErr += "Remark不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string CompanyCode = this.txtCompanyCode.Text; string CustomerCode = this.txtCustomerCode.Text; string CustomerLevel = this.txtCustomerLevel.Text; decimal Discount = decimal.Parse(this.txtDiscount.Text); int DiscountGrade = int.Parse(this.txtDiscountGrade.Text); decimal TradeAmount = decimal.Parse(this.txtTradeAmount.Text); DateTime TradeAmountDate = DateTime.Parse(this.txtTradeAmountDate.Text); int TradeGrade = int.Parse(this.txtTradeGrade.Text); decimal DueAmount = decimal.Parse(this.txtDueAmount.Text); DateTime DueAmountDate = DateTime.Parse(this.txtDueAmountDate.Text); int DueGrade = int.Parse(this.txtDueGrade.Text); int DueTime = int.Parse(this.txtDueTime.Text); int DueTimeGrade = int.Parse(this.txtDueTimeGrade.Text); DateTime DueTimeDate = DateTime.Parse(this.txtDueTimeDate.Text); string Remark = this.txtRemark.Text; MyERP.Model.SAL_CUSTOM model = new MyERP.Model.SAL_CUSTOM(); model.CompanyCode = CompanyCode; model.CustomerCode = CustomerCode; model.CustomerLevel = CustomerLevel; model.Discount = Discount; model.DiscountGrade = DiscountGrade; model.TradeAmount = TradeAmount; model.TradeAmountDate = TradeAmountDate; model.TradeGrade = TradeGrade; model.DueAmount = DueAmount; model.DueAmountDate = DueAmountDate; model.DueGrade = DueGrade; model.DueTime = DueTime; model.DueTimeGrade = DueTimeGrade; model.DueTimeDate = DueTimeDate; model.Remark = Remark; MyERP.BLL.SAL_CUSTOM bll = new MyERP.BLL.SAL_CUSTOM(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MyERP.Model.SAL_CUSTOM model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SAL_CUSTOM set "); strSql.Append("CompanyCode=@CompanyCode,"); strSql.Append("CustomerCode=@CustomerCode,"); strSql.Append("CustomerLevel=@CustomerLevel,"); strSql.Append("Discount=@Discount,"); strSql.Append("DiscountGrade=@DiscountGrade,"); strSql.Append("TradeAmount=@TradeAmount,"); strSql.Append("TradeAmountDate=@TradeAmountDate,"); strSql.Append("TradeGrade=@TradeGrade,"); strSql.Append("DueAmount=@DueAmount,"); strSql.Append("DueAmountDate=@DueAmountDate,"); strSql.Append("DueGrade=@DueGrade,"); strSql.Append("DueTime=@DueTime,"); strSql.Append("DueTimeGrade=@DueTimeGrade,"); strSql.Append("DueTimeDate=@DueTimeDate,"); strSql.Append("Remark=@Remark"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@CompanyCode", SqlDbType.NVarChar, 10), new SqlParameter("@CustomerCode", SqlDbType.NVarChar, 20), new SqlParameter("@CustomerLevel", SqlDbType.NVarChar, 20), new SqlParameter("@Discount", SqlDbType.Decimal, 9), new SqlParameter("@DiscountGrade", SqlDbType.Int, 4), new SqlParameter("@TradeAmount", SqlDbType.Decimal, 9), new SqlParameter("@TradeAmountDate", SqlDbType.SmallDateTime), new SqlParameter("@TradeGrade", SqlDbType.Int, 4), new SqlParameter("@DueAmount", SqlDbType.Decimal, 9), new SqlParameter("@DueAmountDate", SqlDbType.SmallDateTime), new SqlParameter("@DueGrade", SqlDbType.Int, 4), new SqlParameter("@DueTime", SqlDbType.Int, 4), new SqlParameter("@DueTimeGrade", SqlDbType.Int, 4), new SqlParameter("@DueTimeDate", SqlDbType.SmallDateTime), new SqlParameter("@Remark", SqlDbType.NVarChar, 200) }; parameters[0].Value = model.CompanyCode; parameters[1].Value = model.CustomerCode; parameters[2].Value = model.CustomerLevel; parameters[3].Value = model.Discount; parameters[4].Value = model.DiscountGrade; parameters[5].Value = model.TradeAmount; parameters[6].Value = model.TradeAmountDate; parameters[7].Value = model.TradeGrade; parameters[8].Value = model.DueAmount; parameters[9].Value = model.DueAmountDate; parameters[10].Value = model.DueGrade; parameters[11].Value = model.DueTime; parameters[12].Value = model.DueTimeGrade; parameters[13].Value = model.DueTimeDate; parameters[14].Value = model.Remark; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MyERP.Model.SAL_CUSTOM DataRowToModel(DataRow row) { MyERP.Model.SAL_CUSTOM model = new MyERP.Model.SAL_CUSTOM(); if (row != null) { if (row["CompanyCode"] != null) { model.CompanyCode = row["CompanyCode"].ToString(); } if (row["CustomerCode"] != null) { model.CustomerCode = row["CustomerCode"].ToString(); } if (row["CustomerLevel"] != null) { model.CustomerLevel = row["CustomerLevel"].ToString(); } if (row["Discount"] != null && row["Discount"].ToString() != "") { model.Discount = decimal.Parse(row["Discount"].ToString()); } if (row["DiscountGrade"] != null && row["DiscountGrade"].ToString() != "") { model.DiscountGrade = int.Parse(row["DiscountGrade"].ToString()); } if (row["TradeAmount"] != null && row["TradeAmount"].ToString() != "") { model.TradeAmount = decimal.Parse(row["TradeAmount"].ToString()); } if (row["TradeAmountDate"] != null && row["TradeAmountDate"].ToString() != "") { model.TradeAmountDate = DateTime.Parse(row["TradeAmountDate"].ToString()); } if (row["TradeGrade"] != null && row["TradeGrade"].ToString() != "") { model.TradeGrade = int.Parse(row["TradeGrade"].ToString()); } if (row["DueAmount"] != null && row["DueAmount"].ToString() != "") { model.DueAmount = decimal.Parse(row["DueAmount"].ToString()); } if (row["DueAmountDate"] != null && row["DueAmountDate"].ToString() != "") { model.DueAmountDate = DateTime.Parse(row["DueAmountDate"].ToString()); } if (row["DueGrade"] != null && row["DueGrade"].ToString() != "") { model.DueGrade = int.Parse(row["DueGrade"].ToString()); } if (row["DueTime"] != null && row["DueTime"].ToString() != "") { model.DueTime = int.Parse(row["DueTime"].ToString()); } if (row["DueTimeGrade"] != null && row["DueTimeGrade"].ToString() != "") { model.DueTimeGrade = int.Parse(row["DueTimeGrade"].ToString()); } if (row["DueTimeDate"] != null && row["DueTimeDate"].ToString() != "") { model.DueTimeDate = DateTime.Parse(row["DueTimeDate"].ToString()); } if (row["Remark"] != null) { model.Remark = row["Remark"].ToString(); } } return(model); }