Beispiel #1
0
        /// <summary>
        /// Creates a new instance of the sol_Products class and populates it with data from the specified SqlDataReader.
        /// </summary>
        protected virtual Sol_Product MakeSol_Product(SqlDataReader dataReader)
        {
            Sol_Product sol_Product = new Sol_Product();

            sol_Product.ProductID           = SqlClientUtility.GetInt32(dataReader, "ProductID", 0);
            sol_Product.ProName             = SqlClientUtility.GetString(dataReader, "ProName", String.Empty);
            sol_Product.ProDescription      = SqlClientUtility.GetString(dataReader, "ProDescription", String.Empty);
            sol_Product.ProShortDescription = SqlClientUtility.GetString(dataReader, "ProShortDescription", String.Empty);
            sol_Product.ProImage            = SqlClientUtility.GetBytes(dataReader, "ProImage", new byte[0]);
            sol_Product.AgencyID            = SqlClientUtility.GetInt32(dataReader, "AgencyID", 0);
            sol_Product.MenuOrder           = SqlClientUtility.GetInt32(dataReader, "MenuOrder", 0);
            sol_Product.IsActive            = SqlClientUtility.GetBoolean(dataReader, "IsActive", false);
            sol_Product.Price                    = SqlClientUtility.GetDecimal(dataReader, "Price", Decimal.Zero);
            sol_Product.CategoryID               = SqlClientUtility.GetInt32(dataReader, "CategoryID", 0);
            sol_Product.RefundAmount             = SqlClientUtility.GetDecimal(dataReader, "RefundAmount", Decimal.Zero);
            sol_Product.HandlingCommissionAmount = SqlClientUtility.GetDecimal(dataReader, "HandlingCommissionAmount", Decimal.Zero);
            sol_Product.CommissionUnit           = SqlClientUtility.GetInt32(dataReader, "CommissionUnit", 0);
            sol_Product.VafAmount                = SqlClientUtility.GetDecimal(dataReader, "VafAmount", Decimal.Zero);
            sol_Product.FeeUnit                  = SqlClientUtility.GetInt32(dataReader, "FeeUnit", 0);
            sol_Product.ContainerID              = SqlClientUtility.GetInt32(dataReader, "ContainerID", 0);
            sol_Product.StandardDozenID          = SqlClientUtility.GetInt32(dataReader, "StandardDozenID", 0);
            sol_Product.UPC             = SqlClientUtility.GetString(dataReader, "UPC", String.Empty);
            sol_Product.ProductCode     = SqlClientUtility.GetString(dataReader, "ProductCode", String.Empty);
            sol_Product.TypeId          = SqlClientUtility.GetByte(dataReader, "TypeId", 0x00);
            sol_Product.Tax1Exempt      = SqlClientUtility.GetBoolean(dataReader, "Tax1Exempt", false);
            sol_Product.Tax2Exempt      = SqlClientUtility.GetBoolean(dataReader, "Tax2Exempt", false);
            sol_Product.MasterProductID = SqlClientUtility.GetInt32(dataReader, "MasterProductID", 0);
            sol_Product.Weight          = SqlClientUtility.GetDecimal(dataReader, "Weight", Decimal.Zero);
            sol_Product.Volume          = SqlClientUtility.GetDecimal(dataReader, "Volume", Decimal.Zero);
            sol_Product.TargetQuantity  = SqlClientUtility.GetInt32(dataReader, "TargetQuantity", 0);

            return(sol_Product);
        }
        private void AddRow2(string productCode, int containerID, int quantity, bool empty, bool quantityLocked)
        {
            //if (String.IsNullOrEmpty(productCode))
            //    return;

            //if (String.IsNullOrEmpty(categoryName))
            //    return;

            //if (quantity == 0)
            //    return;


            sol_Product = new Sol_Product();
            if (productCode == "Pallets")
            {
                sol_Product.ProductID = -1;
                sol_Product.ProName   = productCode;
            }
            else if (productCode == "EmptyBags")
            {
                sol_Product.ProductID = 0;
                sol_Product.ProName   = productCode;
            }
            //if (String.IsNullOrEmpty(productCode))
            //{
            //if(empty)
            //    sol_Product.ProName = "Empty";   //Undefined";
            //else
            //    sol_Product.ProName = "";   //Undefined";
            //}
            else
            {
                sol_Product = sol_Product_Sp.SelectProductCode(productCode);
                if (sol_Product == null)
                {
                    sol_Product         = new Sol_Product();
                    sol_Product.ProName = "Undefined";
                }
            }

            this.dataGridViewShippingContainers.Rows.Add();
            int colIndex = 0;
            int rowIndex = this.dataGridViewShippingContainers.Rows.Count - 1;

            this.dataGridViewShippingContainers.Rows[rowIndex].Cells[colIndex].Value = sol_Product.ProName;
            colIndex++;
            this.dataGridViewShippingContainers.Rows[rowIndex].Cells[colIndex].Value = containerID;
            colIndex++;
            this.dataGridViewShippingContainers.Rows[rowIndex].Cells[colIndex].Value    = quantity;
            this.dataGridViewShippingContainers.Rows[rowIndex].Cells[colIndex].ReadOnly = quantityLocked;
            colIndex++;
            this.dataGridViewShippingContainers.Rows[rowIndex].Cells[colIndex].Value = empty;
            colIndex++;
            this.dataGridViewShippingContainers.Rows[rowIndex].Cells[colIndex].Value = sol_Product.ProductID;
        }
Beispiel #3
0
        /// <summary>
        /// Selects all records from the sol_Products table.
        /// </summary>
        public virtual List <Sol_Product> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "sol_Products_SelectAll"))
            {
                List <Sol_Product> sol_ProductList = new List <Sol_Product>();
                while (dataReader.Read())
                {
                    Sol_Product sol_Product = MakeSol_Product(dataReader);
                    sol_ProductList.Add(sol_Product);
                }

                return(sol_ProductList);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Selects all records from the sol_Products table by a foreign key.
        /// </summary>
        public virtual List <Sol_Product> _SelectAllByStandardDozenID(int standardDozenID)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@StandardDozenID", standardDozenID)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "sol_Products_SelectAllByStandardDozenID", parameters))
            {
                List <Sol_Product> sol_ProductList = new List <Sol_Product>();
                while (dataReader.Read())
                {
                    Sol_Product sol_Product = MakeSol_Product(dataReader);
                    sol_ProductList.Add(sol_Product);
                }

                return(sol_ProductList);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Updates a record in the sol_Products table.
        /// </summary>
        public virtual void Update(Sol_Product sol_Product)
        {
            ValidationUtility.ValidateArgument("sol_Product", sol_Product);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@ProductID", sol_Product.ProductID),
                new SqlParameter("@ProName", sol_Product.ProName),
                new SqlParameter("@ProDescription", sol_Product.ProDescription),
                new SqlParameter("@ProShortDescription", sol_Product.ProShortDescription),
                new SqlParameter("@ProImage", sol_Product.ProImage),
                new SqlParameter("@AgencyID", sol_Product.AgencyID),
                new SqlParameter("@MenuOrder", sol_Product.MenuOrder),
                new SqlParameter("@IsActive", sol_Product.IsActive),
                new SqlParameter("@Price", sol_Product.Price),
                new SqlParameter("@CategoryID", sol_Product.CategoryID),
                new SqlParameter("@RefundAmount", sol_Product.RefundAmount),
                new SqlParameter("@HandlingCommissionAmount", sol_Product.HandlingCommissionAmount),
                new SqlParameter("@CommissionUnit", sol_Product.CommissionUnit),
                new SqlParameter("@VafAmount", sol_Product.VafAmount),
                new SqlParameter("@FeeUnit", sol_Product.FeeUnit),
                new SqlParameter("@ContainerID", sol_Product.ContainerID),
                new SqlParameter("@StandardDozenID", sol_Product.StandardDozenID),
                new SqlParameter("@UPC", sol_Product.UPC),
                new SqlParameter("@ProductCode", sol_Product.ProductCode),
                new SqlParameter("@TypeId", sol_Product.TypeId),
                new SqlParameter("@Tax1Exempt", sol_Product.Tax1Exempt),
                new SqlParameter("@Tax2Exempt", sol_Product.Tax2Exempt),
                new SqlParameter("@MasterProductID", sol_Product.MasterProductID),
                new SqlParameter("@Weight", sol_Product.Weight),
                new SqlParameter("@Volume", sol_Product.Volume),
                new SqlParameter("@TargetQuantity", sol_Product.TargetQuantity)
            };

            SqlClientUtility.ExecuteNonQuery(connectionStringName, CommandType.StoredProcedure, "sol_Products_Update", parameters);
        }
Beispiel #6
0
        private bool CreateAdjustment(AdjustmentActionTypes adjActionTypes, int stageId, int productId)
        {
            sol_Stage = sol_Stage_Sp.Select(stageId);
            if (sol_Stage == null)
            {
                MessageBox.Show(String.Format("StageID not found ({0}) ", stageId));
                return(false);
            }

            DateTime dt = sol_Stage.Date;

            if (checkBoxDate.Checked)
            {
                dt = Main.rc.FechaActual;
            }

            Sol_Stage sol_StageAdjustment = new Sol_Stage();

            sol_StageAdjustment.ShipmentID = sol_ShipmentAdjustment.ShipmentID;
            sol_StageAdjustment.UserID     = sol_Stage.UserID;
            sol_StageAdjustment.UserName   = sol_Stage.UserName;
            //sol_StageAdjustment.Date = dt;
            sol_StageAdjustment.Date = Main.rc.FechaActual; // ; // Properties.Settings.Default.FechaActual;;

            sol_StageAdjustment.TagNumber            = sol_Stage.TagNumber + "A";
            sol_StageAdjustment.ContainerID          = sol_Stage.ContainerID;
            sol_StageAdjustment.ContainerDescription = sol_Stage.ContainerDescription;
            sol_StageAdjustment.ProductID            = sol_Stage.ProductID;
            sol_StageAdjustment.ProductName          = sol_Stage.ProductName;
            sol_StageAdjustment.Dozen    = 0; //not used anymore sol_Stage.Dozen * -1;
            sol_StageAdjustment.Quantity = sol_Stage.Quantity * -1;
            sol_StageAdjustment.Price    = sol_Stage.Price;
            sol_StageAdjustment.Remarks  = sol_Stage.Remarks;
            sol_StageAdjustment.Status   = sol_Stage.Status;

            //in case there is no default value in the db
            sol_StageAdjustment.DateClosed = DateTime.Parse("1753-01-01 12:00:00.000");

            switch (adjActionTypes)
            {
            case AdjustmentActionTypes.Return:
                //remove it
                //sol_StageAdjustment.TagNumber = sol_Stage.TagNumber;
                sol_StageAdjustment.Dozen    = sol_Stage.Dozen * -1;
                sol_StageAdjustment.Quantity = sol_Stage.Quantity * -1;
                //sol_StageAdjustment.Status = sol_Stage.Status;
                sol_Stage_Sp.Insert(sol_StageAdjustment);

                //add an adjustment to return to inventory
                sol_StageAdjustment.ShipmentID = 0;
                sol_StageAdjustment.TagNumber  = textBoxNewTagNumber.Text; //sol_Stage.TagNumber
                sol_StageAdjustment.Dozen      = 0;                        //not used anymore sol_Stage.Dozen;
                sol_StageAdjustment.Quantity   = sol_Stage.Quantity;
                sol_StageAdjustment.Status     = "I";                      //sol_Stage.Status;

                sol_Stage_Sp.Insert(sol_StageAdjustment);

                ////remove it from shipment
                //sol_Stage.ShipmentID = 0;
                //sol_Stage.TagNumber = textBoxNewTagNumber.Text;
                //sol_Stage.Status = "I";
                //sol_Stage_Sp.Update(sol_Stage);


                MessageBox.Show(
                    string.Format(
                        @"Tag Number {0} has been added to inventory. Note: This tag is in inventory and is no longer linked to the previous shipment.  Therefore, the new tag will not be removed if you delete the adjustment."
                        , textBoxNewTagNumber.Text
                        ));

                return(true);

            //break;

            case AdjustmentActionTypes.Remove:

                break;
            //case AdjustmentActionTypes.Add:
            //    break;

            case AdjustmentActionTypes.Adjust:
                //create reverse adjustment to remove original quantity
                sol_Stage_Sp.Insert(sol_StageAdjustment);

                //create adjustment with new product
                if (productId > 0)
                {
                    if (sol_Product_Sp == null)
                    {
                        sol_Product_Sp = new Sol_Product_Sp(Properties.Settings.Default.WsirDbConnectionString);
                    }
                    sol_Product = sol_Product_Sp.Select(productId);
                    sol_StageAdjustment.ProductID   = productId;
                    sol_StageAdjustment.ProductName = sol_Product.ProName;
                    //sol_StageAdjustment.Dozen = sol_Stage.Dozen;
                    //sol_StageAdjustment.Quantity = sol_Stage.Quantity;
                }

                int newQuantity = 0;
                int.TryParse(textBoxNewQuantity.Text, out newQuantity);

                sol_StageAdjustment.Quantity = newQuantity;
                sol_StageAdjustment.Dozen    = 0;   //not used anymore newQuantityOfDozens;

                break;

            //case AdjustmentActionTypes.Change:
            //    //create reverse adjustment to remove original product

            //    sol_Stage_Sp.Insert(sol_StageAdjustment);

            //    //create adjustment with new product
            //    if (sol_Product_Sp == null)
            //        sol_Product_Sp = new Sol_Product_Sp(Properties.Settings.Default.WsirDbConnectionString);
            //    sol_Product = sol_Product_Sp.Select(productId);
            //    sol_StageAdjustment.ProductID = productId;
            //    sol_StageAdjustment.ProductName = sol_Product.ProName;
            //    sol_StageAdjustment.Dozen = sol_Stage.Dozen;
            //    sol_StageAdjustment.Quantity = sol_Stage.Quantity;

            //    break;
            //case AdjustmentActionTypes.Delete:
            //    break;
            default:
                break;
            }

            sol_Stage_Sp.Insert(sol_StageAdjustment);

            return(true);
        }
        private void buttonPrintLabel_Click(object sender, EventArgs e)
        {
            //commands

            /*
             * {barCode}
             * {vendorId}
             * {productCode}
             * {quantity}
             * {tag}
             * {depotName}
             * {description}    of the product
             * {dozen}
             * {date}
             * {stageId}
             */


            string barCode     = String.Empty;
            string vendorId    = String.Empty;
            string productCode = String.Empty;
            string quantity    = String.Empty;
            string tag         = String.Empty;

            int intValue = 0;

            //sending raw directly to lp2844
            UpcLabel label         = new UpcLabel("");
            string   labelCommands = Properties.Settings.Default.SettingsWsLabelCommands;

            //open table connection
            if (sol_Agency_Sp == null)
            {
                sol_Agency_Sp = new Sol_Agencie_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }
            if (sol_Product_Sp == null)
            {
                sol_Product_Sp = new Sol_Product_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            //search for product
            sol_Product = sol_Product_Sp.Select(sol_Stage.ProductID);
            if (sol_Product != null)
            {
                intValue = 0;
                Int32.TryParse(sol_Product.ProductCode, out intValue);
                productCode = intValue.ToString("0000");

                sol_Agency = sol_Agency_Sp.Select(sol_Product.AgencyID);
                if (sol_Agency != null)
                {
                    intValue = 0;
                    Int32.TryParse(sol_Agency.VendorID, out intValue);
                    vendorId = intValue.ToString("0000");
                }
            }


            intValue = 0;
            Int32.TryParse(textBoxDozen.Text, out intValue);
            string c = String.Format("{0}", intValue);

            labelCommands = labelCommands.Replace("{dozen}", c);

            int intQuantity = intValue * 12;

            c             = String.Format("{0}", intQuantity);
            labelCommands = labelCommands.Replace("{quantity}", c);
            quantity      = intQuantity.ToString("00000");

            intValue = 0;
            Int32.TryParse(textBoxTagNumber.Text, out intValue);
            tag = intValue.ToString("0000000");

            barCode       = vendorId + productCode + quantity + tag;
            labelCommands = labelCommands.Replace("{barCode}", barCode);

            labelCommands = labelCommands.Replace("{vendorId}", sol_Agency.VendorID.Trim());
            labelCommands = labelCommands.Replace("{productCode}", sol_Product.ProductCode.Trim());
            labelCommands = labelCommands.Replace("{quantity}", sol_Stage.Quantity.ToString().Trim());

            labelCommands = labelCommands.Replace("{tag}", textBoxTagNumber.Text.Trim());

            labelCommands = labelCommands.Replace("{depotName}", Main.Sol_ControlInfo.BusinessName.Trim());
            labelCommands = labelCommands.Replace("{description}", sol_Product.ProDescription.Trim());

            //labelCommands = labelCommands.Replace("{dozen}", textBoxTagNumber.Text.Trim());
            //labelCommands = labelCommands.Replace("{date}", textBoxTagNumber.Text.Trim());
            //labelCommands = labelCommands.Replace("{stageId}", textBoxTagNumber.Text.Trim());

            ////MessageBox.Show(labelCommands);
            //labelCommands = labelCommands.Replace("{tag}", textBoxTagNumber.Text.Trim());
            ////labelCommands = labelCommands.Replace("{agency}", textBoxTagNumber.Text.Trim());
            //labelCommands = labelCommands.Replace("{description}", comboBoxProducts.Text.Trim());

            DateTime dt = Main.rc.FechaActual; // ;

            try
            {
                dt = DateTime.Parse(textBoxDate.Text);
            }
            catch { }

            labelCommands = labelCommands.Replace("{date}", dt.ToString("dd-MMM-yyyy"));
            labelCommands = labelCommands.Replace("{stageId}", sol_Stage.StageID.ToString());

            try
            {
                //quitar (uncomment)
                label.Print(Properties.Settings.Default.SettingsWsLabelPrinter, labelCommands);

                //quitar (comment)
                //MessageBox.Show(labelCommands);
            }
            catch
            {
                MessageBox.Show("Label printer not found!");
            }
        }
        private void comboBoxProducts_SelectedIndexChanged(object sender, EventArgs e)
        {
            int Id = -1;

            try
            {
                Id = (int)comboBoxProducts.SelectedValue;
            }
            catch
            {
                return;
            }


            //delete row if it was new
            if (sol_Agency != null)
            {
                if (sol_Agency.AutoGenerateTagNumber)
                {
                    if (buttonClicked == "&New")
                    {
                        DeleteStagedRow();
                    }
                }
            }

            //Sol_Product sol_Product = new Sol_Product();
            if (sol_Product_Sp == null)
            {
                sol_Product_Sp = new Sol_Product_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }
            sol_Product = sol_Product_Sp.Select(Id);

            comboBoxContainers.SelectedValue = sol_Product.ContainerID;


            //open table connection
            if (sol_Agency_Sp == null)
            {
                sol_Agency_Sp = new Sol_Agencie_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }
            sol_Agency = sol_Agency_Sp.Select(sol_Product.AgencyID);
            //if (sol_Agency != null)
            //{
            //    Int32.TryParse(sol_Agency.VendorID, out intValue);
            //    vendorId = intValue.ToString("0000");
            //}


            if (sol_Agency.AutoGenerateTagNumber)
            {
                //add row
                if (AddStagedRow())
                {
                    textBoxTagNumber.Text     = sol_Stage.TagNumber;
                    textBoxTagNumber.ReadOnly = true;
                    comboBoxContainers.Focus();
                    comboBoxProducts.Enabled = false;
                }
                else
                {
                    buttonCancel.PerformClick();
                }
            }
            else
            {
                textBoxTagNumber.ReadOnly = false;
                //textBoxTagNumber.Focus();
            }

            //Sol_StandardDozen_Sp sol_StandardDozen_Sp = new Sol_StandardDozen_Sp(Properties.Settings.Default.WsirDbConnectionString);
            //Sol_StandardDozen sol_StandardDozen = sol_StandardDozen_Sp.Select(sol_Product.StandardDozenID);
            //textBoxDefaultDozen.Text = sol_StandardDozen.Quantity.ToString();

            textBoxQuantity.Text = sol_Product.TargetQuantity.ToString();
            textBoxDozen.Text    = SolFunctions.Quantity2Dozen(sol_Product.TargetQuantity);
        }
        //private void timer1_Tick(object sender, System.EventArgs e)
        //{
        //    DateTime t = DateTime.Now;
        //    toolStripStatusLabelTimer.Text = t.ToShortTimeString();
        //    toolStripStatusLabelToday.Text = t.ToShortDateString();
        //}


        private void textBoxTagNumber_Leave(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBoxTagNumber.Text))
            {
                return;
            }

            if (buttonClicked != "&New")
            {
                return;
            }


            //was a barcode read?
            string barCode = textBoxTagNumber.Text.Trim();
            string x       = barCode;

            if (x.Length > 7)
            {
                //x = x.Substring(x.Length - 7);
                //int intValue = 0;
                //Int32.TryParse(x, out intValue);
                //if (intValue > 0)
                //    textBoxTagNumber.Text = String.Format("{0}", intValue);
                //else
                //{
                //    MessageBox.Show("Error parsing the Tag Number!");
                //    textBoxTagNumber.Focus();
                //    return;
                //}


                //search for product from barcode

                /* 0000 1006 00000 0004209
                 * 4 = vendorID
                 *      4 = productCode = ItemTypes (CRIS)
                 *           5 = quantity
                 *                 7 = tagNumber
                 * 7 + 5 + 4
                 *
                 */

                x = barCode;
                if (x.Length > 19)
                {
                    int i = x.Length - 16;
                    x = x.Substring(i, 4);
                }
                if (sol_Product_Sp == null)
                {
                    sol_Product_Sp = new Sol_Product_Sp(Properties.Settings.Default.WsirDbConnectionString);
                }

                //search for product
                sol_Product = sol_Product_Sp.SelectProductCode(x);
                if (sol_Product != null)
                {
                    comboBoxProducts.SelectedValue = sol_Product.ProductID;
                    textBoxQuantity.Focus();
                    //textBoxDozen.Focus();
                }
            }
        }