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);
        }
Esempio n. 2
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.");
            }
        }