Example #1
0
        public static List <MES_SNOriginalDTO> ExecuteNonQuery(string spName, SqlParameter[] parameterValues)
        {
            string connectionString             = ConfigurationManager.ConnectionStrings["SyncGoldenLineCT"].ConnectionString;
            List <MES_SNOriginalDTO> resultList = new List <MES_SNOriginalDTO>();

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(spName, conn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                foreach (SqlParameter p in parameterValues)
                {
                    if ((p.Direction == ParameterDirection.InputOutput) && (p.Value == null))
                    {
                        p.Value = DBNull.Value;
                    }

                    cmd.Parameters.Add(p);
                }

                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    MES_SNOriginalDTO model = new MES_SNOriginalDTO();
                    model.SeriesNumber  = dr["SeriesNumber"].ToString();
                    model.CustomerName  = dr["CustomerName"].ToString();
                    model.StationName   = dr["StationName"].ToString();
                    model.Color         = dr["Color"].ToString();
                    model.MES_ProcessID = int.Parse(dr["MES_ProcessID"].ToString());
                    resultList.Add(model);
                }
            }
            return(resultList);
        }
Example #2
0
        public static List <MES_SNOriginalDTO> ExecuteReader(string cmdText)
        {
            var connectionString = "Data Source=CNCTUG0PISMES01;Initial Catalog=CTU_PDMS_MES;User ID=pdms_mes;Password=PDMS2018@Dbmes;Persist Security Info=true;Connection Timeout=300";

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                var dr = ExecuteReader(conn, null, CommandType.Text, cmdText, null);
                List <MES_SNOriginalDTO> resultList = new List <MES_SNOriginalDTO>();
                while (dr.Read())
                {
                    MES_SNOriginalDTO model = new MES_SNOriginalDTO();
                    model.MES_SNOriginal_UID = int.Parse(dr["MES_SNOriginal_UID"].ToString());
                    model.SeriesNumber       = dr["SeriesNumber"].ToString();
                    model.CustomerName       = dr["CustomerName"].ToString();
                    model.StationName        = dr["StationName"].ToString();
                    model.Color     = dr["Color"].ToString();
                    model.Starttime = Convert.ToDateTime(dr["Starttime"].ToString());
                    resultList.Add(model);
                }
                return(resultList);
            }
        }