コード例 #1
0
        protected void FillBinComboBox(int jobnumber)
        {
            Connection_Query con    = Connection_Query.INSTANCE;
            SqlConnection    conn   = con.con;
            DataSet          binnum = new DataSet();

            try
            {
                con.OpenConnection();
                SqlCommand bins = new SqlCommand("select [dbo].[BIN].[Index] as BinNumber, BinID, FK_JobID from BIN WHERE FK_JobID = @Jobid And Completed = 'False'", conn);
                bins.Parameters.AddWithValue("Jobid", jobnumber);
                SqlDataAdapter binnumbers = new SqlDataAdapter(bins);
                DataTable      dt         = new DataTable();
                binnumbers.Fill(dt);
                con.CloseConnection();
                dr           = dt.NewRow();
                dr.ItemArray = new object[] { 0, 0 };
                dt.Rows.InsertAt(dr, 0);
                mWBinComboBox.DataSource    = dt;
                mWBinComboBox.DisplayMember = "BinNumber";
                mWBinComboBox.ValueMember   = "BinID";
            }
            catch (Exception ex)
            {
                                //Exception Message
                MessageBox.Show("Connection to the database has quit. Please reload Database" + ex.StackTrace + ex.Message);
            }
            finally
            {
                con.CloseConnection();
                conn.Dispose();
            }
        }
コード例 #2
0
        protected void FillComboBox()
        {
            Connection_Query con    = Connection_Query.INSTANCE;
            SqlConnection    conn   = con.con;
            DataSet          user1  = new DataSet();
            DataSet          user2  = new DataSet();
            DataSet          jobnum = new DataSet();

            try
            {
                con.OpenConnection();
                SqlCommand cmdUser = new SqlCommand("select CONCAT(UserLName, ', ', UserFName)as UserLastFirst, UserID, UserFName, UserLName from dbo.[USER] order by UserLastFirst", conn);
                SqlCommand cmdJob  = new SqlCommand("select CONCAT(JobID,' - ',ClientName) as JobClient, JobID from dbo.[JOB], CLIENT Where ClientID = FK_ClientID order by JobID", conn);

                SqlDataAdapter ucb1 = new SqlDataAdapter();
                SqlDataAdapter ucb2 = new SqlDataAdapter();
                SqlDataAdapter job  = new SqlDataAdapter();

                ucb1.SelectCommand = cmdUser;
                ucb2.SelectCommand = cmdUser;
                job.SelectCommand  = cmdJob;

                ucb1.Fill(user1);
                ucb2.Fill(user2);
                job.Fill(jobnum);

                mWUser1ComboBox.DisplayMember = "UserLastFirst";
                mWUser1ComboBox.ValueMember   = "UserID";
                mWUser1ComboBox.DataSource    = user1.Tables[0];

                mWUser2ComboBox.DisplayMember = "UserLastFirst";
                mWUser2ComboBox.ValueMember   = "UserID";
                mWUser2ComboBox.DataSource    = user2.Tables[0];

                mWJobComboBox.DisplayMember = "JobClient";
                mWJobComboBox.ValueMember   = "JobID";
                mWJobComboBox.DataSource    = jobnum.Tables[0];
            }
            catch (Exception ex)
            {
                                //Exception Message
                MessageBox.Show("Connection to the database has quit. Please reload Database" + ex.StackTrace + ex.Message);
            }
            finally
            {
                con.CloseConnection();
                conn.Dispose();
            }
        }
コード例 #3
0
        private void LoadDataGrid()
        {
            Connection_Query con = Connection_Query.INSTANCE;

            con.OpenConnection();
            SqlConnection conn = con.con;

            try
            {
                SqlCommand cmdload = new SqlCommand("select FK_JobID as JobNumber, [dbo].[SEQUENCE].[Index] as SequenceNumber, ScanDateTime " +
                                                    "from SEQUENCE, BIN WHERE BinID = FK_BinID AND BinID = @BinID", conn);
                SqlParameter BinId = new SqlParameter("@BinID", SqlDbType.Int);
                BinId.Value = binid;
                cmdload.Parameters.Add(BinId);
                SqlDataAdapter datagridview = new SqlDataAdapter(cmdload);
                DataTable      Sequence     = new DataTable();
                using (SqlDataReader sqldr = cmdload.ExecuteReader())
                {
                    Sequence.Load(sqldr);
                    sqldr.Close();
                }
                DataGridView dataGridView1 = new DataGridView();
                dataGridView1.DataSource = datagridview.FillSchema(Sequence, SchemaType.Source);
                BindingSource bs = new BindingSource();
                datagridview.Fill(Sequence);
                sWJobDataGrid.DataSource = Sequence;
                //sWJobDataGrid.DataMember = Sequence.Table[0];
                //Sequence.Load(cmdload.ExecuteReader());
            }
            catch (Exception ex)
            {
                                //Exception Message
                MessageBox.Show("Connection to the database has quit. Please reload Database" + ex.Message + " " + ex.StackTrace);
            }
            finally
            {
                con.CloseConnection();
                conn.Dispose();
            }
        }
コード例 #4
0
        private void sWSubmitButton_Click(object sender, EventArgs e)
        {
            int bin = Convert.ToInt32(binid);

            Connection_Query con = Connection_Query.INSTANCE;

            con.OpenConnection();
            SqlConnection conn = con.con;

            try
            {
                string processTableUpdate = "INSERT into SEQUENCE(FK_BinID, [dbo].[SEQUENCE].[INDEX], ScanDateTime) Values (@binid, @[Index], @ScanDT)";
                using (SqlCommand updateProcessTable = new SqlCommand(processTableUpdate, conn))
                {
                    SqlParameter BinsID = new SqlParameter("@binid", SqlDbType.Int);
                    SqlParameter indx   = new SqlParameter("@[Index]", SqlDbType.Int);
                    SqlParameter scan   = new SqlParameter("@ScanDT", SqlDbType.DateTime);
                    BinsID.Value = this.binid;
                    indx.Value   = sequenceMaskedTextBox.Text;
                    scan.Value   = DateTime.Now.ToLocalTime();
                    updateProcessTable.Parameters.Add(BinsID);
                    updateProcessTable.Parameters.Add(indx);
                    updateProcessTable.Parameters.Add(scan);
                    updateProcessTable.CommandType = CommandType.Text;
                    updateProcessTable.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                //Exception Message
                MessageBox.Show("Connection to the database has quit. Please reload Database" + ex.Message + " " + ex.StackTrace);
            }
            finally
            {
                con.CloseConnection();
                conn.Dispose();
            }
        }