using System; using System.Data; using System.Text; using System.Data.SqlClient; using EXDataControl; using Utility; namespace BasicInformation { /// <summary> /// 类pdt_MaterialMasterBill。 /// </summary> [Serializable] public partial class pdt_MaterialMasterBill { public pdt_MaterialMasterBill(EXDataControl.EXDataCenter dc) { DbHelperSQL = dc; } EXDataControl.EXDataCenter DbHelperSQL; #region Model private int _autoid; private string _materialcode; private string _materialname; private string _nnemoniccode; private string _spellcode; private int? _classfication; private string _color; private decimal? _size=0M; private decimal? _weight=0M; private bool _isvirtual; private int? _processroute; private int? _materialplantype; private int? _materialstatustype; private int? _purchasingleadcycle; private int? _preparationcycle; private int? _repleasecycle; private decimal? _costprice; private decimal? _price; private DateTime? _begindate; private DateTime? _enddate; private string _remark; private bool _active; private string _loginby; private DateTime? _logindate; private string _updateby; private DateTime? _updatedate; /// <summary> /// /// </summary> public int AutoID { set{ _autoid=value;} get{return _autoid;} } /// <summary> /// /// </summary> public string MaterialCode { set{ _materialcode=value;} get{return _materialcode;} } /// <summary> /// /// </summary> public string MaterialName { set{ _materialname=value;} get{return _materialname;} } /// <summary> /// /// </summary> public string NnemonicCode { set{ _nnemoniccode=value;} get{return _nnemoniccode;} } /// <summary> /// /// </summary> public string SpellCode { set{ _spellcode=value;} get{return _spellcode;} } /// <summary> /// /// </summary> public int? ClassFication { set{ _classfication=value;} get{return _classfication;} } /// <summary> /// /// </summary> public string Color { set{ _color=value;} get{return _color;} } /// <summary> /// /// </summary> public decimal? Size { set{ _size=value;} get{return _size;} } /// <summary> /// /// </summary> public decimal? Weight { set{ _weight=value;} get{return _weight;} } /// <summary> /// /// </summary> public bool IsVirtual { set{ _isvirtual=value;} get{return _isvirtual;} } /// <summary> /// /// </summary> public int? ProcessRoute { set{ _processroute=value;} get{return _processroute;} } /// <summary> /// /// </summary> public int? MaterialPlanType { set{ _materialplantype=value;} get{return _materialplantype;} } /// <summary> /// /// </summary> public int? MaterialStatusType { set{ _materialstatustype=value;} get{return _materialstatustype;} } /// <summary> /// /// </summary> public int? PurchasingLeadCycle { set{ _purchasingleadcycle=value;} get{return _purchasingleadcycle;} } /// <summary> /// /// </summary> public int? PreparationCycle { set{ _preparationcycle=value;} get{return _preparationcycle;} } /// <summary> /// /// </summary> public int? RepleaseCycle { set{ _repleasecycle=value;} get{return _repleasecycle;} } /// <summary> /// /// </summary> public decimal? CostPrice { set{ _costprice=value;} get{return _costprice;} } /// <summary> /// /// </summary> public decimal? Price { set{ _price=value;} get{return _price;} } /// <summary> /// /// </summary> public DateTime? BeginDate { set{ _begindate=value;} get{return _begindate;} } /// <summary> /// /// </summary> public DateTime? EndDate { set{ _enddate=value;} get{return _enddate;} } /// <summary> /// /// </summary> public string Remark { set{ _remark=value;} get{return _remark;} } /// <summary> /// /// </summary> public bool Active { set{ _active=value;} get{return _active;} } /// <summary> /// /// </summary> public string LoginBy { set{ _loginby=value;} get{return _loginby;} } /// <summary> /// /// </summary> public DateTime? LoginDate { set{ _logindate=value;} get{return _logindate;} } /// <summary> /// /// </summary> public string UpdateBy { set{ _updateby=value;} get{return _updateby;} } /// <summary> /// /// </summary> public DateTime? UpdateDate { set{ _updatedate=value;} get{return _updatedate;} } #endregion Model #region Method /// <summary> /// 得到一个对象实体 /// </summary> public pdt_MaterialMasterBill(int AutoID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select AutoID,MaterialCode,MaterialName,NnemonicCode,SpellCode,ClassFication,Color,Size,Weight,IsVirtual,ProcessRoute,MaterialPlanType,MaterialStatusType,PurchasingLeadCycle,PreparationCycle,RepleaseCycle,CostPrice,Price,BeginDate,EndDate,Remark,Active,LoginBy,LoginDate,UpdateBy,UpdateDate "); strSql.Append(" FROM [pdt_MaterialMasterBill] "); strSql.Append(" where [email protected] "); SqlParameter[] parameters = { new SqlParameter("@AutoID", SqlDbType.Int,4)}; parameters[0].Value = AutoID; DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["AutoID"]!=null && ds.Tables[0].Rows[0]["AutoID"].ToString()!="") { this.AutoID=int.Parse(ds.Tables[0].Rows[0]["AutoID"].ToString()); } if(ds.Tables[0].Rows[0]["MaterialCode"]!=null) { this.MaterialCode=ds.Tables[0].Rows[0]["MaterialCode"].ToString(); } if(ds.Tables[0].Rows[0]["MaterialName"]!=null) { this.MaterialName=ds.Tables[0].Rows[0]["MaterialName"].ToString(); } if(ds.Tables[0].Rows[0]["NnemonicCode"]!=null) { this.NnemonicCode=ds.Tables[0].Rows[0]["NnemonicCode"].ToString(); } if(ds.Tables[0].Rows[0]["SpellCode"]!=null) { this.SpellCode=ds.Tables[0].Rows[0]["SpellCode"].ToString(); } if(ds.Tables[0].Rows[0]["ClassFication"]!=null && ds.Tables[0].Rows[0]["ClassFication"].ToString()!="") { this.ClassFication=int.Parse(ds.Tables[0].Rows[0]["ClassFication"].ToString()); } if(ds.Tables[0].Rows[0]["Color"]!=null) { this.Color=ds.Tables[0].Rows[0]["Color"].ToString(); } if(ds.Tables[0].Rows[0]["Size"]!=null && ds.Tables[0].Rows[0]["Size"].ToString()!="") { this.Size=decimal.Parse(ds.Tables[0].Rows[0]["Size"].ToString()); } if(ds.Tables[0].Rows[0]["Weight"]!=null && ds.Tables[0].Rows[0]["Weight"].ToString()!="") { this.Weight=decimal.Parse(ds.Tables[0].Rows[0]["Weight"].ToString()); } if(ds.Tables[0].Rows[0]["IsVirtual"]!=null && ds.Tables[0].Rows[0]["IsVirtual"].ToString()!="") { if((ds.Tables[0].Rows[0]["IsVirtual"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsVirtual"].ToString().ToLower()=="true")) { this.IsVirtual=true; } else { this.IsVirtual=false; } } if(ds.Tables[0].Rows[0]["ProcessRoute"]!=null && ds.Tables[0].Rows[0]["ProcessRoute"].ToString()!="") { this.ProcessRoute=int.Parse(ds.Tables[0].Rows[0]["ProcessRoute"].ToString()); } if(ds.Tables[0].Rows[0]["MaterialPlanType"]!=null && ds.Tables[0].Rows[0]["MaterialPlanType"].ToString()!="") { this.MaterialPlanType=int.Parse(ds.Tables[0].Rows[0]["MaterialPlanType"].ToString()); } if(ds.Tables[0].Rows[0]["MaterialStatusType"]!=null && ds.Tables[0].Rows[0]["MaterialStatusType"].ToString()!="") { this.MaterialStatusType=int.Parse(ds.Tables[0].Rows[0]["MaterialStatusType"].ToString()); } if(ds.Tables[0].Rows[0]["PurchasingLeadCycle"]!=null && ds.Tables[0].Rows[0]["PurchasingLeadCycle"].ToString()!="") { this.PurchasingLeadCycle=int.Parse(ds.Tables[0].Rows[0]["PurchasingLeadCycle"].ToString()); } if(ds.Tables[0].Rows[0]["PreparationCycle"]!=null && ds.Tables[0].Rows[0]["PreparationCycle"].ToString()!="") { this.PreparationCycle=int.Parse(ds.Tables[0].Rows[0]["PreparationCycle"].ToString()); } if(ds.Tables[0].Rows[0]["RepleaseCycle"]!=null && ds.Tables[0].Rows[0]["RepleaseCycle"].ToString()!="") { this.RepleaseCycle=int.Parse(ds.Tables[0].Rows[0]["RepleaseCycle"].ToString()); } if(ds.Tables[0].Rows[0]["CostPrice"]!=null && ds.Tables[0].Rows[0]["CostPrice"].ToString()!="") { this.CostPrice=decimal.Parse(ds.Tables[0].Rows[0]["CostPrice"].ToString()); } if(ds.Tables[0].Rows[0]["Price"]!=null && ds.Tables[0].Rows[0]["Price"].ToString()!="") { this.Price=decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if(ds.Tables[0].Rows[0]["BeginDate"]!=null && ds.Tables[0].Rows[0]["BeginDate"].ToString()!="") { this.BeginDate=DateTime.Parse(ds.Tables[0].Rows[0]["BeginDate"].ToString()); } if(ds.Tables[0].Rows[0]["EndDate"]!=null && ds.Tables[0].Rows[0]["EndDate"].ToString()!="") { this.EndDate=DateTime.Parse(ds.Tables[0].Rows[0]["EndDate"].ToString()); } if(ds.Tables[0].Rows[0]["Remark"]!=null) { this.Remark=ds.Tables[0].Rows[0]["Remark"].ToString(); } if(ds.Tables[0].Rows[0]["Active"]!=null && ds.Tables[0].Rows[0]["Active"].ToString()!="") { if((ds.Tables[0].Rows[0]["Active"].ToString()=="1")||(ds.Tables[0].Rows[0]["Active"].ToString().ToLower()=="true")) { this.Active=true; } else { this.Active=false; } } if(ds.Tables[0].Rows[0]["LoginBy"]!=null) { this.LoginBy=ds.Tables[0].Rows[0]["LoginBy"].ToString(); } if(ds.Tables[0].Rows[0]["LoginDate"]!=null && ds.Tables[0].Rows[0]["LoginDate"].ToString()!="") { this.LoginDate=DateTime.Parse(ds.Tables[0].Rows[0]["LoginDate"].ToString()); } if(ds.Tables[0].Rows[0]["UpdateBy"]!=null) { this.UpdateBy=ds.Tables[0].Rows[0]["UpdateBy"].ToString(); } if(ds.Tables[0].Rows[0]["UpdateDate"]!=null && ds.Tables[0].Rows[0]["UpdateDate"].ToString()!="") { this.UpdateDate=DateTime.Parse(ds.Tables[0].Rows[0]["UpdateDate"].ToString()); } } } /// <summary> /// 是否存在该记录 /// </summary> public bool Exists(int AutoID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select count(1) from [pdt_MaterialMasterBill]"); strSql.Append(" where [email protected] "); SqlParameter[] parameters = { new SqlParameter("@AutoID", SqlDbType.Int,4)}; parameters[0].Value = AutoID; return DbHelperSQL.Exists(strSql.ToString(),parameters); } /// <summary> /// 增加一条数据 /// </summary> public int Add() { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into [pdt_MaterialMasterBill] ("); strSql.Append("MaterialCode,MaterialName,NnemonicCode,SpellCode,ClassFication,Color,Size,Weight,IsVirtual,ProcessRoute,MaterialPlanType,MaterialStatusType,PurchasingLeadCycle,PreparationCycle,RepleaseCycle,CostPrice,Price,BeginDate,EndDate,Remark,Active,LoginBy,LoginDate,UpdateBy,UpdateDate)"); strSql.Append(" values ("); strSql.Append("@MaterialCode,@MaterialName,@NnemonicCode,@SpellCode,@ClassFication,@Color,@Size,@Weight,@IsVirtual,@ProcessRoute,@MaterialPlanType,@MaterialStatusType,@PurchasingLeadCycle,@PreparationCycle,@RepleaseCycle,@CostPrice,@Price,@BeginDate,@EndDate,@Remark,@Active,@LoginBy,@LoginDate,@UpdateBy,@UpdateDate)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@MaterialCode", SqlDbType.VarChar,10), new SqlParameter("@MaterialName", SqlDbType.NVarChar,255), new SqlParameter("@NnemonicCode", SqlDbType.VarChar,128), new SqlParameter("@SpellCode", SqlDbType.VarChar,255), new SqlParameter("@ClassFication", SqlDbType.Int,4), new SqlParameter("@Color", SqlDbType.NVarChar,50), new SqlParameter("@Size", SqlDbType.Decimal,9), new SqlParameter("@Weight", SqlDbType.Decimal,9), new SqlParameter("@IsVirtual", SqlDbType.Bit,1), new SqlParameter("@ProcessRoute", SqlDbType.Int,4), new SqlParameter("@MaterialPlanType", SqlDbType.Int,4), new SqlParameter("@MaterialStatusType", SqlDbType.Int,4), new SqlParameter("@PurchasingLeadCycle", SqlDbType.Int,4), new SqlParameter("@PreparationCycle", SqlDbType.Int,4), new SqlParameter("@RepleaseCycle", SqlDbType.Int,4), new SqlParameter("@CostPrice", SqlDbType.Decimal,9), new SqlParameter("@Price", SqlDbType.Decimal,9), new SqlParameter("@BeginDate", SqlDbType.DateTime), new SqlParameter("@EndDate", SqlDbType.DateTime), new SqlParameter("@Remark", SqlDbType.NVarChar,255), new SqlParameter("@Active", SqlDbType.Bit,1), new SqlParameter("@LoginBy", SqlDbType.NVarChar,30), new SqlParameter("@LoginDate", SqlDbType.DateTime), new SqlParameter("@UpdateBy", SqlDbType.NVarChar,30), new SqlParameter("@UpdateDate", SqlDbType.DateTime)}; parameters[0].Value = PubControl.SqlDBNull(MaterialCode); parameters[1].Value = PubControl.SqlDBNull(MaterialName); parameters[2].Value = PubControl.SqlDBNull(NnemonicCode); parameters[3].Value = PubControl.SqlDBNull(SpellCode); parameters[4].Value = PubControl.SqlDBNull(ClassFication); parameters[5].Value = PubControl.SqlDBNull(Color); parameters[6].Value = PubControl.SqlDBNull(Size); parameters[7].Value = PubControl.SqlDBNull(Weight); parameters[8].Value = PubControl.SqlDBNull(IsVirtual); parameters[9].Value = PubControl.SqlDBNull(ProcessRoute); parameters[10].Value = PubControl.SqlDBNull(MaterialPlanType); parameters[11].Value = PubControl.SqlDBNull(MaterialStatusType); parameters[12].Value = PubControl.SqlDBNull(PurchasingLeadCycle); parameters[13].Value = PubControl.SqlDBNull(PreparationCycle); parameters[14].Value = PubControl.SqlDBNull(RepleaseCycle); parameters[15].Value = PubControl.SqlDBNull(CostPrice); parameters[16].Value = PubControl.SqlDBNull(Price); parameters[17].Value = PubControl.SqlDBNull(BeginDate); parameters[18].Value = PubControl.SqlDBNull(EndDate); parameters[19].Value = PubControl.SqlDBNull(Remark); parameters[20].Value = PubControl.SqlDBNull(Active); parameters[21].Value = PubControl.SqlDBNull(LoginBy); parameters[22].Value = PubControl.SqlDBNull(LoginDate); parameters[23].Value = PubControl.SqlDBNull(UpdateBy); parameters[24].Value = PubControl.SqlDBNull(UpdateDate); #region 返回AutoID int iIntFlag = 0; if (parameters != null) { SqlConnection conn = new SqlConnection(this.DbHelperSQL.ConnString); SqlCommand cmd = new SqlCommand(); try { conn.Open(); cmd.Connection = conn; cmd.CommandText = strSql.ToString(); cmd.CommandType = CommandType.Text;//cmdType; if (parameters != null) { foreach (SqlParameter parameter in parameters) { if ((parameter.Direction == ParameterDirection.InputOutput || parameter.Direction == ParameterDirection.Input) && (parameter.Value == null)) { parameter.Value = DBNull.Value; } cmd.Parameters.Add(parameter); } } object obj = cmd.ExecuteScalar(); if (obj != null) { if (Convert.ToInt32(obj) > 0) { iIntFlag = Convert.ToInt32(obj); } } } catch (Exception ex) { } finally { conn.Close(); cmd.Dispose(); } } #endregion return iIntFlag; } /// <summary> /// 更新一条数据 /// </summary> public int Update() { StringBuilder strSql=new StringBuilder(); strSql.Append("update [pdt_MaterialMasterBill] set "); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected],"); strSql.Append("[email protected]ateBy,"); strSql.Append("[email protected]"); strSql.Append(" where [email protected] "); SqlParameter[] parameters = { new SqlParameter("@MaterialCode", SqlDbType.VarChar,10), new SqlParameter("@MaterialName", SqlDbType.NVarChar,255), new SqlParameter("@NnemonicCode", SqlDbType.VarChar,128), new SqlParameter("@SpellCode", SqlDbType.VarChar,255), new SqlParameter("@ClassFication", SqlDbType.Int,4), new SqlParameter("@Color", SqlDbType.NVarChar,50), new SqlParameter("@Size", SqlDbType.Decimal,9), new SqlParameter("@Weight", SqlDbType.Decimal,9), new SqlParameter("@IsVirtual", SqlDbType.Bit,1), new SqlParameter("@ProcessRoute", SqlDbType.Int,4), new SqlParameter("@MaterialPlanType", SqlDbType.Int,4), new SqlParameter("@MaterialStatusType", SqlDbType.Int,4), new SqlParameter("@PurchasingLeadCycle", SqlDbType.Int,4), new SqlParameter("@PreparationCycle", SqlDbType.Int,4), new SqlParameter("@RepleaseCycle", SqlDbType.Int,4), new SqlParameter("@CostPrice", SqlDbType.Decimal,9), new SqlParameter("@Price", SqlDbType.Decimal,9), new SqlParameter("@BeginDate", SqlDbType.DateTime), new SqlParameter("@EndDate", SqlDbType.DateTime), new SqlParameter("@Remark", SqlDbType.NVarChar,255), new SqlParameter("@Active", SqlDbType.Bit,1), new SqlParameter("@LoginBy", SqlDbType.NVarChar,30), new SqlParameter("@LoginDate", SqlDbType.DateTime), new SqlParameter("@UpdateBy", SqlDbType.NVarChar,30), new SqlParameter("@UpdateDate", SqlDbType.DateTime), new SqlParameter("@AutoID", SqlDbType.Int,4)}; parameters[0].Value = PubControl.SqlDBNull(MaterialCode); parameters[1].Value = PubControl.SqlDBNull(MaterialName); parameters[2].Value = PubControl.SqlDBNull(NnemonicCode); parameters[3].Value = PubControl.SqlDBNull(SpellCode); parameters[4].Value = PubControl.SqlDBNull(ClassFication); parameters[5].Value = PubControl.SqlDBNull(Color); parameters[6].Value = PubControl.SqlDBNull(Size); parameters[7].Value = PubControl.SqlDBNull(Weight); parameters[8].Value = PubControl.SqlDBNull(IsVirtual); parameters[9].Value = PubControl.SqlDBNull(ProcessRoute); parameters[10].Value = PubControl.SqlDBNull(MaterialPlanType); parameters[11].Value = PubControl.SqlDBNull(MaterialStatusType); parameters[12].Value = PubControl.SqlDBNull(PurchasingLeadCycle); parameters[13].Value = PubControl.SqlDBNull(PreparationCycle); parameters[14].Value = PubControl.SqlDBNull(RepleaseCycle); parameters[15].Value = PubControl.SqlDBNull(CostPrice); parameters[16].Value = PubControl.SqlDBNull(Price); parameters[17].Value = PubControl.SqlDBNull(BeginDate); parameters[18].Value = PubControl.SqlDBNull(EndDate); parameters[19].Value = PubControl.SqlDBNull(Remark); parameters[20].Value = PubControl.SqlDBNull(Active); parameters[21].Value = PubControl.SqlDBNull(LoginBy); parameters[22].Value = PubControl.SqlDBNull(LoginDate); parameters[23].Value = PubControl.SqlDBNull(UpdateBy); parameters[24].Value = PubControl.SqlDBNull(UpdateDate); parameters[25].Value = PubControl.SqlDBNull(AutoID); //int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); //if (rows > 0) //{ // return true; //} //else //{ // return false; //} int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return rows; } else { return 0; } } /// <summary> /// 删除一条数据 /// </summary> public bool Delete(int AutoID) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from [pdt_MaterialMasterBill] "); strSql.Append(" where [email protected] "); SqlParameter[] parameters = { new SqlParameter("@AutoID", SqlDbType.Int,4)}; parameters[0].Value = AutoID; int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); if (rows > 0) { return true; } else { return false; } } /// <summary> /// 得到一个对象实体 /// </summary> public void GetModel(int AutoID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select AutoID,MaterialCode,MaterialName,NnemonicCode,SpellCode,ClassFication,Color,Size,Weight,IsVirtual,ProcessRoute,MaterialPlanType,MaterialStatusType,PurchasingLeadCycle,PreparationCycle,RepleaseCycle,CostPrice,Price,BeginDate,EndDate,Remark,Active,LoginBy,LoginDate,UpdateBy,UpdateDate "); strSql.Append(" FROM [pdt_MaterialMasterBill] "); strSql.Append(" where [email protected] "); SqlParameter[] parameters = { new SqlParameter("@AutoID", SqlDbType.Int,4)}; parameters[0].Value = AutoID; DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["AutoID"]!=null && ds.Tables[0].Rows[0]["AutoID"].ToString()!="") { this.AutoID=int.Parse(ds.Tables[0].Rows[0]["AutoID"].ToString()); } if(ds.Tables[0].Rows[0]["MaterialCode"]!=null ) { this.MaterialCode=ds.Tables[0].Rows[0]["MaterialCode"].ToString(); } if(ds.Tables[0].Rows[0]["MaterialName"]!=null ) { this.MaterialName=ds.Tables[0].Rows[0]["MaterialName"].ToString(); } if(ds.Tables[0].Rows[0]["NnemonicCode"]!=null ) { this.NnemonicCode=ds.Tables[0].Rows[0]["NnemonicCode"].ToString(); } if(ds.Tables[0].Rows[0]["SpellCode"]!=null ) { this.SpellCode=ds.Tables[0].Rows[0]["SpellCode"].ToString(); } if(ds.Tables[0].Rows[0]["ClassFication"]!=null && ds.Tables[0].Rows[0]["ClassFication"].ToString()!="") { this.ClassFication=int.Parse(ds.Tables[0].Rows[0]["ClassFication"].ToString()); } if(ds.Tables[0].Rows[0]["Color"]!=null ) { this.Color=ds.Tables[0].Rows[0]["Color"].ToString(); } if(ds.Tables[0].Rows[0]["Size"]!=null && ds.Tables[0].Rows[0]["Size"].ToString()!="") { this.Size=decimal.Parse(ds.Tables[0].Rows[0]["Size"].ToString()); } if(ds.Tables[0].Rows[0]["Weight"]!=null && ds.Tables[0].Rows[0]["Weight"].ToString()!="") { this.Weight=decimal.Parse(ds.Tables[0].Rows[0]["Weight"].ToString()); } if(ds.Tables[0].Rows[0]["IsVirtual"]!=null && ds.Tables[0].Rows[0]["IsVirtual"].ToString()!="") { if((ds.Tables[0].Rows[0]["IsVirtual"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsVirtual"].ToString().ToLower()=="true")) { this.IsVirtual=true; } else { this.IsVirtual=false; } } if(ds.Tables[0].Rows[0]["ProcessRoute"]!=null && ds.Tables[0].Rows[0]["ProcessRoute"].ToString()!="") { this.ProcessRoute=int.Parse(ds.Tables[0].Rows[0]["ProcessRoute"].ToString()); } if(ds.Tables[0].Rows[0]["MaterialPlanType"]!=null && ds.Tables[0].Rows[0]["MaterialPlanType"].ToString()!="") { this.MaterialPlanType=int.Parse(ds.Tables[0].Rows[0]["MaterialPlanType"].ToString()); } if(ds.Tables[0].Rows[0]["MaterialStatusType"]!=null && ds.Tables[0].Rows[0]["MaterialStatusType"].ToString()!="") { this.MaterialStatusType=int.Parse(ds.Tables[0].Rows[0]["MaterialStatusType"].ToString()); } if(ds.Tables[0].Rows[0]["PurchasingLeadCycle"]!=null && ds.Tables[0].Rows[0]["PurchasingLeadCycle"].ToString()!="") { this.PurchasingLeadCycle=int.Parse(ds.Tables[0].Rows[0]["PurchasingLeadCycle"].ToString()); } if(ds.Tables[0].Rows[0]["PreparationCycle"]!=null && ds.Tables[0].Rows[0]["PreparationCycle"].ToString()!="") { this.PreparationCycle=int.Parse(ds.Tables[0].Rows[0]["PreparationCycle"].ToString()); } if(ds.Tables[0].Rows[0]["RepleaseCycle"]!=null && ds.Tables[0].Rows[0]["RepleaseCycle"].ToString()!="") { this.RepleaseCycle=int.Parse(ds.Tables[0].Rows[0]["RepleaseCycle"].ToString()); } if(ds.Tables[0].Rows[0]["CostPrice"]!=null && ds.Tables[0].Rows[0]["CostPrice"].ToString()!="") { this.CostPrice=decimal.Parse(ds.Tables[0].Rows[0]["CostPrice"].ToString()); } if(ds.Tables[0].Rows[0]["Price"]!=null && ds.Tables[0].Rows[0]["Price"].ToString()!="") { this.Price=decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if(ds.Tables[0].Rows[0]["BeginDate"]!=null && ds.Tables[0].Rows[0]["BeginDate"].ToString()!="") { this.BeginDate=DateTime.Parse(ds.Tables[0].Rows[0]["BeginDate"].ToString()); } if(ds.Tables[0].Rows[0]["EndDate"]!=null && ds.Tables[0].Rows[0]["EndDate"].ToString()!="") { this.EndDate=DateTime.Parse(ds.Tables[0].Rows[0]["EndDate"].ToString()); } if(ds.Tables[0].Rows[0]["Remark"]!=null ) { this.Remark=ds.Tables[0].Rows[0]["Remark"].ToString(); } if(ds.Tables[0].Rows[0]["Active"]!=null && ds.Tables[0].Rows[0]["Active"].ToString()!="") { if((ds.Tables[0].Rows[0]["Active"].ToString()=="1")||(ds.Tables[0].Rows[0]["Active"].ToString().ToLower()=="true")) { this.Active=true; } else { this.Active=false; } } if(ds.Tables[0].Rows[0]["LoginBy"]!=null ) { this.LoginBy=ds.Tables[0].Rows[0]["LoginBy"].ToString(); } if(ds.Tables[0].Rows[0]["LoginDate"]!=null && ds.Tables[0].Rows[0]["LoginDate"].ToString()!="") { this.LoginDate=DateTime.Parse(ds.Tables[0].Rows[0]["LoginDate"].ToString()); } if(ds.Tables[0].Rows[0]["UpdateBy"]!=null ) { this.UpdateBy=ds.Tables[0].Rows[0]["UpdateBy"].ToString(); } if(ds.Tables[0].Rows[0]["UpdateDate"]!=null && ds.Tables[0].Rows[0]["UpdateDate"].ToString()!="") { this.UpdateDate=DateTime.Parse(ds.Tables[0].Rows[0]["UpdateDate"].ToString()); } } } /// <summary> /// 得到一个对象实体 /// </summary> public void GetModel2(string MaterialCode) { StringBuilder strSql = new StringBuilder(); strSql.Append("select AutoID,MaterialCode,MaterialName,NnemonicCode,SpellCode,ClassFication,Color,Size,Weight,IsVirtual,ProcessRoute,MaterialPlanType,MaterialStatusType,PurchasingLeadCycle,PreparationCycle,RepleaseCycle,CostPrice,Price,BeginDate,EndDate,Remark,Active,LoginBy,LoginDate,UpdateBy,UpdateDate "); strSql.Append(" FROM [pdt_MaterialMasterBill] "); strSql.Append(" where [email protected] "); SqlParameter[] parameters = { new SqlParameter("@MaterialCode", SqlDbType.VarChar,-1)}; parameters[0].Value = MaterialCode; DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["AutoID"] != null && ds.Tables[0].Rows[0]["AutoID"].ToString() != "") { this.AutoID = int.Parse(ds.Tables[0].Rows[0]["AutoID"].ToString()); } if (ds.Tables[0].Rows[0]["MaterialCode"] != null) { this.MaterialCode = ds.Tables[0].Rows[0]["MaterialCode"].ToString(); } if (ds.Tables[0].Rows[0]["MaterialName"] != null) { this.MaterialName = ds.Tables[0].Rows[0]["MaterialName"].ToString(); } if (ds.Tables[0].Rows[0]["NnemonicCode"] != null) { this.NnemonicCode = ds.Tables[0].Rows[0]["NnemonicCode"].ToString(); } if (ds.Tables[0].Rows[0]["SpellCode"] != null) { this.SpellCode = ds.Tables[0].Rows[0]["SpellCode"].ToString(); } if (ds.Tables[0].Rows[0]["ClassFication"] != null && ds.Tables[0].Rows[0]["ClassFication"].ToString() != "") { this.ClassFication = int.Parse(ds.Tables[0].Rows[0]["ClassFication"].ToString()); } if (ds.Tables[0].Rows[0]["Color"] != null) { this.Color = ds.Tables[0].Rows[0]["Color"].ToString(); } if (ds.Tables[0].Rows[0]["Size"] != null && ds.Tables[0].Rows[0]["Size"].ToString() != "") { this.Size = decimal.Parse(ds.Tables[0].Rows[0]["Size"].ToString()); } if (ds.Tables[0].Rows[0]["Weight"] != null && ds.Tables[0].Rows[0]["Weight"].ToString() != "") { this.Weight = decimal.Parse(ds.Tables[0].Rows[0]["Weight"].ToString()); } if (ds.Tables[0].Rows[0]["IsVirtual"] != null && ds.Tables[0].Rows[0]["IsVirtual"].ToString() != "") { if ((ds.Tables[0].Rows[0]["IsVirtual"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsVirtual"].ToString().ToLower() == "true")) { this.IsVirtual = true; } else { this.IsVirtual = false; } } if (ds.Tables[0].Rows[0]["ProcessRoute"] != null && ds.Tables[0].Rows[0]["ProcessRoute"].ToString() != "") { this.ProcessRoute = int.Parse(ds.Tables[0].Rows[0]["ProcessRoute"].ToString()); } if (ds.Tables[0].Rows[0]["MaterialPlanType"] != null && ds.Tables[0].Rows[0]["MaterialPlanType"].ToString() != "") { this.MaterialPlanType = int.Parse(ds.Tables[0].Rows[0]["MaterialPlanType"].ToString()); } if (ds.Tables[0].Rows[0]["MaterialStatusType"] != null && ds.Tables[0].Rows[0]["MaterialStatusType"].ToString() != "") { this.MaterialStatusType = int.Parse(ds.Tables[0].Rows[0]["MaterialStatusType"].ToString()); } if (ds.Tables[0].Rows[0]["PurchasingLeadCycle"] != null && ds.Tables[0].Rows[0]["PurchasingLeadCycle"].ToString() != "") { this.PurchasingLeadCycle = int.Parse(ds.Tables[0].Rows[0]["PurchasingLeadCycle"].ToString()); } if (ds.Tables[0].Rows[0]["PreparationCycle"] != null && ds.Tables[0].Rows[0]["PreparationCycle"].ToString() != "") { this.PreparationCycle = int.Parse(ds.Tables[0].Rows[0]["PreparationCycle"].ToString()); } if (ds.Tables[0].Rows[0]["RepleaseCycle"] != null && ds.Tables[0].Rows[0]["RepleaseCycle"].ToString() != "") { this.RepleaseCycle = int.Parse(ds.Tables[0].Rows[0]["RepleaseCycle"].ToString()); } if (ds.Tables[0].Rows[0]["CostPrice"] != null && ds.Tables[0].Rows[0]["CostPrice"].ToString() != "") { this.CostPrice = decimal.Parse(ds.Tables[0].Rows[0]["CostPrice"].ToString()); } if (ds.Tables[0].Rows[0]["Price"] != null && ds.Tables[0].Rows[0]["Price"].ToString() != "") { this.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if (ds.Tables[0].Rows[0]["BeginDate"] != null && ds.Tables[0].Rows[0]["BeginDate"].ToString() != "") { this.BeginDate = DateTime.Parse(ds.Tables[0].Rows[0]["BeginDate"].ToString()); } if (ds.Tables[0].Rows[0]["EndDate"] != null && ds.Tables[0].Rows[0]["EndDate"].ToString() != "") { this.EndDate = DateTime.Parse(ds.Tables[0].Rows[0]["EndDate"].ToString()); } if (ds.Tables[0].Rows[0]["Remark"] != null) { this.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); } if (ds.Tables[0].Rows[0]["Active"] != null && ds.Tables[0].Rows[0]["Active"].ToString() != "") { if ((ds.Tables[0].Rows[0]["Active"].ToString() == "1") || (ds.Tables[0].Rows[0]["Active"].ToString().ToLower() == "true")) { this.Active = true; } else { this.Active = false; } } if (ds.Tables[0].Rows[0]["LoginBy"] != null) { this.LoginBy = ds.Tables[0].Rows[0]["LoginBy"].ToString(); } if (ds.Tables[0].Rows[0]["LoginDate"] != null && ds.Tables[0].Rows[0]["LoginDate"].ToString() != "") { this.LoginDate = DateTime.Parse(ds.Tables[0].Rows[0]["LoginDate"].ToString()); } if (ds.Tables[0].Rows[0]["UpdateBy"] != null) { this.UpdateBy = ds.Tables[0].Rows[0]["UpdateBy"].ToString(); } if (ds.Tables[0].Rows[0]["UpdateDate"] != null && ds.Tables[0].Rows[0]["UpdateDate"].ToString() != "") { this.UpdateDate = DateTime.Parse(ds.Tables[0].Rows[0]["UpdateDate"].ToString()); } } } /// <summary> /// 获得数据列表 /// </summary> public DataSet GetList(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append("select * "); strSql.Append(" FROM [pdt_MaterialMasterBill] "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } return DbHelperSQL.Query(strSql.ToString()); } #endregion Method } }
时间: 2024-10-03 13:20:43