Пример #1
0
        /// <summary>
        /// usp_select_StockInfo
        /// </summary>
        /// <param name="stockInfoId"></param>
        /// <returns></returns>
        public override StockInfoDetails Get(System.Int32?stockInfoId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try
            {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_select_StockInfo", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@StockInfoDataId", SqlDbType.Int).Value = stockInfoId;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    StockInfoDetails obj = new StockInfoDetails();
                    obj.StockInfoId        = GetReaderValue_Int32(reader, "StockInfoDataId", 0);
                    obj.Part               = GetReaderValue_String(reader, "Part", "");
                    obj.AlternatePart      = GetReaderValue_String(reader, "AlternatePart", "");
                    obj.Notes              = GetReaderValue_String(reader, "Notes", "");
                    obj.ManufacturerCode   = GetReaderValue_String(reader, "ManufacturerCode", "");
                    obj.ManufacturerNo     = GetReaderValue_NullableInt32(reader, "ManufacturerNo", null);
                    obj.ManufacturerName   = GetReaderValue_String(reader, "ManufacturerName", "");
                    obj.ProductNo          = GetReaderValue_NullableInt32(reader, "ProductNo", null);
                    obj.DateCode           = GetReaderValue_String(reader, "DateCode", "");
                    obj.ClientNo           = GetReaderValue_Int32(reader, "ClientNo", 0);
                    obj.SupplierNo         = GetReaderValue_NullableInt32(reader, "SupplierNo", null);
                    obj.SupplierName       = GetReaderValue_String(reader, "SupplierName", "");
                    obj.SupplierPart       = GetReaderValue_String(reader, "SupplierPart", "");
                    obj.ProductDescription = GetReaderValue_String(reader, "ProductDescription", "");
                    return(obj);
                }
                else
                {
                    return(null);
                }
            }
            catch (SqlException sqlex)
            {
                //LogException(sqlex);
                throw new Exception("Failed to get stock info", sqlex);
            }
            finally
            {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
Пример #2
0
        /// <summary>
        /// Calls [usp_source_StockInfo] for localServer else call [usp_source_StockInfo_Without_ClientId]
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="partSearch"></param>
        /// <returns></returns>
        public override List <StockInfoDetails> Source(System.Int32?clientId, System.String partSearch, bool hasServerLocal)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try
            {
                if (!hasServerLocal)
                {
                    cn  = new SqlConnection(this.GTConnectionString);
                    cmd = new SqlCommand("usp_source_StockInfo_Without_ClientId", cn);
                }
                else
                {
                    cn  = new SqlConnection(this.ConnectionString);
                    cmd = new SqlCommand("usp_source_StockInfo", cn);
                }

                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value        = clientId;
                cmd.Parameters.Add("@PartSearch", SqlDbType.NVarChar).Value = partSearch;
                cn.Open();
                DbDataReader            reader = ExecuteReader(cmd);
                List <StockInfoDetails> lst    = new List <StockInfoDetails>();
                while (reader.Read())
                {
                    StockInfoDetails obj = new StockInfoDetails();
                    obj.StockInfoId       = GetReaderValue_Int32(reader, "StockInfoDataId", 0);
                    obj.Part              = GetReaderValue_String(reader, "Part", "");
                    obj.AlternatePart     = GetReaderValue_String(reader, "AlternatePart", "");
                    obj.Notes             = GetReaderValue_String(reader, "Notes", "");
                    obj.ManufacturerCode  = GetReaderValue_String(reader, "ManufacturerCode", "");
                    obj.ManufacturerNo    = GetReaderValue_NullableInt32(reader, "ManufacturerNo", null);
                    obj.ProductName       = GetReaderValue_String(reader, "ProductName", "");
                    obj.DateCode          = GetReaderValue_String(reader, "DateCode", "");
                    obj.ClientNo          = GetReaderValue_Int32(reader, "ClientNo", 0);
                    obj.SupplierNo        = GetReaderValue_NullableInt32(reader, "SupplierNo", null);
                    obj.SupplierName      = GetReaderValue_String(reader, "SupplierName", "");
                    obj.ClientName        = GetReaderValue_String(reader, "ClientName", "");
                    obj.SupplierPart      = GetReaderValue_String(reader, "SupplierPart", "");
                    obj.DLUP              = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue);
                    obj.SupplierRMAId     = GetReaderValue_Int32(reader, "SupplierRMAId", 0);
                    obj.SupplierRMANumber = GetReaderValue_Int32(reader, "SupplierRMANumber", 0);
                    obj.ClientCode        = GetReaderValue_String(reader, "ClientCode", "");
                    lst.Add(obj);
                    obj = null;
                }
                return(lst);
            }
            catch (SqlException sqlex)
            {
                //LogException(sqlex);
                throw new Exception("Failed to get stocks info", sqlex);
            }
            finally
            {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }