Пример #1
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();
        }
Пример #2
0
        private void buttonQuitar_Click(object sender, EventArgs e)
        {
            DataRowView conveyor = (DataRowView)listBoxAssignedConveyors.SelectedItem;

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

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

            int id = 0;

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

            vir_ConveyorLink_Sp.Delete(id);

            bindListBoxConveyors();
        }
Пример #3
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
        }