| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Configuration; | 
					
						
							|  |  |  |  | using DeiNiu.Utils; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace DeiNiu.Data.BaseObject | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     [Serializable] | 
					
						
							|  |  |  |  |     public abstract class BaseModel :BaseOperModel | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         internal int custOperFlag = 0;      | 
					
						
							|  |  |  |  |         public BaseModel() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             getImp(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public  BaseModel(DataRow dr) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             getModel(dr);  | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public BaseModel(System.Data.SqlClient.SqlConnection _Conn) | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             getImp(); | 
					
						
							|  |  |  |  |             model_imp._Conn = _Conn; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public BaseModel(int operid,string connStr) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             getImp(); | 
					
						
							|  |  |  |  |             model_imp.operid = operid; | 
					
						
							|  |  |  |  |             model_imp.connString = connStr; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |        protected BaseModel_Imp model_imp; | 
					
						
							|  |  |  |  |         public int Add() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |           //  _operater = _operater >0 ?_operater : DeiNiu.Utils.LoginInfo.UserId;  | 
					
						
							|  |  |  |  |             return model_imp.Add(this); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public int Update() | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             //  _operater = DeiNiu.Utils. LoginInfo.UserId > 0 ? DeiNiu.Utils. LoginInfo.UserId : _operater; | 
					
						
							|  |  |  |  |             if (this.ID <= 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return 0; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             _lastmodified = getDateTime(); | 
					
						
							|  |  |  |  |             return model_imp.Update(this); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public int UpdateNoCompare() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //  _operater = DeiNiu.Utils. LoginInfo.UserId > 0 ? DeiNiu.Utils. LoginInfo.UserId : _operater; | 
					
						
							|  |  |  |  |             _lastmodified = getDateTime(); | 
					
						
							|  |  |  |  |             return model_imp.UpdateNoCompare(this); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public int Delete() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |            return model_imp.Delete(this); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public int rownumStart | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get { return model_imp.rownumStart; } | 
					
						
							|  |  |  |  |             set { model_imp.rownumStart = value; } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public int rownumEnd | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get { return model_imp.rownumEnd; } | 
					
						
							|  |  |  |  |             set { model_imp.rownumEnd = value; } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public int QueryCount() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string tmp = model_imp.QueryCount().Tables[0].Rows[0][0].ToString(); | 
					
						
							|  |  |  |  |             return tmp != string.Empty | 
					
						
							|  |  |  |  |                        ? Convert.ToInt32(tmp) | 
					
						
							|  |  |  |  |                        : 0; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public DataSet QueryActived() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return model_imp.QueryActived(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public DataSet Query(BaseModel exampleObj) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return model_imp.Query(exampleObj); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public DataSet Query() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return model_imp.Query(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         protected DataSet CustQuery(int custOperFlag) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             this.custOperFlag = custOperFlag; | 
					
						
							|  |  |  |  |             return model_imp.CustQuery(this); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         protected int queryCount(int custOperFlag) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             this.custOperFlag = custOperFlag; | 
					
						
							|  |  |  |  |             DataTable dt = model_imp.CustQuery(this).Tables[0]; | 
					
						
							|  |  |  |  |             if (dt.Rows.Count ==1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (dt.Columns.Count > 0) | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |                     return Convert.ToInt32( dt.Rows[0][0].ToString()); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return 0; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         protected int CustOper(int custOperFlag) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             this.custOperFlag = custOperFlag; | 
					
						
							|  |  |  |  |             return model_imp.CustOper(this); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       //  public int colone() | 
					
						
							|  |  |  |  |        // { | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |       //  } | 
					
						
							|  |  |  |  |         public void getModel(DataRow dr) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 model_imp.getModel(this, dr); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception er ) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 throw er; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public void getModel() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             custOperFlag = 0;  //2010.1.3 | 
					
						
							|  |  |  |  |            model_imp.getModel(this); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public void getModel(int custOperFlag) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             this.custOperFlag = custOperFlag; | 
					
						
							|  |  |  |  |             model_imp.getModel(this); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         /*private void getImp() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Type tp = GetType(); | 
					
						
							|  |  |  |  |             String impClassName = getImpClassName(tp.FullName); | 
					
						
							|  |  |  |  |            // impClassName = "DeiNiu.wms.Data.Model.Department_Imp"; | 
					
						
							|  |  |  |  |             Type tpImp = tp.Assembly.GetType(impClassName); | 
					
						
							|  |  |  |  |              model_imp = (BaseModel_Imp)System.Activator.CreateInstance(tpImp); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         */ | 
					
						
							|  |  |  |  |         protected virtual void getImp() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private String getImpClassName(String ClassName) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return ClassName + "_Imp"; | 
					
						
							|  |  |  |  |            | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public DataSet Query(string condition) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             cmdParameters[0] = condition; | 
					
						
							|  |  |  |  |             return CustQuery(99); | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |            /* try {  } | 
					
						
							|  |  |  |  |             catch | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 return new DataSet(); | 
					
						
							|  |  |  |  |             }*/ | 
					
						
							|  |  |  |  |            | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |         public int getNextSeq(enumCreateOrderType orderType) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             string seq = "seq" + Utils.Util.getPrefix(orderType); | 
					
						
							| 
									
										
										
										
											2024-03-06 20:48:05 +08:00
										 |  |  |  |            // LogHelper.debug(GetType(), " seq name is " + seq); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             return model_imp.getSequence("seq" + Utils.Util.getPrefix(orderType) ); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |         public int getNextSeq(string seqName) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return model_imp.getSequence(seqName); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public string getDateTime() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return model_imp.getDateTime(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected string getCondition(string querystr, int start, int end) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (end > start && start > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.rownumStart = start; | 
					
						
							|  |  |  |  |                 this.rownumEnd = end; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             //  DataSet ds = string.IsNullOrEmpty(querystr) ? _obj.Query() : _obj.Query(querystr); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (string.IsNullOrEmpty(querystr)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return ""; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |            | 
					
						
							|  |  |  |  |             return getCondition( querystr); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |         public string getCondition(string querystr) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             string condition = ""; | 
					
						
							|  |  |  |  |             //   querystr = filtRiskChar(querystr); | 
					
						
							|  |  |  |  |             string[] parameters = querystr.Split(";".ToCharArray()); | 
					
						
							|  |  |  |  |             foreach (string value in parameters) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (string.IsNullOrEmpty(value)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     continue; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 string[] par = value.Split("#".ToCharArray()); | 
					
						
							|  |  |  |  |                 condition += par.Length == 0 ? "" : " and "; | 
					
						
							|  |  |  |  |                 foreach (string p in par) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     condition += p; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return condition; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |         public override string ToString() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return Util.getJson(this); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |      | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | } |