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

            vir_ConveyorLink.ConveyorLinkID = SqlClientUtility.GetInt32(dataReader, "ConveyorLinkID", 0);
            vir_ConveyorLink.BagPositionID  = SqlClientUtility.GetInt32(dataReader, "BagPositionID", 0);
            vir_ConveyorLink.ConveyorID     = SqlClientUtility.GetInt32(dataReader, "ConveyorID", 0);

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

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@BagPositionID", vir_ConveyorLink.BagPositionID),
                new SqlParameter("@ConveyorID", vir_ConveyorLink.ConveyorID)
            };

            vir_ConveyorLink.ConveyorLinkID = (int)SqlClientUtility.ExecuteScalar(connectionStringName, CommandType.StoredProcedure, "Vir_ConveyorLink_Insert", parameters);
        }
Beispiel #3
0
        /// <summary>
        /// Updates a record in the Vir_ConveyorLink table.
        /// </summary>
        public virtual void Update(Vir_ConveyorLink vir_ConveyorLink)
        {
            ValidationUtility.ValidateArgument("vir_ConveyorLink", vir_ConveyorLink);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@ConveyorLinkID", vir_ConveyorLink.ConveyorLinkID),
                new SqlParameter("@BagPositionID", vir_ConveyorLink.BagPositionID),
                new SqlParameter("@ConveyorID", vir_ConveyorLink.ConveyorID)
            };

            SqlClientUtility.ExecuteNonQuery(connectionStringName, CommandType.StoredProcedure, "Vir_ConveyorLink_Update", parameters);
        }
Beispiel #4
0
        private void buttonAgregar_Click(object sender, EventArgs e)
        {
            //vir_BagPosition_SelectAllBindingNavigatorSaveItem.PerformClick();

            bagPositionNameTextBox.Text = bagPositionNameTextBox.Text.Trim();
            if (!Funciones.ValidateText(bagPositionNameTextBox, ref errorProvider1))
            {
                bagPositionNameTextBox.Focus();
                return;
            }

            string t = targetQuantityTextBox.Text;

            this.Validate();
            this.vir_BagPosition_SelectAllBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.dataSetBagPosition);

            DataRowView conveyor = (DataRowView)listBoxUnassignedConveyors.SelectedItem;

            if (conveyor == null)
            {
                MessageBox.Show("PLease select a conveyor to add!");
                listBoxUnassignedConveyors.Focus();
                return;
            }

            int bagPositionID = 0;

            int.TryParse(bagPositionIDTextBox.Text, out bagPositionID);


            if (vir_ConveyorLink_Sp == null)
            {
                vir_ConveyorLink_Sp = new Vir_ConveyorLink_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            //vir_ConveyorLink_Sp._DeleteByBagPositionIDConveyorID(bagPositionID, c.ConveyorID);

            vir_ConveyorLink = new Vir_ConveyorLink();
            vir_ConveyorLink.BagPositionID = bagPositionID;

            int conveyorid = 0;

            int.TryParse(conveyor["conveyorid"].ToString(), out conveyorid);

            vir_ConveyorLink.ConveyorID = conveyorid;
            vir_ConveyorLink_Sp.Insert(vir_ConveyorLink);

            bindListBoxConveyors();
        }
Beispiel #5
0
        /// <summary>
        /// Selects all records from the Vir_ConveyorLink table.
        /// </summary>
        public virtual List <Vir_ConveyorLink> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Vir_ConveyorLink_SelectAll"))
            {
                List <Vir_ConveyorLink> vir_ConveyorLinkList = new List <Vir_ConveyorLink>();
                while (dataReader.Read())
                {
                    Vir_ConveyorLink vir_ConveyorLink = MakeVir_ConveyorLink(dataReader);
                    vir_ConveyorLinkList.Add(vir_ConveyorLink);
                }

                return(vir_ConveyorLinkList);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Selects all records from the Vir_ConveyorLink table by a foreign key.
        /// </summary>
        public virtual List <Vir_ConveyorLink> _SelectAllByConveyorID(int conveyorID)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@ConveyorID", conveyorID)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Vir_ConveyorLink_SelectAllByConveyorID", parameters))
            {
                List <Vir_ConveyorLink> vir_ConveyorLinkList = new List <Vir_ConveyorLink>();
                while (dataReader.Read())
                {
                    Vir_ConveyorLink vir_ConveyorLink = MakeVir_ConveyorLink(dataReader);
                    vir_ConveyorLinkList.Add(vir_ConveyorLink);
                }

                return(vir_ConveyorLinkList);
            }
        }
Beispiel #7
0
        private void bindListBoxConveyors()
        {
            //DataSet dsAssigned, dsUnAssigned;
            //DataTable dtAssigned, dtUnAssigned;
            //DataRow drAssigned, drUnAssigned;

            dsAssigned = new DataSet();
            dtAssigned = new DataTable("MyTable");
            dtAssigned.Columns.Add(new DataColumn("id", typeof(int)));
            dtAssigned.Columns.Add(new DataColumn("name", typeof(string)));
            dtAssigned.Columns.Add(new DataColumn("conveyorId", typeof(string)));

            dsUnassigned = new DataSet();
            dtUnassigned = new DataTable("MyTable");
            dtUnassigned.Columns.Add(new DataColumn("id", typeof(int)));
            dtUnassigned.Columns.Add(new DataColumn("name", typeof(string)));
            dtUnassigned.Columns.Add(new DataColumn("conveyorId", typeof(string)));

            listBoxUnassignedConveyors.DataSource = null;
            listBoxAssignedConveyors.DataSource   = null;

            int bagPositionID = 0;

            int.TryParse(bagPositionIDTextBox.Text, out bagPositionID);

            if (vir_ConveyorLink_Sp == null)
            {
                vir_ConveyorLink_Sp = new Vir_ConveyorLink_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            if (vir_Conveyor_Sp == null)
            {
                vir_Conveyor_Sp = new Vir_Conveyor_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            List <Vir_Conveyor> vir_ConveyorList = vir_Conveyor_Sp.SelectAll();

            foreach (Vir_Conveyor c in vir_ConveyorList)
            {
                vir_ConveyorLink = vir_ConveyorLink_Sp._SelectByBagPositionIDConveyorID(bagPositionID, c.ConveyorID);
                if (vir_ConveyorLink == null)
                {
                    drUnassigned               = dtUnassigned.NewRow();
                    drUnassigned["id"]         = 0; // vir_ConveyorLink.ConveyorLinkID;
                    drUnassigned["name"]       = c.ConveyorDescription;
                    drUnassigned["conveyorid"] = c.ConveyorID;
                    dtUnassigned.Rows.Add(drUnassigned);
                }
                else
                {
                    drAssigned               = dtAssigned.NewRow();
                    drAssigned["id"]         = vir_ConveyorLink.ConveyorLinkID;
                    drAssigned["name"]       = c.ConveyorDescription;
                    drAssigned["conveyorid"] = c.ConveyorID;
                    dtAssigned.Rows.Add(drAssigned);
                }
            }

            //Unassigned
            dsUnassigned.Tables.Add(dtUnassigned);
            listBoxUnassignedConveyors.ValueMember   = "id";
            listBoxUnassignedConveyors.DisplayMember = "name";
            listBoxUnassignedConveyors.DataSource    = dtUnassigned;
            //listBoxUnassignedConveyors.Items.Add(c.ConveyorDescription);

            //Assigned
            dsAssigned.Tables.Add(dtAssigned);
            //listBoxAssignedConveyors.Items.Add(c.ConveyorDescription);
            listBoxAssignedConveyors.ValueMember   = "id";
            listBoxAssignedConveyors.DisplayMember = "name";
            listBoxAssignedConveyors.DataSource    = dtAssigned;
            //listBoxAssignedConveyors.r
        }