/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(BArriveBoxData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("set nocount on; "); strSql.Append("insert into BArriveBox("); strSql.Append(@"arriveBillNo,financeBillNo,materialNo,boxNo,palletNo,isBoxArrange,isPalletUsing,isrtEmpId,isrtDt,wareNo, wareLocatorNo,preWareNo,preWareLocatorNo)"); strSql.Append(" values ("); strSql.Append(@"@arriveBillNo,@financeBillNo,@materialNo,@boxNo,@palletNo,@isBoxArrange,@isPalletUsing,@isrtEmpId,@isrtDt,@wareNo, @wareLocatorNo,@preWareNo,@preWareLocatorNo)"); strSql.Append("; select @@identity; set nocount off; "); SqlParameter[] parameters = { new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20), new SqlParameter("@financeBillNo", SqlDbType.VarChar,20), new SqlParameter("@materialNo", SqlDbType.VarChar,20), new SqlParameter("@boxNo", SqlDbType.VarChar,20), new SqlParameter("@palletNo", SqlDbType.VarChar,20), new SqlParameter("@isBoxArrange", SqlDbType.Bit), new SqlParameter("@isPalletUsing", SqlDbType.Bit), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@wareNo", SqlDbType.VarChar,20), new SqlParameter("@wareLocatorNo", SqlDbType.VarChar,20), new SqlParameter("@preWareNo", SqlDbType.VarChar,20), new SqlParameter("@preWareLocatorNo", SqlDbType.VarChar,20) }; parameters[0].Value = model.arriveBillNo; parameters[1].Value = model.financeBillNo; parameters[2].Value = model.materialNo; parameters[3].Value = model.boxNo; parameters[4].Value = model.palletNo; parameters[5].Value = model.isBoxArrange; parameters[6].Value = model.isPalletUsing; parameters[7].Value = model.isrtEmpId; parameters[8].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[9].Value = model.wareNo; parameters[10].Value = model.wareLocatorNo; parameters[11].Value = model.preWareNo; parameters[12].Value = model.preWareLocatorNo; 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(BArriveBoxData model) { return this.arriveBoxDB.ModifyRecord(model); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(BArriveBoxData model) { return this.arriveBoxDB.AddRecord(model); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BArriveBoxData model) { bool ret = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update BArriveBox set "); strSql.Append("arriveBillNo=@arriveBillNo,"); strSql.Append("financeBillNo=@financeBillNo,"); strSql.Append("materialNo=@materialNo,"); strSql.Append("boxNo=@boxNo,"); strSql.Append("palletNo=@palletNo,"); strSql.Append("isBoxArrange=@isBoxArrange,"); strSql.Append("isPalletUsing=@isPalletUsing,"); strSql.Append("isrtEmpId=@isrtEmpId,"); strSql.Append("isrtDt=@isrtDt,"); strSql.Append("wareNo=@wareNo,"); strSql.Append("wareLocatorNo=@wareLocatorNo,"); strSql.Append("preWareNo=@preWareNo,"); strSql.Append("preWareLocatorNo=@preWareLocatorNo"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20), new SqlParameter("@financeBillNo", SqlDbType.VarChar,20), new SqlParameter("@materialNo", SqlDbType.VarChar,20), new SqlParameter("@boxNo", SqlDbType.VarChar,20), new SqlParameter("@palletNo", SqlDbType.VarChar,20), new SqlParameter("@isBoxArrange", SqlDbType.Bit), new SqlParameter("@isPalletUsing", SqlDbType.Bit), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@wareNo", SqlDbType.VarChar,20), new SqlParameter("@wareLocatorNo", SqlDbType.VarChar,20), new SqlParameter("@preWareNo", SqlDbType.VarChar,20), new SqlParameter("@preWareLocatorNo", SqlDbType.VarChar,20) }; parameters[0].Value = model.id; parameters[1].Value = model.arriveBillNo; parameters[2].Value = model.financeBillNo; parameters[3].Value = model.materialNo; parameters[4].Value = model.boxNo; parameters[5].Value = model.palletNo; parameters[6].Value = model.isBoxArrange; parameters[7].Value = model.isPalletUsing; parameters[8].Value = model.isrtEmpId; parameters[9].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[10].Value = model.wareNo; parameters[11].Value = model.wareLocatorNo; parameters[12].Value = model.preWareNo; parameters[13].Value = model.preWareLocatorNo; try { SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); ret = true; } catch (Exception ex) { throw ex; } return ret; }
/// <summary> /// 得到一个model /// </summary> /// <param name="id">主键值</param> /// <returns>model</returns> public BArriveBoxData GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"select id,arriveBillNo,financeBillNo,materialNo,boxNo,palletNo,isBoxArrange,isPalletUsing,isrtEmpId,isrtDt,wareNo, wareLocatorNo,preWareNo,preWareLocatorNo from BArriveBox"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; BArriveBoxData model = new BArriveBoxData(); 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["arriveBillNo"] != DBNull.Value) { model.arriveBillNo = Convert.ToString(row["arriveBillNo"]); } if (row["financeBillNo"] != DBNull.Value) { model.financeBillNo = Convert.ToString(row["financeBillNo"]); } if (row["materialNo"] != DBNull.Value) { model.materialNo = Convert.ToString(row["materialNo"]); } if (row["boxNo"] != DBNull.Value) { model.boxNo = Convert.ToString(row["boxNo"]); } if (row["palletNo"] != DBNull.Value) { model.palletNo = Convert.ToString(row["palletNo"]); } if (row["isBoxArrange"] != DBNull.Value) { model.isBoxArrange = Convert.ToBoolean(row["isBoxArrange"]); } if (row["isPalletUsing"] != DBNull.Value) { model.isPalletUsing = Convert.ToBoolean(row["isPalletUsing"]); } if (row["isrtEmpId"] != DBNull.Value) { model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]); } if (row["isrtDt"] != DBNull.Value) { model.isrtDt = Convert.ToString(row["isrtDt"]); } if (row["wareNo"] != DBNull.Value) { model.wareNo = Convert.ToString(row["wareNo"]); } if (row["wareLocatorNo"] != DBNull.Value) { model.wareLocatorNo = Convert.ToString(row["wareLocatorNo"]); } if (row["preWareNo"] != DBNull.Value) { model.preWareNo = Convert.ToString(row["preWareNo"]); } if (row["preWareLocatorNo"] != DBNull.Value) { model.preWareLocatorNo = Convert.ToString(row["preWareLocatorNo"]); } return model; } else { return null; } }