| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |  | 
					
						
							|  |  |  |  | /// <summary> | 
					
						
							|  |  |  |  | ///LOGIC CLASS FOR TABLE t_wmsImportSeeds | 
					
						
							|  |  |  |  | ///By wm with codesmith.  | 
					
						
							|  |  |  |  | ///on 07/21/2019 | 
					
						
							|  |  |  |  | /// </summary> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using DeiNiu.wms.Data.Model; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Transactions; | 
					
						
							|  |  |  |  | using DeiNiu.wms.win; | 
					
						
							|  |  |  |  | using DeiNiu.Utils; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace DeiNiu.wms.Logical | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     [Serializable] | 
					
						
							|  |  |  |  |     public class lWmsImportSeeds   :lbase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         WmsImportSeeds _obj; | 
					
						
							|  |  |  |  |         public lWmsImportSeeds() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |              initialize(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |   | 
					
						
							|  |  |  |  |         public  WmsImportSeeds getWmsImportSeeds | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |              if (_obj == null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     _obj = new WmsImportSeeds(); | 
					
						
							|  |  |  |  |                     | 
					
						
							|  |  |  |  |                 }  | 
					
						
							|  |  |  |  |                 _obj.operater = operId; | 
					
						
							|  |  |  |  |                 return _obj; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |        public lWmsImportSeeds(int operId) | 
					
						
							|  |  |  |  |             : base(operId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             initialize(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |    | 
					
						
							|  |  |  |  | 		/// <summary> | 
					
						
							|  |  |  |  | 		/// get all data | 
					
						
							|  |  |  |  | 		/// </summary> | 
					
						
							|  |  |  |  |         public DataSet getAllData() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |            return _obj.Query(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// get all data | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public DataSet getAllActiveData() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return _obj.QueryActived(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		/// <summary> | 
					
						
							|  |  |  |  | 		/// get a record by id | 
					
						
							|  |  |  |  | 		/// </summary> | 
					
						
							|  |  |  |  |         public void initialize(int id) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  |             _obj = id != 0 ? new WmsImportSeeds(id) : new WmsImportSeeds(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  | 		/// get a record by id 0 | 
					
						
							|  |  |  |  | 		/// </summary> | 
					
						
							|  |  |  |  |         public void initialize() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             initialize(0); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          /// <summary> | 
					
						
							|  |  |  |  |         /// get a record by id | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public void initialize(DataRow dr) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             _obj =   new WmsImportSeeds(dr); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |         protected override DeiNiu.Data.BaseObject.BaseModel getModel() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return _obj; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |   | 
					
						
							|  |  |  |  |         //begin cust db operation, query, excute sql etc. | 
					
						
							|  |  |  |  |       | 
					
						
							|  |  |  |  |         internal int add(WmsImportSeeds obj) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return obj.Add(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |       | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// update in a transaction scrop | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public void update() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (valid()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 using (TransactionScope scope = new TransactionScope()) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     //Node tmp = new Node(); | 
					
						
							|  |  |  |  |                     //tmp.parentid = 1; | 
					
						
							|  |  |  |  |                     //tmp.name = "test trans" + DateTime.Now; | 
					
						
							|  |  |  |  |                     //tmp.description = "this is for transTest"; | 
					
						
							|  |  |  |  |                     //tmp.Add(); | 
					
						
							|  |  |  |  |                     _obj.Update(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     scope.Complete(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |          private bool valid() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          internal int updateCount(int count, int id, int status,String desc) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              if (status == (int)enumSeedsState.待处理) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  WmsImportSeeds wis = new WmsImportSeeds(id); | 
					
						
							|  |  |  |  |                  if (wis.ID == id) | 
					
						
							|  |  |  |  |                  { | 
					
						
							|  |  |  |  |                      wis.countOut = count; | 
					
						
							|  |  |  |  |                      wis.description += desc; | 
					
						
							|  |  |  |  |                      return wis.Update(); | 
					
						
							|  |  |  |  |                  } | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              else if (status == (int)enumSeedsState.处理中 || status == (int)enumSeedsState.已亮灯) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  WmsImportSeeds_tmp wis = new WmsImportSeeds_tmp(id); | 
					
						
							|  |  |  |  |                  if (wis.ID == id) | 
					
						
							|  |  |  |  |                  { | 
					
						
							|  |  |  |  |                      wis.countOut = count; | 
					
						
							|  |  |  |  |                      wis.description += desc; | 
					
						
							|  |  |  |  |                      return wis.Update(); | 
					
						
							|  |  |  |  |                  } | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              else if (status == (int)enumSeedsState.已按灭) | 
					
						
							|  |  |  |  |              {  | 
					
						
							|  |  |  |  |                  WmsImportSeeds_history wis = new WmsImportSeeds_history(id); | 
					
						
							|  |  |  |  |                  if (wis.ID == id) | 
					
						
							|  |  |  |  |                  { | 
					
						
							|  |  |  |  |                      wis.countOut = count; | 
					
						
							|  |  |  |  |                      wis.description += desc; | 
					
						
							|  |  |  |  |                     return wis.Update(); | 
					
						
							|  |  |  |  |                  }  | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              return 0; | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          internal int loadNewSeeds(int partion, string seedsNo) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              /* | 
					
						
							|  |  |  |  |              string isAutoBind = System.Configuration.ConfigurationManager.AppSettings["IsAutoBind"]; | 
					
						
							|  |  |  |  |              if (!String.IsNullOrEmpty(isAutoBind) || Convert.ToInt16(isAutoBind) >0) //自动绑定标签ID | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                DataTable dt =  getWmsImportSeeds.QueryBySeeds(seedsNo).Tables[0]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                string lastCust = ""; | 
					
						
							|  |  |  |  |                int elId =0; | 
					
						
							|  |  |  |  |                foreach (DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |                { | 
					
						
							|  |  |  |  |                    WmsImportSeeds wis = new WmsImportSeeds(dr);  | 
					
						
							|  |  |  |  |                     | 
					
						
							|  |  |  |  |                    if (string.IsNullOrEmpty(lastCust) || !lastCust.Equals(wis.custName)) | 
					
						
							|  |  |  |  |                    { | 
					
						
							|  |  |  |  |                        lastCust = wis.custName; | 
					
						
							|  |  |  |  |                        elId++;  | 
					
						
							|  |  |  |  |                    } | 
					
						
							|  |  |  |  |                    wis.elabId = elId; | 
					
						
							|  |  |  |  |                    wis.Update();  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                }  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              return getWmsImportSeeds.loadNewSeeds(partion, seedsNo); | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  |          internal DataTable getSumCount(string seedsNo, string barcode) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              return getWmsImportSeeds.getSumCount(seedsNo, barcode); | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  |          internal List<ELabel> startNewSeed(int deskId, string seedsNo, string barcode, int operater, int color,bool isValid ) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              return getWmsImportSeeds.startNewSeed(deskId, seedsNo, barcode, operater, color,  isValid); | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  |          internal List<ELabel> startNewDeskSeed( string seedsNo, string barcode, int operater, int color, bool isValid) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              return getWmsImportSeeds.startNewDeskSeed(seedsNo, barcode, operater, color, isValid); | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          internal int deleteOrder(string seedsNo) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              return getWmsImportSeeds.deleteOrder(seedsNo); | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  |   | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         String seedsNo ="seedsNo123";        | 
					
						
							|  |  |  |  |         String barcode ="1099"; | 
					
						
							|  |  |  |  |          internal bool validLimit(string input) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              WmsOutSeeds wos = new WmsOutSeeds(); | 
					
						
							|  |  |  |  |              DataTable dt = wos.getValidSeed(1000, seedsNo, barcode); | 
					
						
							|  |  |  |  |              if (dt.Rows.Count > 0) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  wos = new WmsOutSeeds(dt.Rows[0]); | 
					
						
							|  |  |  |  |                  return input.Equals(wos.description); | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              return false; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  |          internal int isExceedLimitCnt(bool isFix, int limitCount) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              int notExceed = -1; | 
					
						
							|  |  |  |  |              int exceed = 0; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              WmsOutSeeds wos = new WmsOutSeeds(); | 
					
						
							|  |  |  |  |              DataTable dt = wos.getValidSeed(1000, seedsNo, barcode); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              if (dt.Rows.Count == 0) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  wos.seedsNo = seedsNo; | 
					
						
							|  |  |  |  |                  wos.barcode = barcode; | 
					
						
							|  |  |  |  |                  wos.deskId = 1000; | 
					
						
							|  |  |  |  |                  wos.count = 1; | 
					
						
							|  |  |  |  |                  wos.description ="D0-43-D4-A4-A9-EF-C8-72-AD-8E-FD-C3-81-07-BF-84"; | 
					
						
							|  |  |  |  |                  wos.custOrder = "001"; | 
					
						
							|  |  |  |  |                  wos.Add(); | 
					
						
							|  |  |  |  |                  return notExceed; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              else | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  wos = new WmsOutSeeds(dt.Rows[0]); | 
					
						
							|  |  |  |  |                  if (isFix) | 
					
						
							|  |  |  |  |                  { | 
					
						
							|  |  |  |  |                      wos.count = -1; | 
					
						
							|  |  |  |  |                      wos.Update(); | 
					
						
							|  |  |  |  |                      return notExceed; | 
					
						
							|  |  |  |  |                  } | 
					
						
							|  |  |  |  |                  int count = (int)wos.count; | 
					
						
							|  |  |  |  |                  if (count == -1) | 
					
						
							|  |  |  |  |                  { | 
					
						
							|  |  |  |  |                      return notExceed; | 
					
						
							|  |  |  |  |                  } | 
					
						
							|  |  |  |  |                  else | 
					
						
							|  |  |  |  |                      if (count < limitCount) | 
					
						
							|  |  |  |  |                      { | 
					
						
							|  |  |  |  |                          wos.count++; | 
					
						
							|  |  |  |  |                          wos.Update();  | 
					
						
							|  |  |  |  |                          return limitCount -(int)wos.count; | 
					
						
							|  |  |  |  |                      } | 
					
						
							|  |  |  |  |                      else | 
					
						
							|  |  |  |  |                      { | 
					
						
							|  |  |  |  |                          return exceed; | 
					
						
							|  |  |  |  |                      }  | 
					
						
							|  |  |  |  |              }  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public ELight getLight(int deskId,string barcode) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              ELight el = new ELight(); | 
					
						
							|  |  |  |  |              DataTable dt = getWmsImportSeeds.getLightInfo(barcode, deskId); | 
					
						
							|  |  |  |  |              foreach (DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  WmsImportSeeds_tmp it = new WmsImportSeeds_tmp(dr);  | 
					
						
							|  |  |  |  |                  el.lightId = it.elabId; | 
					
						
							|  |  |  |  |                  el.which =Convert.ToByte( it.elabAddress); | 
					
						
							|  |  |  |  |                  el.port = it.port; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                  return el; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              return el; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal int updateCountSeeds(int seedsPlanCnt, int seedscnt, string seedsNo, string barcode) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             /* cust portNo list scope | 
					
						
							|  |  |  |  |              * 1000-2000 重点分货 | 
					
						
							|  |  |  |  |              * 2000-3000 一般分货 | 
					
						
							|  |  |  |  |              * 3000-4000 加盟 | 
					
						
							|  |  |  |  |              * 5000-5000 外区 | 
					
						
							|  |  |  |  |              * 6000-7000 新店及业绩差 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             */ | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             DataTable dtSeeds = getWmsImportSeeds.getCustomerSeedsList(seedsNo, barcode); | 
					
						
							|  |  |  |  |             DataView dvSeeds = dtSeeds.DefaultView; | 
					
						
							|  |  |  |  |             getWmsImportSeeds.resetOut(seedsNo, barcode); | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             int cnt = 0; | 
					
						
							|  |  |  |  |             | 
					
						
							|  |  |  |  |             int diff = seedscnt - seedsPlanCnt; | 
					
						
							|  |  |  |  |             int absDiff = Math.Abs(diff); | 
					
						
							|  |  |  |  |             if (absDiff == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return 0; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             string rowFilter = " portNo <2000"; //先分重点 | 
					
						
							|  |  |  |  |             dvSeeds.RowFilter = rowFilter; | 
					
						
							|  |  |  |  |             dvSeeds.Sort = "portNo"; | 
					
						
							|  |  |  |  |             int firstCount = dvSeeds.Count*2;     //45个 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (absDiff > firstCount) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 firstCount = diff > 0 ? firstCount : firstCount * -1; | 
					
						
							|  |  |  |  |                 cnt = updateCountSeeds(firstCount, rowFilter, seedsNo, barcode); | 
					
						
							|  |  |  |  |                 rowFilter = "  portNo <3000";              //重点、一般合起来分 | 
					
						
							|  |  |  |  |                // rowFilter = " portNo >2000 and portNo <3000"; //先分重点,后分一般 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (diff > 0) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     diff -= cnt; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     diff += cnt; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 cnt += updateCountSeeds(diff, rowFilter, seedsNo, barcode); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                cnt= updateCountSeeds(diff, rowFilter, seedsNo, barcode); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (cnt == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 cnt = updateCountSeeds(diff, "seedsNo>0", seedsNo, barcode); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return cnt; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal int updateCountSeeds(int diff, string rowFilter, string seedsNo, string barcode) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             int cnt = 0;  | 
					
						
							|  |  |  |  |            | 
					
						
							|  |  |  |  |             int absDiff = Math.Abs(diff);  | 
					
						
							|  |  |  |  |            | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             DataTable dtSeeds  ; | 
					
						
							|  |  |  |  |             DataView dvSeeds  ; | 
					
						
							|  |  |  |  |             | 
					
						
							|  |  |  |  |             while (absDiff > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 dtSeeds = getWmsImportSeeds.getCustomerSeedsList(seedsNo, barcode); | 
					
						
							|  |  |  |  |                 dvSeeds = dtSeeds.DefaultView; | 
					
						
							|  |  |  |  |                 dvSeeds.RowFilter = rowFilter; | 
					
						
							|  |  |  |  |                 dvSeeds.Sort = "portNo"; | 
					
						
							|  |  |  |  |                 bool isLimit = true; | 
					
						
							|  |  |  |  |                 List<int> lst = new List<int>(); | 
					
						
							|  |  |  |  |                 foreach (DataRowView drv in dvSeeds) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     if (absDiff <= 0) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         break; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     WmsImportSeeds_tmp wit = new WmsImportSeeds_tmp(drv.Row); | 
					
						
							|  |  |  |  |                     if (lst.Contains(wit.ID)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         continue; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (!lst.Contains(wit.ID) && wit.countOut>0 | 
					
						
							|  |  |  |  |                         && (wit.countOut < wit.count * 2) && (wit.countOut > wit.count / 2) //不允许减量或者加量分货超订货50% | 
					
						
							|  |  |  |  |                        // && Math.Abs(wit.countOut - wit.count) < 20 //所有品项1家门店不超过20包 | 
					
						
							|  |  |  |  |                         ) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         wit.countOut += diff > 0 ? 1 : -1; | 
					
						
							|  |  |  |  |                         wit.Update(); | 
					
						
							|  |  |  |  |                         absDiff--; | 
					
						
							|  |  |  |  |                         cnt++; | 
					
						
							|  |  |  |  |                         isLimit = false; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     lst.Add(wit.ID); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (isLimit) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     break; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return cnt; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         internal DataSet queryDesk(string seedNo, string barcode,  bool isValid) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return getWmsImportSeeds.queryDesk(seedNo,   barcode,      isValid); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal DataTable getPrintCodes(string seedsNo, string barcode) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return getWmsImportSeeds.getPrintCodes(seedsNo, barcode); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public DataSet queryDesk(string querystr, int rownumStart, int rownumEnd) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             _obj = getWmsImportSeeds ; | 
					
						
							|  |  |  |  |             if (rownumEnd > rownumStart && rownumStart > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 _obj.rownumStart = rownumStart; | 
					
						
							|  |  |  |  |                 _obj.rownumEnd = rownumEnd; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             //  DataSet ds = string.IsNullOrEmpty(querystr) ? _obj.Query() : _obj.Query(querystr); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             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 _obj.queryDesk(condition); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         public void clearHistory() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return _obj.clearHistroy(); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  |      | 
					
						
							|  |  |  |  |      | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  |   |