Beispiel #1
0
        /// <summary>
        /// Selects all records from the Qds_Bag table.
        /// </summary>
        public virtual List <Qds_Bag> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Qds_Bag_SelectAll"))
            {
                List <Qds_Bag> qds_BagList = new List <Qds_Bag>();
                while (dataReader.Read())
                {
                    Qds_Bag qds_Bag = MakeQds_Bag(dataReader);
                    qds_BagList.Add(qds_Bag);
                }

                return(qds_BagList);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new instance of the Qds_Bag class and populates it with data from the specified SqlDataReader.
        /// </summary>
        protected virtual Qds_Bag MakeQds_Bag(SqlDataReader dataReader)
        {
            Qds_Bag qds_Bag = new Qds_Bag();

            qds_Bag.BagID  = SqlClientUtility.GetInt32(dataReader, "BagID", 0);
            qds_Bag.DropID = SqlClientUtility.GetInt32(dataReader, "DropID", 0);
            qds_Bag.BagEstimateUnderLitre = SqlClientUtility.GetInt32(dataReader, "BagEstimateUnderLitre", 0);
            qds_Bag.BagEstimateOverLitre  = SqlClientUtility.GetInt32(dataReader, "BagEstimateOverLitre", 0);
            qds_Bag.DateEntered           = SqlClientUtility.GetDateTime(dataReader, "DateEntered", DateTime.Now);
            qds_Bag.DateAccepted          = SqlClientUtility.GetDateTime(dataReader, "DateAccepted", DateTime.Now);
            qds_Bag.DateCounted           = SqlClientUtility.GetDateTime(dataReader, "DateCounted", DateTime.Now);
            qds_Bag.DatePaid    = SqlClientUtility.GetDateTime(dataReader, "DatePaid", DateTime.Now);
            qds_Bag.DepotID     = SqlClientUtility.GetString(dataReader, "DepotID", String.Empty);
            qds_Bag.DatePrinted = SqlClientUtility.GetDateTime(dataReader, "DatePrinted", DateTime.Now);
            //qds_Bag.IsNew = SqlClientUtility.GetBoolean(dataReader, "IsNew", false);

            return(qds_Bag);
        }
Beispiel #3
0
        /// <summary>
        /// Selects all records from the Qds_Bag table by a foreign key.
        /// </summary>
        public virtual List <Qds_Bag> _SelectAllByDropID(int dropID)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@DropID", dropID)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Qds_Bag_SelectAllByDropID", parameters))
            {
                List <Qds_Bag> qds_BagList = new List <Qds_Bag>();
                while (dataReader.Read())
                {
                    Qds_Bag qds_Bag = MakeQds_Bag(dataReader);
                    qds_BagList.Add(qds_Bag);
                }

                return(qds_BagList);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Saves a record to the Qds_Bag table.
        /// </summary>
        public virtual void Insert(Qds_Bag qds_Bag)
        {
            ValidationUtility.ValidateArgument("qds_Bag", qds_Bag);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@DropID", qds_Bag.DropID),
                new SqlParameter("@BagEstimateUnderLitre", qds_Bag.BagEstimateUnderLitre),
                new SqlParameter("@BagEstimateOverLitre", qds_Bag.BagEstimateOverLitre),
                new SqlParameter("@DateEntered", qds_Bag.DateEntered),
                new SqlParameter("@DateAccepted", qds_Bag.DateAccepted),
                new SqlParameter("@DateCounted", qds_Bag.DateCounted),
                new SqlParameter("@DatePaid", qds_Bag.DatePaid),
                new SqlParameter("@DepotID", qds_Bag.DepotID),
                new SqlParameter("@DatePrinted", qds_Bag.DatePrinted)
                //,     new SqlParameter("@IsNew", qds_Bag.IsNew)
            };

            qds_Bag.BagID = (int)SqlClientUtility.ExecuteScalar(connectionStringName, CommandType.StoredProcedure, "Qds_Bag_Insert", parameters);
        }
Beispiel #5
0
        public static void CompleteOrder(
            int orderID
            , string orderType
            , ref List <int> listOfBagsCounted
            , ref List <int> listOfBagsNotCounted
            )
        {
            if (listOfBagsNotCounted.Count < 1)
            {
                return;
            }

            //set the status of the rest of the bags to MISSING
            Qds_Drop_Sp qds_Drop_Sp = new Qds_Drop_Sp(Properties.Settings.Default.WsirDbConnectionString);

            List <Qds_Drop> dl         = qds_Drop_Sp._SelectAllByOrderID_OrderType(orderID, orderType);
            Qds_Drop        qds_Drop   = dl[0];
            Qds_Bag_Sp      qds_Bag_Sp = new Qds_Bag_Sp(Properties.Settings.Default.WsirDbConnectionString);

            List <Qds_Bag> bl = qds_Bag_Sp._SelectAllByDropID(qds_Drop.DropID);
            //create new drop for missing bags
            Qds_Drop nd = new Qds_Drop();

            //nd.DropID = 0;
            nd.CustomerID      = qds_Drop.CustomerID;
            nd.NumberOfBags    = listOfBagsNotCounted.Count; // od.NumberOfBags;
            nd.PaymentMethodID = qds_Drop.PaymentMethodID;
            nd.DepotID         = qds_Drop.DepotID;
            nd.OrderID         = 0;
            nd.OrderType       = "M"; //missing
            qds_Drop_Sp.Insert(nd);

            //move missing bags to new drop
            //foreach(ComboBoxItem i in comboBoxBagId.Items)

            foreach (int id in listOfBagsNotCounted)
            {
                //move missing bag
                Qds_Bag mb = qds_Bag_Sp.Select(id); //bagIdFromComboBox);
                mb.DropID = nd.DropID;
                qds_Bag_Sp.Update(mb);
            }

            //change numer of bags of the original drop
            qds_Drop.NumberOfBags -= listOfBagsNotCounted.Count();
            qds_Drop_Sp.Update(qds_Drop);

            //close order
            Sol_Order_Sp sol_Order_Sp = new Sol_Order_Sp(Properties.Settings.Default.WsirDbConnectionString);
            Sol_Order    sol_Order    = sol_Order_Sp.Select(orderID, orderType);

            sol_Order_Sp.UpdateDates(sol_Order.OrderID, sol_Order.OrderType, "", "DateClosed");

            //is drop ready for payment?
            if (qds_Drop_Sp.IsReady(qds_Drop.DropID))
            {
                string status = String.Empty;
                if (qds_Drop.PaymentMethodID == 1)
                {
                    status = "A";
                }
                else
                {
                    status = "O";
                }
                sol_Order_Sp.UpdateStatus(sol_Order.OrderID, sol_Order.OrderType, status);
            }

            //update customerID
            //sol_Order_Sp._UpdateCustomerID(sol_Order.OrderID, sol_Order.OrderType, qds_Drop.CustomerID);
        }