/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(BArriveBill_HangHaoData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("set nocount on; "); strSql.Append("insert into BArriveBill_HangHao("); strSql.Append(@"billNo,custNo,arriveDt,isrtEmpId,isrtDt,updtEmpId,updtDt,commitEmpId,commitDt,instantState)"); strSql.Append(" values ("); strSql.Append(@"@billNo,@custNo,@arriveDt,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt,@commitEmpId,@commitDt,@instantState)"); strSql.Append("; select @@identity; set nocount off; "); SqlParameter[] parameters = { new SqlParameter("@billNo", SqlDbType.VarChar,20), new SqlParameter("@custNo", SqlDbType.VarChar,20), new SqlParameter("@arriveDt", SqlDbType.DateTime), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@updtEmpId", SqlDbType.Int), new SqlParameter("@updtDt", SqlDbType.DateTime), new SqlParameter("@commitEmpId", SqlDbType.Int), new SqlParameter("@commitDt", SqlDbType.DateTime), new SqlParameter("@instantState", SqlDbType.NVarChar,20) }; parameters[0].Value = model.billNo; parameters[1].Value = model.custNo; parameters[2].Value = model.arriveDt == string.Empty ? null : model.arriveDt; parameters[3].Value = model.isrtEmpId; parameters[4].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[5].Value = model.updtEmpId; parameters[6].Value = model.updtDt == string.Empty ? null : model.updtDt; parameters[7].Value = model.commitEmpId; parameters[8].Value = model.commitDt == string.Empty ? null : model.commitDt; parameters[9].Value = model.instantState; int id = 0; try { object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ret != null && ret != DBNull.Value) { id = Convert.ToInt32(ret); } } catch (Exception ex) { throw ex; } return id; }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BArriveBill_HangHaoData model) { bool ret = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update BArriveBill_HangHao set "); strSql.Append("billNo=@billNo,"); strSql.Append("custNo=@custNo,"); strSql.Append("arriveDt=@arriveDt,"); strSql.Append("isrtEmpId=@isrtEmpId,"); strSql.Append("isrtDt=@isrtDt,"); strSql.Append("updtEmpId=@updtEmpId,"); strSql.Append("updtDt=@updtDt,"); strSql.Append("commitEmpId=@commitEmpId,"); strSql.Append("commitDt=@commitDt,"); strSql.Append("instantState=@instantState"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@billNo", SqlDbType.VarChar,20), new SqlParameter("@custNo", SqlDbType.VarChar,20), new SqlParameter("@arriveDt", SqlDbType.DateTime), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@updtEmpId", SqlDbType.Int), new SqlParameter("@updtDt", SqlDbType.DateTime), new SqlParameter("@commitEmpId", SqlDbType.Int), new SqlParameter("@commitDt", SqlDbType.DateTime), new SqlParameter("@instantState", SqlDbType.NVarChar,20) }; parameters[0].Value = model.id; parameters[1].Value = model.billNo; parameters[2].Value = model.custNo; parameters[3].Value = model.arriveDt == string.Empty ? null : model.arriveDt; parameters[4].Value = model.isrtEmpId; parameters[5].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[6].Value = model.updtEmpId; parameters[7].Value = model.updtDt == string.Empty ? null : model.updtDt; parameters[8].Value = model.commitEmpId; parameters[9].Value = model.commitDt == string.Empty ? null : model.commitDt; parameters[10].Value = model.instantState; try { SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); ret = true; } catch (Exception ex) { throw ex; } return ret; }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BArriveBill_HangHaoData model) { return this.arriveBill_HangHaoDB.ModifyRecord(model); }
/// <summary> /// 得到一个model /// </summary> /// <param name="id">主键值</param> /// <returns>model</returns> public BArriveBill_HangHaoData GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"select id,billNo,custNo,arriveDt,isrtEmpId,isrtDt,updtEmpId,updtDt,commitEmpId,commitDt,instantState from BArriveBill_HangHao"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; BArriveBill_HangHaoData model = new BArriveBill_HangHaoData(); DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; if (row["id"] != DBNull.Value) { model.id = Convert.ToInt32(row["id"]); } if (row["billNo"] != DBNull.Value) { model.billNo = Convert.ToString(row["billNo"]); } if (row["custNo"] != DBNull.Value) { model.custNo = Convert.ToString(row["custNo"]); } if (row["arriveDt"] != DBNull.Value) { model.arriveDt = Convert.ToString(row["arriveDt"]); } if (row["isrtEmpId"] != DBNull.Value) { model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]); } if (row["isrtDt"] != DBNull.Value) { model.isrtDt = Convert.ToString(row["isrtDt"]); } if (row["updtEmpId"] != DBNull.Value) { model.updtEmpId = Convert.ToInt32(row["updtEmpId"]); } if (row["updtDt"] != DBNull.Value) { model.updtDt = Convert.ToString(row["updtDt"]); } if (row["commitEmpId"] != DBNull.Value) { model.commitEmpId = Convert.ToInt32(row["commitEmpId"]); } if (row["commitDt"] != DBNull.Value) { model.commitDt = Convert.ToString(row["commitDt"]); } if (row["instantState"] != DBNull.Value) { model.instantState = Convert.ToString(row["instantState"]); } return model; } else { return null; } }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(BArriveBill_HangHaoData model) { return this.arriveBill_HangHaoDB.AddRecord(model); }