Пример #1
0
        private void AddRowsToTable()
        {
            //Sol_SupplyInventory Sol_SupplyInventory = new Sol_SupplyInventory();
            Sol_SupplyInventory_Sp sol_SupplyInventory_Sp = new Sol_SupplyInventory_Sp(Properties.Settings.Default.WsirDbConnectionString);

            MembershipUser membershipUser = membershipUser = Membership.GetUser(Properties.Settings.Default.UsuarioNombre);

            if (membershipUser == null)
            {
                MessageBox.Show("User does not exits, cannot add shipping containers entry");
                return;
            }

            Guid userID = (Guid)membershipUser.ProviderUserKey;

            int quantity = 0;

            foreach (DataGridViewRow row in dataGridViewShippingContainers.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }

                Int32.TryParse(row.Cells[2].Value.ToString(), out quantity);

                if (quantity == 0)
                {
                    continue;
                }

                Sol_SupplyInventory sol_SupplyInventory = new Sol_SupplyInventory();
                ////SupplyInventoryTypes
                //"0", "Order"
                //"R", "Received Order"
                //"A", "Adjustment"
                //"S", "Shipped"
                sol_SupplyInventory.SupplyInventoryType = "S";
                sol_SupplyInventory.UserID          = userID;
                sol_SupplyInventory.Date            = Main.rc.FechaActual;
                sol_SupplyInventory.DateOrdered     = DateTime.Parse("1753-1-1 12:00:00");
                sol_SupplyInventory.ProductID       = (int)row.Cells[4].Value;
                sol_SupplyInventory.ContainerID     = (int)row.Cells[1].Value;
                sol_SupplyInventory.Quantity        = quantity;
                sol_SupplyInventory.ShipmentID      = shipmentId;
                sol_SupplyInventory.ReferenceNumber = String.Empty;

                sol_SupplyInventory_Sp.Insert(sol_SupplyInventory);
            }

            //dataGridViewShippingContainers.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
        }
Пример #2
0
        /// <summary>
        /// Selects all records from the Sol_SupplyInventory table.
        /// </summary>
        public virtual List <Sol_SupplyInventory> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Sol_SupplyInventory_SelectAll"))
            {
                List <Sol_SupplyInventory> sol_SupplyInventoryList = new List <Sol_SupplyInventory>();
                while (dataReader.Read())
                {
                    Sol_SupplyInventory sol_SupplyInventory = MakeSol_SupplyInventory(dataReader);
                    sol_SupplyInventoryList.Add(sol_SupplyInventory);
                }

                return(sol_SupplyInventoryList);
            }
        }
Пример #3
0
        /// <summary>
        /// Creates a new instance of the Sol_SupplyInventory class and populates it with data from the specified SqlDataReader.
        /// </summary>
        protected virtual Sol_SupplyInventory MakeSol_SupplyInventory(SqlDataReader dataReader)
        {
            Sol_SupplyInventory sol_SupplyInventory = new Sol_SupplyInventory();

            sol_SupplyInventory.SupplyInventoryID   = SqlClientUtility.GetInt32(dataReader, "SupplyInventoryID", 0);
            sol_SupplyInventory.SupplyInventoryType = SqlClientUtility.GetString(dataReader, "SupplyInventoryType", String.Empty);
            sol_SupplyInventory.UserID          = SqlClientUtility.GetGuid(dataReader, "UserID", Guid.Empty);
            sol_SupplyInventory.Date            = SqlClientUtility.GetDateTime(dataReader, "Date", new DateTime(0));
            sol_SupplyInventory.DateOrdered     = SqlClientUtility.GetDateTime(dataReader, "DateOrdered", new DateTime(0));
            sol_SupplyInventory.ProductID       = SqlClientUtility.GetInt32(dataReader, "ProductID", 0);
            sol_SupplyInventory.ContainerID     = SqlClientUtility.GetInt32(dataReader, "ContainerID", 0);
            sol_SupplyInventory.Quantity        = SqlClientUtility.GetInt32(dataReader, "Quantity", 0);
            sol_SupplyInventory.ShipmentID      = SqlClientUtility.GetInt32(dataReader, "ShipmentID", 0);
            sol_SupplyInventory.ReferenceNumber = SqlClientUtility.GetString(dataReader, "ReferenceNumber", String.Empty);

            return(sol_SupplyInventory);
        }
Пример #4
0
        /// <summary>
        /// Saves a record to the Sol_SupplyInventory table.
        /// </summary>
        public virtual void Insert(Sol_SupplyInventory sol_SupplyInventory)
        {
            ValidationUtility.ValidateArgument("sol_SupplyInventory", sol_SupplyInventory);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@SupplyInventoryType", sol_SupplyInventory.SupplyInventoryType),
                new SqlParameter("@UserID", sol_SupplyInventory.UserID),
                new SqlParameter("@Date", sol_SupplyInventory.Date),
                new SqlParameter("@DateOrdered", sol_SupplyInventory.DateOrdered),
                new SqlParameter("@ProductID", sol_SupplyInventory.ProductID),
                new SqlParameter("@ContainerID", sol_SupplyInventory.ContainerID),
                new SqlParameter("@Quantity", sol_SupplyInventory.Quantity),
                new SqlParameter("@ShipmentID", sol_SupplyInventory.ShipmentID),
                new SqlParameter("@ReferenceNumber", sol_SupplyInventory.ReferenceNumber)
            };

            sol_SupplyInventory.SupplyInventoryID = (int)SqlClientUtility.ExecuteScalar(connectionStringName, CommandType.StoredProcedure, "Sol_SupplyInventory_Insert", parameters);
        }
Пример #5
0
        /// <summary>
        /// Selects all records from the Sol_SupplyInventory table by a foreign key.
        /// </summary>
        public virtual List <Sol_SupplyInventory> _SelectAllByShipmentID(int shipmentID)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@ShipmentID", shipmentID)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Sol_SupplyInventory_SelectAllByShipmentID", parameters))
            {
                List <Sol_SupplyInventory> sol_SupplyInventoryList = new List <Sol_SupplyInventory>();
                while (dataReader.Read())
                {
                    Sol_SupplyInventory sol_SupplyInventory = MakeSol_SupplyInventory(dataReader);
                    sol_SupplyInventoryList.Add(sol_SupplyInventory);
                }

                return(sol_SupplyInventoryList);
            }
        }
Пример #6
0
        private void CreateAdjustemnt()
        {
            bool flagDone = false;

            //classes of tables
            sol_SupplyInventory = new Sol_SupplyInventory();
            if (sol_SupplyInventory_Sp == null)
            {
                sol_SupplyInventory_Sp = new Sol_SupplyInventory_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            //if (MessageBox.Show("Do you want to continue", "Closing Voucher", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != System.Windows.Forms.DialogResult.Yes)
            //    return;

            //int totalqty = 0;
            int nrows = listViewUnstagedProducts.Items.Count;

            sol_SupplyInventory.SupplyInventoryType = "A";      // O = Order, R = Received Order, A = Adjustment, S = Shipped

            string c;
            //computer name
            //c = Properties.Settings.Default.SettingsWsWorkStationName.Trim();
            //if (String.IsNullOrEmpty(c))
            //    c = Main.myHostName;
            //sol_SupplyInventory.ComputerName = c;  //

            MembershipUser membershipUser = membershipUser = Membership.GetUser(Properties.Settings.Default.UsuarioNombre);

            if (membershipUser == null)
            {
                MessageBox.Show("User does not exits, cannot create Adjustment!");
                return;
            }
            Guid userId = (Guid)membershipUser.ProviderUserKey;

            sol_SupplyInventory.UserID      = userId;
            sol_SupplyInventory.Date        = Main.rc.FechaActual; // ;// Properties.Settings.Default.FechaActual;
            sol_SupplyInventory.DateOrdered = DateTime.Parse("1753-1-1 12:00:00");
            sol_SupplyInventory_Sp.Insert(sol_SupplyInventory);

            for (int i = 0; i < nrows; i++)
            {
                //int quantity
                c = listViewUnstagedProducts.Items[i].SubItems[1].Text;
                c = c.Replace("(", "");
                c = c.Replace(")", "");
                c = c.Replace(",", "");

                int quantity = Convert.ToInt32(c);

                c = this.arrayListViewQuantity[i].ToString();

                int oldQuantity = (int)this.arrayListViewQuantity[i];
                if (oldQuantity == quantity)
                {
                    continue;
                }

                int adjustmenQuantity = quantity - oldQuantity;
                sol_SupplyInventory.Quantity = adjustmenQuantity;

                //totalqty = totalqty + (adjustmenQuantity);

                //int categoryID
                sol_SupplyInventory.ContainerID = (int)this.arrayListViewContainerId[i];


                //add row
                sol_SupplyInventory_Sp.Insert(sol_SupplyInventory);

                flagDone = true;
            }

            if (flagDone)
            {
                MessageBox.Show("Adjustment created.");
            }
        }