73 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
 | |
| /// <summary>
 | |
| ///INTERFACE IMPLIMENT FOR TABLE t_tmsLineDetail
 | |
| ///By wm with codesmith. 
 | |
| ///on 07/23/2017
 | |
| /// </summary>
 | |
| 
 | |
| using System;
 | |
| using System.Data.SqlClient; 
 | |
| namespace DeiNiu.wms.Data.Model
 | |
| {
 | |
|     [Serializable]  class TmsLineDetail_Imp : TmsLineDetail_base_Imp
 | |
|     { 
 | |
|         protected override void CmdPrepare(SqlCommand sqlCmd)
 | |
|         { 
 | |
|             base.CmdPrepare(sqlCmd);
 | |
|             TmsLineDetail mObj = ( TmsLineDetail)modelObj;
 | |
|             switch (_cust_op_flag)
 | |
|             {
 | |
|              case 99:  //query with dic
 | |
|                     _strSql = "SELECT *,ROW_NUMBER() OVER (ORDER BY ID DESC) as sortNo  FROM t_tmsLineDetail  WHERE DR = 1 " + mObj.CmdParameters[0].ToString();
 | |
|                     _strSql = "SELECT * FROM (" + _strSql + " )AS SORTEDTB WHERE sortNo BETWEEN @START AND @END" + " ORDER BY ID DESC";
 | |
|                     _strSql += ";SELECT COUNT(*) FROM t_tmsLineDetail  WHERE DR = 1 " + mObj.CmdParameters[0].ToString();
 | |
|                    
 | |
|                     sqlCmd.Parameters.AddWithValue("@START", this._rownumStart);
 | |
|                     sqlCmd.Parameters.AddWithValue("@END", this._rownumEnd);
 | |
|                     sqlCmd.CommandText = _strSql;
 | |
| 
 | |
|                     break;
 | |
|                 case 100:  //by cust name
 | |
|                     _strSql = "SELECT * FROM v_tmsLineDetail WHERE custName like @NAME ";
 | |
|                     sqlCmd.CommandText = _strSql; 
 | |
|                      sqlCmd.Parameters.AddWithValue("@NAME", string.Format("%{0}%",  mObj.CmdParameters[0])  );
 | |
|                     break;
 | |
| 
 | |
|                 case 200:  //get available customers by lineId, custName, pages
 | |
|                   //  _strSql = "SELECT *,ROW_NUMBER() OVER (ORDER BY custName) as sortNo FROM v_customer a WHERE not exists (select 1 from t_tmsLineDetail where lineId =@lineId and custId = a.custId)"   +mObj.CmdParameters[1].ToString();
 | |
|                     _strSql = "SELECT *,ROW_NUMBER() OVER (ORDER BY custName) as sortNo FROM v_customer a WHERE not exists (select 1 from t_tmsLineDetail where custId = a.custId)" + mObj.CmdParameters[1].ToString();
 | |
|                     _strSql = "SELECT * FROM (" + _strSql + " )AS SORTEDTB WHERE sortNo BETWEEN @START AND @END" + " ORDER BY custName ";
 | |
|                     //_strSql += ";SELECT COUNT(*) FROM  v_customer a WHERE not exists (select 1 from t_tmsLineDetail where lineId =@lineId and custId = a.custId)" + mObj.CmdParameters[1].ToString();
 | |
|                     _strSql += ";SELECT COUNT(*) FROM  v_customer a WHERE not exists (select 1 from t_tmsLineDetail where custId = a.custId)" + mObj.CmdParameters[1].ToString();
 | |
| 
 | |
| 
 | |
|                     sqlCmd.CommandText = _strSql;
 | |
|                   //  sqlCmd.Parameters.AddWithValue("@lineId", mObj.CmdParameters[0]);
 | |
|                     sqlCmd.Parameters.AddWithValue("@START", mObj.CmdParameters[2]);
 | |
|                     sqlCmd.Parameters.AddWithValue("@END", mObj.CmdParameters[3]);
 | |
|                     break;
 | |
|                 case 300:  //by lineId
 | |
|                     _strSql = "SELECT * FROM v_tmsLineDetail WHERE lineId = @lineId order by lineOrder ";
 | |
|                     sqlCmd.CommandText = _strSql;
 | |
|                     sqlCmd.Parameters.AddWithValue("@lineId", mObj.CmdParameters[0]);
 | |
|                     break;
 | |
|                 case 400:  //update line cust orders
 | |
|                     _strSql = "update t_tmsLineDetail set lineOrder = lineOrder + @adjust WHERE lineId = @lineId and lineOrder between @start and @end";
 | |
|                     sqlCmd.CommandText = _strSql;
 | |
|                     sqlCmd.Parameters.AddWithValue("@lineId", mObj.CmdParameters[0]);
 | |
|                     sqlCmd.Parameters.AddWithValue("@adjust", mObj.CmdParameters[3]);
 | |
|                     sqlCmd.Parameters.AddWithValue("@start", mObj.CmdParameters[1]);
 | |
|                     sqlCmd.Parameters.AddWithValue("@end", mObj.CmdParameters[2]);
 | |
|                     break;
 | |
| 
 | |
|                 case 500:  //by cust name
 | |
|                     _strSql = "SELECT * FROM t_tmsLineDetail WHERE custId =@custId  ";
 | |
|                     sqlCmd.CommandText = _strSql;
 | |
|                     sqlCmd.Parameters.AddWithValue("@custId", mObj.CmdParameters[0]);
 | |
|                     break;
 | |
| 
 | |
| 
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| } |