/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Supplier_BillType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_Supplier_BillType]("); strSql.Append("TaxRate,Type_id_BillType,Supplier_id)"); strSql.Append(" values ("); strSql.Append("@TaxRate,@Type_id_BillType,@Supplier_id)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@TaxRate", model.TaxRate), new SqlParameter("@Type_id_BillType", model.Type_id_BillType), new SqlParameter("@Supplier_id", model.Supplier_id) }; object obj = SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_Supplier_BillType ReaderBind(IDataReader dataReader) { Lebi_Supplier_BillType model = new Lebi_Supplier_BillType(); object ojb; ojb = dataReader["id"]; if (ojb != null && ojb != DBNull.Value) { model.id = (int)ojb; } ojb = dataReader["TaxRate"]; if (ojb != null && ojb != DBNull.Value) { model.TaxRate = (decimal)ojb; } ojb = dataReader["Type_id_BillType"]; if (ojb != null && ojb != DBNull.Value) { model.Type_id_BillType = (int)ojb; } ojb = dataReader["Supplier_id"]; if (ojb != null && ojb != DBNull.Value) { model.Supplier_id = (int)ojb; } return(model); }
protected void Page_Load(object sender, EventArgs e) { if (!Power("supplier_billtype_list", "发票管理")) { PageNoPower(); } int id = RequestTool.RequestInt("id", 0); model = B_Lebi_Supplier_BillType.GetModel("id = " + id + " and Supplier_id = " + CurrentSupplier.id + ""); if (model == null) { model = new Lebi_Supplier_BillType(); model.Type_id_BillType = 151; } }
/// <summary> /// 安全方式绑定对象表单 /// </summary> public Lebi_Supplier_BillType SafeBindForm(Lebi_Supplier_BillType model) { if (HttpContext.Current.Request["TaxRate"] != null) { model.TaxRate = Shop.Tools.RequestTool.RequestDecimal("TaxRate", 0); } if (HttpContext.Current.Request["Type_id_BillType"] != null) { model.Type_id_BillType = Shop.Tools.RequestTool.RequestInt("Type_id_BillType", 0); } if (HttpContext.Current.Request["Supplier_id"] != null) { model.Supplier_id = Shop.Tools.RequestTool.RequestInt("Supplier_id", 0); } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Supplier_BillType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_Supplier_BillType] set "); strSql.Append("[TaxRate]=@TaxRate,"); strSql.Append("[Type_id_BillType]=@Type_id_BillType,"); strSql.Append("[Supplier_id]=@Supplier_id"); strSql.Append(" where id=" + model.id); OleDbParameter[] parameters = { new OleDbParameter("@TaxRate", model.TaxRate), new OleDbParameter("@Type_id_BillType", model.Type_id_BillType), new OleDbParameter("@Supplier_id", model.Supplier_id) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Supplier_BillType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_Supplier_BillType]("); strSql.Append("[TaxRate],[Type_id_BillType],[Supplier_id])"); strSql.Append(" values ("); strSql.Append("@TaxRate,@Type_id_BillType,@Supplier_id)"); OleDbParameter[] parameters = { new OleDbParameter("@TaxRate", model.TaxRate), new OleDbParameter("@Type_id_BillType", model.Type_id_BillType), new OleDbParameter("@Supplier_id", model.Supplier_id) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); return(1); }
/// <summary> /// 编辑发票信息 /// </summary> public void BillType_Edit() { if (!Power("supplier_billtype_list", "发票管理")) { AjaxNoPower(); return; } int id = RequestTool.RequestInt("id", 0); int Type_id_BillType = RequestTool.RequestInt("Type_id_BillType", 0); bool addflag = false; string where = ""; if (id == 0) { where = "Type_id_BillType = " + Type_id_BillType + " and Supplier_id = " + CurrentSupplier.id + ""; } else { where = "id = " + id + " and Supplier_id = " + CurrentSupplier.id + ""; } Lebi_Supplier_BillType model = B_Lebi_Supplier_BillType.GetModel(where); if (model == null) { addflag = true; model = new Lebi_Supplier_BillType(); } model = B_Lebi_Supplier_BillType.SafeBindForm(model); if (addflag) { model.Supplier_id = CurrentSupplier.id; B_Lebi_Supplier_BillType.Add(model); id = B_Lebi_Supplier_BillType.GetMaxId(); Log.Add("添加发票类型", "BillType", id.ToString(), CurrentSupplier, Shop.Bussiness.EX_Type.TypeName(model.Type_id_BillType)); } else { B_Lebi_Supplier_BillType.Update(model); Log.Add("编辑发票类型", "BillType", id.ToString(), CurrentSupplier, Shop.Bussiness.EX_Type.TypeName(model.Type_id_BillType)); } string result = "{\"msg\":\"OK\", \"id\":\"" + id + "\"}"; Response.Write(result); }
/// <summary> /// 得到一个对象实体 by id /// </summary> public Lebi_Supplier_BillType GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_Supplier_BillType] "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Lebi_Supplier_BillType model = new Lebi_Supplier_BillType(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["TaxRate"].ToString() != "") { model.TaxRate = decimal.Parse(ds.Tables[0].Rows[0]["TaxRate"].ToString()); } if (ds.Tables[0].Rows[0]["Type_id_BillType"].ToString() != "") { model.Type_id_BillType = int.Parse(ds.Tables[0].Rows[0]["Type_id_BillType"].ToString()); } if (ds.Tables[0].Rows[0]["Supplier_id"].ToString() != "") { model.Supplier_id = int.Parse(ds.Tables[0].Rows[0]["Supplier_id"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 by where条件 /// </summary> public Lebi_Supplier_BillType GetModel(string strWhere) { if (strWhere.IndexOf("lbsql{") > 0) { SQLPara para = new SQLPara(strWhere, "", ""); return(GetModel(para)); } StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_Supplier_BillType] "); strSql.Append(" where " + strWhere + ""); Lebi_Supplier_BillType model = new Lebi_Supplier_BillType(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["TaxRate"].ToString() != "") { model.TaxRate = decimal.Parse(ds.Tables[0].Rows[0]["TaxRate"].ToString()); } if (ds.Tables[0].Rows[0]["Type_id_BillType"].ToString() != "") { model.Type_id_BillType = int.Parse(ds.Tables[0].Rows[0]["Type_id_BillType"].ToString()); } if (ds.Tables[0].Rows[0]["Supplier_id"].ToString() != "") { model.Supplier_id = int.Parse(ds.Tables[0].Rows[0]["Supplier_id"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Supplier_BillType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_Supplier_BillType] set "); strSql.Append("TaxRate= @TaxRate,"); strSql.Append("Type_id_BillType= @Type_id_BillType,"); strSql.Append("Supplier_id= @Supplier_id"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@TaxRate", SqlDbType.Decimal, 9), new SqlParameter("@Type_id_BillType", SqlDbType.Int, 4), new SqlParameter("@Supplier_id", SqlDbType.Int, 4) }; parameters[0].Value = model.id; parameters[1].Value = model.TaxRate; parameters[2].Value = model.Type_id_BillType; parameters[3].Value = model.Supplier_id; SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_Supplier_BillType model) { D_Lebi_Supplier_BillType.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_Supplier_BillType model) { return(D_Lebi_Supplier_BillType.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_Supplier_BillType SafeBindForm(Lebi_Supplier_BillType model) { return(D_Lebi_Supplier_BillType.Instance.SafeBindForm(model)); }