コード例 #1
0
        // GET: api/FPLotNum/5
        public HttpResponseMessage Get(string Company, string PartNum, string LotNum)
        {
            try
            {
                string        sErrMsg     = "";
                BusinessLayer BL          = new BusinessLayer();
                LotDetails    _lotDetails = BL.CheckFPLotNum(Company, PartNum, LotNum, out sErrMsg);

                if (sErrMsg != "")
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, sErrMsg));
                }
                if (_lotDetails.Company != null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, _lotDetails));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound,
                                                       $"LotNum {LotNum} was not belong to the selected product!"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message.ToString()));
            }
        }
コード例 #2
0
        /// <summary>
        /// DropDownForClient
        /// Calls [usp_dropdown_Lot_for_Client]
        /// </summary>
        public override List <LotDetails> DropDownForClient(System.Int32?clientId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_dropdown_Lot_for_Client", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId;
                cn.Open();
                DbDataReader      reader = ExecuteReader(cmd);
                List <LotDetails> lst    = new List <LotDetails>();
                while (reader.Read())
                {
                    LotDetails obj = new LotDetails();
                    obj.LotId   = GetReaderValue_Int32(reader, "LotId", 0);
                    obj.LotName = GetReaderValue_String(reader, "LotName", "");
                    lst.Add(obj);
                    obj = null;
                }
                return(lst);
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Lots", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
コード例 #3
0
        /// <summary>
        /// Get
        /// Calls [usp_select_Lot]
        /// </summary>
        public override LotDetails Get(System.Int32?lotId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_select_Lot", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@LotId", SqlDbType.Int).Value = lotId;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    //return GetLotFromReader(reader);
                    LotDetails obj = new LotDetails();
                    obj.LotId               = GetReaderValue_Int32(reader, "LotId", 0);
                    obj.ClientNo            = GetReaderValue_Int32(reader, "ClientNo", 0);
                    obj.LotName             = GetReaderValue_String(reader, "LotName", "");
                    obj.Cost                = GetReaderValue_NullableDouble(reader, "Cost", null);
                    obj.CurrencyNo          = GetReaderValue_NullableInt32(reader, "CurrencyNo", null);
                    obj.OnHold              = GetReaderValue_Boolean(reader, "OnHold", false);
                    obj.Consignment         = GetReaderValue_Boolean(reader, "Consignment", false);
                    obj.Notes               = GetReaderValue_String(reader, "Notes", "");
                    obj.LotCode             = GetReaderValue_String(reader, "LotCode", "");
                    obj.Inactive            = GetReaderValue_Boolean(reader, "Inactive", false);
                    obj.UpdatedBy           = GetReaderValue_NullableInt32(reader, "UpdatedBy", null);
                    obj.DLUP                = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue);
                    obj.CurrencyCode        = GetReaderValue_String(reader, "CurrencyCode", "");
                    obj.CurrencyDescription = GetReaderValue_String(reader, "CurrencyDescription", "");
                    obj.LockForCustomerNo   = GetReaderValue_NullableInt32(reader, "LockForCustomerNo", null);
                    obj.LockForCustomer     = GetReaderValue_String(reader, "LockForCustomer", "");
                    return(obj);
                }
                else
                {
                    return(null);
                }
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Lot", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
コード例 #4
0
        /// <summary>
        /// DataListNugget
        /// Calls [usp_datalistnugget_Lot]
        /// </summary>
        public override List <LotDetails> DataListNugget(System.Int32?clientId, System.Int32?orderBy, System.Int32?sortDir, System.Int32?pageIndex, System.Int32?pageSize, System.String lotCode, System.String lotName)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_datalistnugget_Lot", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 60;
                cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value     = clientId;
                cmd.Parameters.Add("@OrderBy", SqlDbType.Int).Value      = orderBy;
                cmd.Parameters.Add("@SortDir", SqlDbType.Int).Value      = sortDir;
                cmd.Parameters.Add("@PageIndex", SqlDbType.Int).Value    = pageIndex;
                cmd.Parameters.Add("@PageSize", SqlDbType.Int).Value     = pageSize;
                cmd.Parameters.Add("@LotCode", SqlDbType.NVarChar).Value = lotCode;
                cmd.Parameters.Add("@LotName", SqlDbType.NVarChar).Value = lotName;
                cn.Open();
                DbDataReader      reader = ExecuteReader(cmd);
                List <LotDetails> lst    = new List <LotDetails>();
                while (reader.Read())
                {
                    LotDetails obj = new LotDetails();
                    obj.LotId        = GetReaderValue_Int32(reader, "LotId", 0);
                    obj.LotName      = GetReaderValue_String(reader, "LotName", "");
                    obj.OnHold       = GetReaderValue_Boolean(reader, "OnHold", false);
                    obj.Consignment  = GetReaderValue_Boolean(reader, "Consignment", false);
                    obj.LotCode      = GetReaderValue_String(reader, "LotCode", "");
                    obj.CurrencyCode = GetReaderValue_String(reader, "CurrencyCode", "");
                    obj.StockCount   = GetReaderValue_NullableInt32(reader, "StockCount", null);
                    obj.RowCnt       = GetReaderValue_NullableInt32(reader, "RowCnt", null);
                    obj.Inactive     = GetReaderValue_Boolean(reader, "Inactive", false);
                    lst.Add(obj);
                    obj = null;
                }
                return(lst);
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Lots", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
コード例 #5
0
        private static Lot PopulateFromDBDetailsObject(LotDetails obj)
        {
            Lot objNew = new Lot();

            objNew.LotId               = obj.LotId;
            objNew.ClientNo            = obj.ClientNo;
            objNew.LotName             = obj.LotName;
            objNew.Cost                = obj.Cost;
            objNew.CurrencyNo          = obj.CurrencyNo;
            objNew.OnHold              = obj.OnHold;
            objNew.Consignment         = obj.Consignment;
            objNew.Notes               = obj.Notes;
            objNew.LotCode             = obj.LotCode;
            objNew.Inactive            = obj.Inactive;
            objNew.UpdatedBy           = obj.UpdatedBy;
            objNew.DLUP                = obj.DLUP;
            objNew.CurrencyCode        = obj.CurrencyCode;
            objNew.StockCount          = obj.StockCount;
            objNew.RowNum              = obj.RowNum;
            objNew.RowCnt              = obj.RowCnt;
            objNew.CurrencyDescription = obj.CurrencyDescription;
            return(objNew);
        }
コード例 #6
0
        /// <summary>
        /// GetForPage
        /// Calls [usp_select_Lot_for_Page]
        /// </summary>
        public override LotDetails GetForPage(System.Int32?lotId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_select_Lot_for_Page", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@LotId", SqlDbType.Int).Value = lotId;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    //return GetLotFromReader(reader);
                    LotDetails obj = new LotDetails();
                    obj.LotId    = GetReaderValue_Int32(reader, "LotId", 0);
                    obj.ClientNo = GetReaderValue_Int32(reader, "ClientNo", 0);
                    obj.LotName  = GetReaderValue_String(reader, "LotName", "");
                    obj.Inactive = GetReaderValue_Boolean(reader, "Inactive", false);
                    return(obj);
                }
                else
                {
                    return(null);
                }
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Lot", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }