Exemple #1
0
        /// <summary>
        /// 查询异常类型表
        /// </summary>
        /// <param name="SQLCommand"></param>
        /// <returns></returns>
        public List <string> selectPExceptionTypesDal(string SQLCommand)
        {
            string        sql  = SQLhelp.GetSQLCommand(SQLCommand);
            List <string> list = new List <string>();

            try
            {
                using (SqlDataReader reader = SQLhelp.ExecuteReader(sql, CommandType.Text))
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            list.Add(reader.GetString(0));
                        }
                    }
                    return(list);
                }
            }
            catch
            {
                throw;
            }
        }
Exemple #2
0
        /// <summary>
        /// 按主键为条件查询异常配置表
        /// </summary>
        /// <param name="BarcodeEncoding"></param>
        /// <param name="SQLCommand"></param>
        /// <returns></returns>
        public List <PEncodingSetting> ConditionsSelectPEncodingSettingDal(string BarcodeEncoding, string SQLCommand)
        {
            string sql = SQLhelp.GetSQLCommand(SQLCommand);
            List <PEncodingSetting> list = new List <PEncodingSetting>();

            SqlParameter[] pms = new SqlParameter[] {
                new SqlParameter("@be", SqlDbType.VarChar, 100)
                {
                    Value = BarcodeEncoding
                }
            };

            try
            {
                using (SqlDataReader reader = SQLhelp.ExecuteReader(sql, CommandType.Text, pms))
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            list.Add(new PEncodingSetting()
                            {
                                BarcodeEncoding    = reader.GetString(0),
                                ProblemDescription = reader.GetString(1),
                                ES_ExceptionTypes  = reader.GetString(2)
                            });
                        }
                    }
                    return(list);
                }
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 查询TestOrder,TestTime
        /// </summary>
        /// <param name="SQLCommand"></param>
        /// <returns></returns>
        public List <ProductPerformance> GetProductPerformanceDal(string order, string SoftModel, bool flag, DateTime timeBegin, DateTime timeEnd, string SQLCommand)
        {
            string sql = SQLhelp.GetSQLCommand(SQLCommand);
            List <ProductPerformance> list = new List <ProductPerformance>();

            #region 旧式
            //if (order != "")
            //{
            //    sql += " and ZhiDan=@order ";
            //}
            //if (SoftModel != "")
            //{
            //    sql += " and SoftModel=@softmodel ";
            //}
            ////if (flag)
            ////{
            ////    sql += " and TestTime>=@timebegin and TestTime<=@timeend ";
            ////}
            //sql += " order by TestTime ";
            //SqlParameter[] pms;
            //List<ProductPerformance> list = new List<ProductPerformance>();
            //if (order != ""&&SoftModel=="")
            //{
            //    pms = new SqlParameter[]{
            //    new SqlParameter("@order",SqlDbType.VarChar,100){Value=order},
            //    new SqlParameter("@timebegin",SqlDbType.DateTime){Value=timeBegin},
            //    new SqlParameter("@timeend",SqlDbType.DateTime){Value=timeEnd}
            //};
            //}
            //else if (order == "" && SoftModel != "")
            //{
            //    pms = new SqlParameter[]{
            //    new SqlParameter("@softmodel",SqlDbType.VarChar,100){Value=SoftModel},
            //    new SqlParameter("@timebegin",SqlDbType.DateTime){Value=timeBegin},
            //    new SqlParameter("@timeend",SqlDbType.DateTime){Value=timeEnd}
            //};
            //}
            //else
            //{
            //    pms = new SqlParameter[]{
            //    new SqlParameter("@order",SqlDbType.VarChar,100){Value=order},
            //    new SqlParameter("@softmodel",SqlDbType.VarChar,20){Value=SoftModel},
            //    new SqlParameter("@timebegin",SqlDbType.DateTime){Value=timeBegin},
            //    new SqlParameter("@timeend",SqlDbType.DateTime){Value=timeEnd}
            //};
            //}
            #endregion

            SqlParameter[] pms = new SqlParameter[] {
                new SqlParameter("@bt", SqlDbType.Bit)
                {
                    Value = flag
                },
                new SqlParameter("@ord", SqlDbType.VarChar, 100)
                {
                    Value = order
                },
                new SqlParameter("@sof", SqlDbType.VarChar, 20)
                {
                    Value = SoftModel
                },
                new SqlParameter("@begin", SqlDbType.DateTime)
                {
                    Value = timeBegin
                },
                new SqlParameter("@end", SqlDbType.DateTime)
                {
                    Value = timeEnd
                }
            };

            try
            {
                using (SqlDataReader reader = SQLhelp.ExecuteReader(sql, CommandType.Text, pms))
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            list.Add(new ProductPerformance()
                            {
                                Order     = reader.IsDBNull(0) ? "" : reader.GetString(0),
                                Time      = reader.IsDBNull(1) ? DateTime.MinValue : reader.GetDateTime(1),
                                SoftModel = reader.IsDBNull(2)?"":reader.GetString(2),
                                Computer  = reader.IsDBNull(3)?"":reader.GetString(3)
                            });
                        }
                    }
                    return(list);
                }
            }
            catch
            {
                throw;
            }
        }
        public List <PWarehouseTable_Detailed> selectPWarehouseTable_DetailedDal(string MaterialName, string MaterialCode, string SupplierName, DateTime beginTime, DateTime endTime, string SQLCommand)
        {
            StringBuilder sql = new StringBuilder(SQLhelp.GetSQLCommand(SQLCommand));
            List <PWarehouseTable_Detailed> rlist      = new List <PWarehouseTable_Detailed>();
            List <SqlParameter>             listsqlpar = new List <SqlParameter>();
            List <string> whereList = new List <string>();

            if (MaterialName.Length > 0)
            {
                whereList.Add(" MaterialName=@MaterialName ");
                listsqlpar.Add(new SqlParameter("@MaterialName", SqlDbType.VarChar, 80)
                {
                    Value = MaterialName
                });
            }
            if (MaterialCode.Length > 0)
            {
                whereList.Add(" MaterialCode=@MaterialCode ");
                listsqlpar.Add(new SqlParameter("@MaterialCode", SqlDbType.VarChar, 80)
                {
                    Value = MaterialCode
                });
            }
            if (SupplierName.Length > 0)
            {
                whereList.Add(" SupplierName=@SupplierName ");
                listsqlpar.Add(new SqlParameter("@SupplierName", SqlDbType.VarChar, 80)
                {
                    Value = SupplierName
                });
            }
            if (beginTime.Year.ToString() != "1")
            {
                whereList.Add(" UpdateTime>=@UpdateTime ");
                listsqlpar.Add(new SqlParameter("@UpdateTime", SqlDbType.DateTime)
                {
                    Value = beginTime
                });
            }
            if (endTime.Year.ToString() != "1")
            {
                whereList.Add(" UpdateTime<=@UpdateTime1 ");
                listsqlpar.Add(new SqlParameter("@UpdateTime1", SqlDbType.DateTime)
                {
                    Value = endTime
                });
            }

            if (whereList.Count > 0)
            {
                sql.Append(" where ");//只要有查询条件,就拼接一个where
                //然后把后面的查询条件连起来
                sql.Append(string.Join(" and ", whereList));
            }

            if (listsqlpar.Count > 0)
            {
                SqlParameter[] pms = listsqlpar.ToArray();
                try
                {
                    using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text, pms))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                rlist.Add(new PWarehouseTable_Detailed()
                                {
                                    PurchaseReceiptID      = reader.GetString(0),
                                    PurchaseNo             = reader.GetString(1),
                                    SupplierName           = reader.GetString(2),
                                    BatchNo                = reader.GetString(3),
                                    MaterialCode           = reader.GetString(4),
                                    MaterialName           = reader.GetString(5),
                                    MaterialSpecifications = reader.GetString(6),
                                    ProductQuantity        = reader.GetInt32(7),
                                    note           = reader.GetString(8),
                                    Updatetime     = reader.GetDateTime(9),
                                    StorageAddress = reader.IsDBNull(10) ? "" : reader.GetString(10),
                                    UserName       = reader.IsDBNull(11)?"":reader.GetString(11)
                                });
                            }
                        }
                        return(rlist);
                    }
                }
                catch
                {
                    throw;
                }
            }
            else
            {
                try
                {
                    using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                rlist.Add(new PWarehouseTable_Detailed()
                                {
                                    PurchaseReceiptID      = reader.GetString(0),
                                    PurchaseNo             = reader.GetString(1),
                                    SupplierName           = reader.GetString(2),
                                    BatchNo                = reader.GetString(3),
                                    MaterialCode           = reader.GetString(4),
                                    MaterialName           = reader.GetString(5),
                                    MaterialSpecifications = reader.GetString(6),
                                    ProductQuantity        = reader.GetInt32(7),
                                    note           = reader.GetString(8),
                                    Updatetime     = reader.GetDateTime(9),
                                    StorageAddress = reader.IsDBNull(10) ? "" : reader.GetString(10),
                                    UserName       = reader.IsDBNull(11) ? "" : reader.GetString(11)
                                });
                            }
                        }
                        return(rlist);
                    }
                }
                catch
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// 查询仓库内货物名称
        /// </summary>
        /// <param name="MaterialName"></param>
        /// <param name="MaterialCode"></param>
        /// <param name="SupplierName"></param>
        /// <param name="SQLCommand"></param>
        /// <returns></returns>
        public List <string> selectPWarehouseTable_DetailedMaterialNameDal(string MaterialName, string MaterialCode, string SupplierName, string SQLCommand)
        {
            StringBuilder       sql        = new StringBuilder(SQLhelp.GetSQLCommand(SQLCommand));
            List <string>       rlist      = new List <string>();
            List <SqlParameter> listsqlpar = new List <SqlParameter>();
            List <string>       whereList  = new List <string>();

            if (MaterialName.Length > 0)
            {
                whereList.Add(" MaterialName=@MaterialName ");
                listsqlpar.Add(new SqlParameter("@MaterialName", SqlDbType.VarChar, 80)
                {
                    Value = MaterialName
                });
            }
            if (MaterialCode.Length > 0)
            {
                whereList.Add(" MaterialCode=@MaterialCode ");
                listsqlpar.Add(new SqlParameter("@MaterialCode", SqlDbType.VarChar, 80)
                {
                    Value = MaterialCode
                });
            }
            if (SupplierName.Length > 0)
            {
                whereList.Add(" SupplierName=@SupplierName ");
                listsqlpar.Add(new SqlParameter("@SupplierName", SqlDbType.VarChar, 80)
                {
                    Value = SupplierName
                });
            }

            if (whereList.Count > 0)
            {
                sql.Append(" where ");//只要有查询条件,就拼接一个where
                //然后把后面的查询条件连起来
                sql.Append(string.Join(" and ", whereList));
            }

            if (listsqlpar.Count > 0)
            {
                SqlParameter[] pms = listsqlpar.ToArray();
                try
                {
                    using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text, pms))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                rlist.Add(reader.IsDBNull(0) ? "" : reader.GetString(0));
                            }
                        }
                        return(rlist);
                    }
                }
                catch
                {
                    throw;
                }
            }
            else
            {
                try
                {
                    using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                rlist.Add(reader.IsDBNull(0) ? "" : reader.GetString(0));
                            }
                        }
                        return(rlist);
                    }
                }
                catch
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// 查询员工信息
        /// </summary>
        /// <param name="list"></param>
        /// <param name="SQLCommand"></param>
        /// <returns></returns>
        public List <PStaffResume> selectPStaffResumeDal(List <PStaffResume> list, string SQLCommand)
        {
            List <PStaffResume> returnList = new List <PStaffResume>();

            StringBuilder       sql        = new StringBuilder(SQLhelp.GetSQLCommand(SQLCommand));
            List <SqlParameter> listsqlpar = new List <SqlParameter>();
            List <string>       whereList  = new List <string>();

            if (list.Count > 0)
            {
                if (list[0].Name.Length > 0)
                {
                    whereList.Add(" Name=@name ");
                    listsqlpar.Add(new SqlParameter("@name", SqlDbType.VarChar, 20)
                    {
                        Value = list[0].Name
                    });
                }
                if (list[0].WorkNumber.Length > 0)
                {
                    whereList.Add(" WorkNumber=@worknumber ");
                    listsqlpar.Add(new SqlParameter("@worknumber", SqlDbType.VarChar, 50)
                    {
                        Value = list[0].WorkNumber
                    });
                }
                if (list[0].Gender.Length > 0)
                {
                    whereList.Add(" Gender=@gender ");
                    listsqlpar.Add(new SqlParameter("@gender", SqlDbType.VarChar, 4)
                    {
                        Value = list[0].Gender
                    });
                }
                if (list[0].Age.Length > 0)
                {
                    whereList.Add(" Age=@age");
                    listsqlpar.Add(new SqlParameter("@age", SqlDbType.VarChar, 6)
                    {
                        Value = list[0].Age
                    });
                }
                if (list[0].WorkTypes.Length > 0)
                {
                    whereList.Add(" WorkTypes=@worktypes ");
                    listsqlpar.Add(new SqlParameter("@worktypes", SqlDbType.VarChar, 80)
                    {
                        Value = list[0].WorkTypes
                    });
                }
                if (list[0].Levels.Length > 0)
                {
                    whereList.Add(" Levels=@levels ");
                    listsqlpar.Add(new SqlParameter("@levels", SqlDbType.VarChar, 50)
                    {
                        Value = list[0].Levels
                    });
                }
                if (list[0].FactoryTime.Year.ToString() != "1")
                {
                    whereList.Add(" FactoryTime=@factorytime ");
                    listsqlpar.Add(new SqlParameter("@factorytime", SqlDbType.DateTime)
                    {
                        Value = list[0].FactoryTime
                    });
                }
                if (list[0].CompanyName.Length > 0)
                {
                    whereList.Add(" CompanyName=@companyname ");
                    listsqlpar.Add(new SqlParameter("@companyname", SqlDbType.VarChar, 120)
                    {
                        Value = list[0].CompanyName
                    });
                }
            }
            if (whereList.Count > 0)
            {
                sql.Append(" where ");//只要有查询条件,就拼接一个where
                //然后把后面的查询条件连起来
                sql.Append(string.Join(" and ", whereList));
            }
            if (listsqlpar.Count > 0)
            {
                SqlParameter[] pms = listsqlpar.ToArray();
                try
                {
                    using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text, pms))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                returnList.Add(new PStaffResume()
                                {
                                    Name        = reader.IsDBNull(0) ? "" : reader.GetString(0),
                                    WorkNumber  = reader.IsDBNull(1) ? "" : reader.GetString(1),
                                    Gender      = reader.IsDBNull(2) ? "" : reader.GetString(2),
                                    Age         = reader.IsDBNull(3) ? "" : reader.GetString(3),
                                    WorkTypes   = reader.IsDBNull(4) ? "" : reader.GetString(4),
                                    Levels      = reader.IsDBNull(5) ? "" : reader.GetString(5),
                                    FactoryTime = reader.GetDateTime(6),
                                    CompanyName = reader.GetString(7)
                                });
                            }
                        }
                        return(returnList);
                    }
                }
                catch
                {
                    throw;
                }
            }
            else
            {
                try
                {
                    using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                returnList.Add(new PStaffResume()
                                {
                                    Name        = reader.IsDBNull(0) ? "" : reader.GetString(0),
                                    WorkNumber  = reader.IsDBNull(1) ? "" : reader.GetString(1),
                                    Gender      = reader.IsDBNull(2) ? "" : reader.GetString(2),
                                    Age         = reader.IsDBNull(3) ? "" : reader.GetString(3),
                                    WorkTypes   = reader.IsDBNull(4) ? "" : reader.GetString(4),
                                    Levels      = reader.IsDBNull(5) ? "" : reader.GetString(5),
                                    FactoryTime = reader.GetDateTime(6),
                                    CompanyName = reader.GetString(7)
                                });
                            }
                        }
                        return(returnList);
                    }
                }
                catch
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// 质检汇总查询
        /// </summary>
        /// <param name="list"></param>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <param name="SQLCommand"></param>
        /// <returns></returns>
        public List <selectPurchaseReceiptCheckQualifiedModel> selectPurchaseReceiptCheckQualifiedDal(List <selectPurchaseReceiptCheckQualifiedModel> list, DateTime beginTime, DateTime endTime, string SQLCommand)
        {
            StringBuilder       sql        = new StringBuilder(SQLhelp.GetSQLCommand(SQLCommand));
            List <SqlParameter> listsqlpar = new List <SqlParameter>();
            List <string>       whereList  = new List <string>();
            List <selectPurchaseReceiptCheckQualifiedModel> rlist = new List <selectPurchaseReceiptCheckQualifiedModel>();

            if (list.Count > 0)
            {
                if (list[0].PurchaseNo.Length > 0)
                {
                    whereList.Add(" PurchaseNo=@PurchaseNo ");
                    listsqlpar.Add(new SqlParameter("@PurchaseNo", SqlDbType.VarChar, 80)
                    {
                        Value = list[0].PurchaseNo
                    });
                }

                if (list[0].MaterialCode.Length > 0)
                {
                    whereList.Add(" MaterialCode=@MaterialCode ");
                    listsqlpar.Add(new SqlParameter("@MaterialCode", SqlDbType.VarChar, 80)
                    {
                        Value = list[0].MaterialCode
                    });
                }
                if (list[0].MaterialName.Length > 0)
                {
                    whereList.Add(" MaterialName=@MaterialName ");
                    listsqlpar.Add(new SqlParameter("@MaterialName", SqlDbType.VarChar, 80)
                    {
                        Value = list[0].MaterialName
                    });
                }
                if (list[0].SupplierName.Length > 0)
                {
                    whereList.Add(" SupplierName=@SupplierName ");
                    listsqlpar.Add(new SqlParameter("@SupplierName", SqlDbType.VarChar, 80)
                    {
                        Value = list[0].SupplierName
                    });
                }
                if (list[0].QualifiedRate.Length > 0)
                {
                    whereList.Add(" SupplierName=@SupplierName ");
                    listsqlpar.Add(new SqlParameter("@SupplierName", SqlDbType.Float)
                    {
                        Value = Convert.ToDouble(list[0].SupplierName)
                    });
                }
            }

            if (beginTime.Year.ToString() != "1")
            {
                whereList.Add(" QualifiedTime2>=@time ");
                listsqlpar.Add(new SqlParameter("@time", SqlDbType.DateTime)
                {
                    Value = beginTime
                });
            }
            if (endTime.Year.ToString() != "1")
            {
                whereList.Add(" QualifiedTime2<=@time1 ");
                listsqlpar.Add(new SqlParameter("@time1", SqlDbType.DateTime)
                {
                    Value = endTime
                });
            }

            if (whereList.Count > 0)
            {
                sql.Append(" and ");
                //然后把后面的查询条件连起来
                sql.Append(string.Join(" and ", whereList));
                sql.Append(" order by QualifiedTime2 ");
            }

            if (listsqlpar.Count > 0)
            {
                SqlParameter[] pms = listsqlpar.ToArray();

                try
                {
                    using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text, pms))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                rlist.Add(new selectPurchaseReceiptCheckQualifiedModel()
                                {
                                    QualifiedTime2         = reader.GetDateTime(0),
                                    PurchaseNo             = reader.GetString(1),
                                    MaterialCode           = reader.GetString(2),
                                    MaterialName           = reader.GetString(3),
                                    SupplierName           = reader.GetString(4),
                                    ProductQuantity1       = reader.GetInt32(5),
                                    QualifiedRate          = reader.GetDouble(6).ToString() + "%",
                                    CheckQualifiedUserName = reader.GetString(7),
                                    WhetherQualified       = reader.GetBoolean(8) ? "合格" : "不合格",
                                    CheckSpecialMining     = reader.GetString(9) == "特采" ? "特采" : reader.GetBoolean(8)?"非特采":"退货",
                                    note                      = reader.GetString(10),
                                    CheckNumber               = reader.IsDBNull(12)?0:reader.GetInt32(12),
                                    classType                 = reader.IsDBNull(13)?"":reader.GetString(13),
                                    ProblemDescription        = reader.IsDBNull(14)?"":reader.GetString(14),
                                    AttributionResponsibility = reader.IsDBNull(15)?"":reader.GetString(15),
                                    Presentation8D            = reader.IsDBNull(16)?"":reader.GetString(16)
                                });
                            }
                        }
                        return(rlist);
                    }
                }
                catch
                {
                    throw;
                }
            }
            else
            {
                try
                {
                    using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                rlist.Add(new selectPurchaseReceiptCheckQualifiedModel()
                                {
                                    QualifiedTime2         = reader.GetDateTime(0),
                                    PurchaseNo             = reader.GetString(1),
                                    MaterialCode           = reader.GetString(2),
                                    MaterialName           = reader.GetString(3),
                                    SupplierName           = reader.GetString(4),
                                    ProductQuantity1       = reader.GetInt32(5),
                                    QualifiedRate          = reader.GetDouble(6).ToString() + "%",
                                    CheckQualifiedUserName = reader.GetString(7),
                                    WhetherQualified       = reader.GetBoolean(8)?"合格":"不合格",
                                    CheckSpecialMining     = reader.GetString(9) == "特采" ? "特采" : reader.GetBoolean(8) ? "非特采" : "退货",
                                    note                      = reader.GetString(10),
                                    CheckNumber               = reader.IsDBNull(12) ? 0 : reader.GetInt32(12),
                                    classType                 = reader.IsDBNull(13) ? "" : reader.GetString(13),
                                    ProblemDescription        = reader.IsDBNull(14) ? "" : reader.GetString(14),
                                    AttributionResponsibility = reader.IsDBNull(15) ? "" : reader.GetString(15),
                                    Presentation8D            = reader.IsDBNull(16) ? "" : reader.GetString(16)
                                });
                            }
                        }
                        return(rlist);
                    }
                }
                catch
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// 多条件查询PAbnormalInput表
        /// </summary>
        /// <param name="list"></param>
        /// <param name="SQLCommand"></param>
        /// <returns></returns>
        public List <PAbnormalInput> selectPAbnormalInputDal(List <PAbnormalInput> list, DateTime beginTime, DateTime endTime, string SQLCommand)
        {
            List <PAbnormalInput> rlist = new List <PAbnormalInput>();

            StringBuilder       sql        = new StringBuilder(SQLhelp.GetSQLCommand(SQLCommand));
            List <SqlParameter> listsqlpar = new List <SqlParameter>();
            List <string>       whereList  = new List <string>();

            if (list.Count > 0)
            {
                if (list[0].ZhiDan.Length > 0)
                {
                    whereList.Add(" ZhiDan=@zhidan ");
                    listsqlpar.Add(new SqlParameter("@zhidan", SqlDbType.VarChar, 100)
                    {
                        Value = list[0].ZhiDan
                    });
                }
                if (list[0].SchoolPersonnel.Length > 0)
                {
                    whereList.Add(" SchoolPersonnel=@school ");
                    listsqlpar.Add(new SqlParameter("@school", SqlDbType.VarChar, 20)
                    {
                        Value = list[0].SchoolPersonnel
                    });
                }
                if (list[0].CompanyName.Length > 0)
                {
                    whereList.Add(" CompanyName=@company ");
                    listsqlpar.Add(new SqlParameter("@company", SqlDbType.VarChar, 80)
                    {
                        Value = list[0].CompanyName
                    });
                }
                if (list[0].LineOf.Length > 0)
                {
                    whereList.Add(" LineOf=@lineof ");
                    listsqlpar.Add(new SqlParameter("@lineof", SqlDbType.VarChar, 80)
                    {
                        Value = list[0].LineOf
                    });
                }
                if (list[0].WorkStation.Length > 0)
                {
                    whereList.Add(" WorkStation=@workstation ");
                    listsqlpar.Add(new SqlParameter("@workstation", SqlDbType.VarChar, 50)
                    {
                        Value = list[0].WorkStation
                    });
                }
                if (list[0].ProblemDescription.Length > 0)
                {
                    whereList.Add(" ProblemDescription=@proble ");
                    listsqlpar.Add(new SqlParameter("@proble", SqlDbType.VarChar, 200)
                    {
                        Value = list[0].ProblemDescription
                    });
                }
                if (list[0].ExceptionTypes.Length > 0)
                {
                    whereList.Add(" ExceptionTypes=@exception ");
                    listsqlpar.Add(new SqlParameter("@exception", SqlDbType.VarChar, 80)
                    {
                        Value = list[0].ExceptionTypes
                    });
                }
                if (list[0].Node1.Length > 0)
                {
                    whereList.Add(" Node1=@node ");
                    listsqlpar.Add(new SqlParameter("@node", SqlDbType.VarChar, 200)
                    {
                        Value = list[0].Node1
                    });
                }

                if (list[0].ID > 0)
                {
                    whereList.Add(" ID=@id ");
                    listsqlpar.Add(new SqlParameter("@id", SqlDbType.Int)
                    {
                        Value = list[0].ID
                    });
                }
            }
            if (beginTime.Year.ToString() != "1")
            {
                whereList.Add(" UpdateTime>=@time ");
                listsqlpar.Add(new SqlParameter("@time", SqlDbType.DateTime)
                {
                    Value = beginTime
                });
            }
            if (endTime.Year.ToString() != "1")
            {
                whereList.Add(" UpdateTime<=@time1 ");
                listsqlpar.Add(new SqlParameter("@time1", SqlDbType.DateTime)
                {
                    Value = endTime
                });
            }
            if (whereList.Count > 0)
            {
                sql.Append(" where ");    //只要有查询条件,就拼接一个where
                //然后把后面的查询条件连起来
                sql.Append(string.Join(" and ", whereList));
                sql.Append(" order by UpdateTime ");
            }

            if (listsqlpar.Count > 0)
            {
                SqlParameter[] pms = listsqlpar.ToArray();

                try
                {
                    using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text, pms))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                rlist.Add(new PAbnormalInput()
                                {
                                    ID                 = reader.GetInt32(0),
                                    ZhiDan             = reader.GetString(1),
                                    SchoolPersonnel    = reader.GetString(2),
                                    CompanyName        = reader.GetString(3),
                                    LineOf             = reader.GetString(4),
                                    WorkStation        = reader.GetString(5),
                                    ProblemDescription = reader.GetString(6),
                                    ExceptionTypes     = reader.GetString(7),
                                    Node1              = reader.GetString(8)
                                });
                            }
                        }
                        return(rlist);
                    }
                }
                catch
                {
                    throw;
                }
            }
            else
            {
                try
                {
                    using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                rlist.Add(new PAbnormalInput()
                                {
                                    ZhiDan             = reader.GetString(0),
                                    SchoolPersonnel    = reader.GetString(1),
                                    CompanyName        = reader.GetString(2),
                                    LineOf             = reader.GetString(3),
                                    WorkStation        = reader.GetString(4),
                                    ProblemDescription = reader.GetString(5),
                                    ExceptionTypes     = reader.GetString(6),
                                    Node1 = reader.GetString(7)
                                });
                            }
                        }
                        return(rlist);
                    }
                }
                catch
                {
                    throw;
                }
            }
        }
        public List <PMCplan_table> selectPMCplan_tableDal(List <PMCplan_table> list, string SQLCommand)
        {
            List <PMCplan_table> retList = new List <PMCplan_table>();

            StringBuilder       sql        = new StringBuilder(SQLhelp.GetSQLCommand(SQLCommand));
            List <SqlParameter> listsqlpar = new List <SqlParameter>();
            List <string>       whereList  = new List <string>();

            if (list.Count > 0)
            {
                if (list[0].CustomerName.Length > 0)
                {
                    whereList.Add(" CustomerName=@customername ");
                    listsqlpar.Add(new SqlParameter("@customername", SqlDbType.VarChar, 80)
                    {
                        Value = list[0].CustomerName
                    });
                }
                if (list[0].CorporateName.Length > 0)
                {
                    whereList.Add(" CorporateName=@corporatename ");
                    listsqlpar.Add(new SqlParameter("@corporatename", SqlDbType.VarChar, 50)
                    {
                        Value = list[0].CorporateName
                    });
                }
                if (list[0].ZhiDan.Length > 0)
                {
                    whereList.Add(" ZhiDan=@zhidan ");
                    listsqlpar.Add(new SqlParameter("@zhidan", SqlDbType.VarChar, 100)
                    {
                        Value = list[0].ZhiDan
                    });
                }
                if (list[0].TotalOrder > 0)
                {
                    whereList.Add(" TotalOrder=@totalorder ");
                    listsqlpar.Add(new SqlParameter("@totalorder", SqlDbType.Int)
                    {
                        Value = list[0].TotalOrder
                    });
                }
                if (list[0].ShippingDate.Year.ToString() != "1")
                {
                    whereList.Add(" ShippingDate=@shippingdate ");
                    listsqlpar.Add(new SqlParameter("@shippingdate", SqlDbType.DateTime)
                    {
                        Value = list[0].ShippingDate
                    });
                }
                if (list[0].UpdateTime.Year.ToString() != "1")
                {
                    whereList.Add(" UpdateTime=@updatetime ");
                    listsqlpar.Add(new SqlParameter("@updatetime", SqlDbType.DateTime)
                    {
                        Value = list[0].UpdateTime
                    });
                }
            }
            if (whereList.Count > 0)
            {
                sql.Append(" where ");//只要有查询条件,就拼接一个where
                //然后把后面的查询条件连起来
                sql.Append(string.Join(" and ", whereList));
            }
            if (listsqlpar.Count > 0)
            {
                SqlParameter[] pms = listsqlpar.ToArray();

                try
                {
                    using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text, pms))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                retList.Add(new PMCplan_table()
                                {
                                    CorporateName    = reader.GetString(0),
                                    ZhiDan           = reader.GetString(1),
                                    TotalOrder       = reader.GetInt32(2),
                                    RequiredTimeGUID = reader.GetString(3),
                                    CustomerName     = reader.GetString(4),
                                    ShippingDate     = reader.GetDateTime(5),
                                    Remarks          = reader.IsDBNull(6)?"":reader.GetString(6),
                                    CreationTime     = reader.GetDateTime(7),
                                    UpdateTime       = reader.GetDateTime(8),
                                });
                            }
                        }
                        return(retList);
                    }
                }
                catch
                {
                    throw;
                }
            }
            else
            {
                try
                {
                    using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                retList.Add(new PMCplan_table()
                                {
                                    CorporateName    = reader.GetString(0),
                                    ZhiDan           = reader.GetString(1),
                                    TotalOrder       = reader.GetInt32(2),
                                    RequiredTimeGUID = reader.GetString(3),
                                    CustomerName     = reader.GetString(4),
                                    ShippingDate     = reader.GetDateTime(5),
                                    Remarks          = reader.IsDBNull(6) ? "" : reader.GetString(6),
                                    CreationTime     = reader.GetDateTime(7),
                                    UpdateTime       = reader.GetDateTime(8),
                                });
                            }
                        }
                        return(retList);
                    }
                }
                catch
                {
                    throw;
                }
            }
        }