/// <summary> /// 更新一条数据 /// </summary> public void Update(VAN_OA.Model.JXC.TB_SupplierInvoices model, SqlCommand objCommand) { StringBuilder strSql = new StringBuilder(); strSql.Append("update TB_SupplierInvoices set "); //if (model.Id != null) //{ // strSql.Append("Id=" + model.Id + ","); //} //if (model.RuIds != null) //{ // strSql.Append("RuIds=" + model.RuIds + ","); //} if (model.SupplierFPNo != null) { strSql.Append("SupplierFPNo='" + model.SupplierFPNo + "',"); } if (model.SupplierInvoiceDate != null) { strSql.Append("SupplierInvoiceDate='" + model.SupplierInvoiceDate + "',"); } if (model.SupplierInvoiceNum != null) { strSql.Append("SupplierInvoiceNum=" + model.SupplierInvoiceNum + ","); } if (model.SupplierInvoicePrice != null) { strSql.Append("SupplierInvoicePrice=" + model.SupplierInvoicePrice + ","); } if (model.SupplierInvoiceTotal != null) { strSql.Append("SupplierInvoiceTotal=" + model.SupplierInvoiceTotal + ","); } if (model.SupplierProNo != null) { strSql.Append("SupplierProNo='" + model.SupplierProNo + "',"); } if (model.SupplierFpDate != null) { strSql.Append("SupplierFpDate='" + model.SupplierFpDate + "',"); } //if (model.IsYuFu != null) //{ // strSql.Append("IsYuFu=" + (model.IsYuFu ? 1 : 0) + ","); //} int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where Ids=" + model.Ids + ""); objCommand.CommandText = strSql.ToString(); objCommand.ExecuteNonQuery(); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(VAN_OA.Model.JXC.TB_SupplierInvoices model, SqlCommand objCommand) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.Id != null) { strSql1.Append("Id,"); strSql2.Append("" + model.Id + ","); } if (model.RuIds != null) { strSql1.Append("RuIds,"); strSql2.Append("" + model.RuIds + ","); } if (model.SupplierFPNo != null) { strSql1.Append("SupplierFPNo,"); strSql2.Append("'" + model.SupplierFPNo + "',"); } if (model.SupplierInvoiceDate != null) { strSql1.Append("SupplierInvoiceDate,"); strSql2.Append("'" + model.SupplierInvoiceDate + "',"); } if (model.SupplierInvoiceNum != null) { strSql1.Append("SupplierInvoiceNum,"); strSql2.Append("" + model.SupplierInvoiceNum + ","); } if (model.SupplierInvoicePrice != null) { strSql1.Append("SupplierInvoicePrice,"); strSql2.Append("" + model.SupplierInvoicePrice + ","); } if (model.SupplierInvoiceTotal != null) { strSql1.Append("SupplierInvoiceTotal,"); strSql2.Append("" + model.SupplierInvoiceTotal + ","); } if (model.IsYuFu != null) { strSql1.Append("IsYuFu,"); strSql2.Append("" + (model.IsYuFu ? 1 : 0) + ","); } strSql1.Append("SupplierProNo,"); strSql2.Append("'" + model.SupplierProNo + "',"); if (model.AllCaiIdsPay != null) { strSql1.Append("AllCaiIdsPay,"); strSql2.Append("'" + model.AllCaiIdsPay + "',"); } if (model.ActPay != null) { strSql1.Append("ActPay,"); strSql2.Append("" + model.ActPay + ","); } if (model.RePayClear != null) { strSql1.Append("RePayClear,"); strSql2.Append("" + model.RePayClear + ","); } if (model.FuShuTotal != null) { strSql1.Append("FuShuTotal,"); strSql2.Append("" + model.FuShuTotal + ","); } if (model.IsPayStatus != null) { strSql1.Append("IsPayStatus,"); strSql2.Append("" + model.IsPayStatus + ","); } if (model.IsHeBing != null) { strSql1.Append("IsHeBing,"); strSql2.Append("" + model.IsHeBing + ","); } if (model.SupplierFpDate != null) { strSql1.Append("SupplierFpDate,"); strSql2.Append("'" + model.SupplierFpDate + "',"); } strSql.Append("insert into TB_SupplierInvoices("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); strSql.Append(";select @@IDENTITY"); int result; objCommand.CommandText = strSql.ToString(); object obj = objCommand.ExecuteScalar(); if (!int.TryParse(obj.ToString(), out result)) { return(0); } return(result); }