Esempio n. 1
0
        private int UpdateDB(string strSQL)
        {
            objDatabase Database = new objDatabase();
            int         intRows;

            return(intRows = Database.AddData(strSQL));
        }
Esempio n. 2
0
        private void LoadControl()
        {
            objDatabase Database = new objDatabase();
            string      strSQL;


            cmbShift.Items.Clear();
            strSQL = "Select Name, TimeIn, TimeOut";
            strSQL = strSQL + " From Shift";

            objTable = Database.ReturnDataTable(strSQL);

            // Loading Shifts into combobox

            foreach (DataRow objRow in objTable.Rows)
            {
                cmbShift.Items.Add(objRow[0].ToString());
            }

            cmbShift.SelectedIndex = -1;
            cmbShift.Text          = "<New Shift>";
            dtStartTime.Text       = "12:00 AM";
            dtEndTime.Text         = "12:00 AM";
            cmbShift.Focus();
        }
Esempio n. 3
0
        private int UpdateDatabase(string strSQL)
        {
            objDatabase Database = new objDatabase();


            return(Database.AddData(strSQL));
        }
Esempio n. 4
0
        private void butEnter_Click(object sender, EventArgs e)
        {
            string[]    strSupervisor;
            string[]    strWorker;
            int         intRows = 0;
            string      strSQL;
            objDatabase Database = new objDatabase();

            strSupervisor = cmbSupervisor.SelectedItem.ToString().Split(' ');

            //Loop through all entries in dtWorkers
            foreach (DataRow objRow in dtWorkers.Rows)
            {
                strWorker = objRow["Name"].ToString().Split(' ');
                if (objRow["Action"].ToString() == "Add")
                {
                    strSQL  = "spUpdateSupervisor " + "'" + strSupervisor[0] + "','" + strSupervisor[1] + "','" + strWorker[0] + "','" + strWorker[1] + "','" + dtDay.Text.ToString() + "','" + cmbShift.SelectedItem.ToString() + "'";
                    intRows = intRows + Database.AddData(strSQL);
                }
                else if (objRow["Action"].ToString() == "Delete")
                {
                    strSQL  = "spRemoveSupervisor " + "'" + strSupervisor[0] + "','" + strSupervisor[1] + "','" + strWorker[0] + "','" + strWorker[1] + "','" + dtDay.Text.ToString() + "','" + cmbShift.SelectedItem.ToString() + "'";
                    intRows = intRows + Database.AddData(strSQL);
                }
            }

            MessageBox.Show(intRows.ToString() + " rows have been updated.");

            strDtDay         = dtDay.Value.ToShortDateString();
            intCmbShift      = cmbShift.SelectedIndex;
            intCmbSupervisor = cmbSupervisor.SelectedIndex;

            LoadControl();
        }
Esempio n. 5
0
        private void update_ListBoxes()
        {
            if (dtDay.Value.ToShortDateString() != "")
            {
                lstScheduled.Items.Clear();
                lstWorkers.Items.Clear();

                objDatabase Database = new objDatabase();
                string      strSQL   = "spReturnSchedule '" + dtDay.Value.ToShortDateString() + "'";

                dtSchedule = Database.ReturnDataTable(strSQL);
                dtSchedule.Columns.Add("Action", typeof(string));


                foreach (DataRow objRow in dtSchedule.Rows)
                {
                    if (objRow["Shift"].ToString() == cmbShift.Text)
                    {
                        lstScheduled.DrawMode = DrawMode.OwnerDrawFixed;
                        lstScheduled.Items.Add(objRow["Worker"]);
                    }
                    else if (objRow["Shift"].ToString() == "")
                    {
                        lstWorkers.DrawMode = DrawMode.OwnerDrawFixed;
                        strCurrentItem      = strCurrentItem + "|" + objRow["Worker"];
                        lstWorkers.Items.Add(objRow["Worker"]);
                    }
                }
            }
        }
Esempio n. 6
0
        private void butSearch_Click(object sender, EventArgs e)
        {
            objDatabase Database = new objDatabase();
            string      strSQL   = CreateSQL();
            DataTable   objTable = new DataTable();


            //objDataReader = Database.ReturnData(strSQL);
            objTable = Database.ReturnDataTable(strSQL);

            if (objTable.Rows.Count > 0)
            {
                objGrid.DataSource         = objTable;
                objGrid.Columns[0].Visible = false;
                objGrid.Columns[4].Visible = false;

                if (objTable.Rows.Count == 1)
                {
                    Fill_Control(objGrid.Rows[0]);
                }
            }
            else
            {
                MessageBox.Show("No rows were returned, for the given critera, please try again");
                ClearControl();
            }
        }
Esempio n. 7
0
        private DataTable QueryDB(string strSQL)
        {
            objDatabase Database = new objDatabase();
            DataTable   objDTable;


            return(objDTable = Database.ReturnDataTable(strSQL));
        }
Esempio n. 8
0
        private void butEnter_Click(object sender, EventArgs e)
        {
            objDatabase Database = new objDatabase();
            string      strSQL;
            string      strMsg = "";
            int         intRows = 0, intDelete = 0, intAdd = 0;

            Cursor.Current = Cursors.WaitCursor;
            foreach (DataRow objRow in dtSchedule.Rows)
            {
                if (objRow["Action"].ToString().Length > 0)
                {
                    strSQL = "spAddSchedule '" + objRow["Worker"] + "','" + objRow["shift"] + "','" + dtDay.Text + "','" + objRow["Action"] + "'";
                    //update database
                    intRows = Database.AddData(strSQL);
                    if (objRow["Action"].ToString() == "delete")
                    {
                        intDelete = intRows + intDelete;
                    }
                    else if (objRow["Action"].ToString() == "new")
                    {
                        intAdd = intRows + intAdd;
                    }
                }
            }
            Cursor.Current = Cursors.Default;

            if (intAdd > 0)
            {
                strMsg = intAdd.ToString() + " worker(s) have been added to the " + cmbShift.Text + ".";
            }

            if (intDelete > 0)
            {
                if (strMsg.Length > 0)
                {
                    strMsg = strMsg + "\r\n";
                }

                strMsg = strMsg + intDelete.ToString() + " worker(s) have been removed from the " + cmbShift.Text + ".";
            }

            MessageBox.Show(strMsg);
            intCmbShiftIndex = cmbShift.SelectedIndex;
            strDtDay         = dtDay.Value.ToLongDateString();
            lstScheduled.Items.Clear();
            lstWorkers.Items.Clear();
            strAction = "";
            LoadControl();
        }
Esempio n. 9
0
        private void butRole_Click(object sender, EventArgs e)
        {
            objDatabase Database = new objDatabase();
            string      strSQL;
            int         intRows;

            strSQL  = "spUpdateRole '" + txtFirstName.Text + "','" + txtLastName.Text + "','" + cmbRole.Text + "'";
            intRows = Database.AddData(strSQL);

            if (intRows > 0)
            {
                MessageBox.Show(txtFirstName.Text + " " + txtLastName.Text + "'s role has been updated.");
            }
            ClearControl();
        }
Esempio n. 10
0
        private void Load_cmbShift()
        {
            objDatabase   Database = new objDatabase();
            string        strSQL   = "Select Shift.Name from Shift";
            SqlDataReader objReader;

            cmbShift.Items.Clear();
            objReader = Database.ReturnData(strSQL);

            while (objReader.Read())
            {
                cmbShift.Items.Add(objReader[0].ToString());
                cmbShift.SelectedIndex = 0;
            }
        }
Esempio n. 11
0
        private void LoadControl()
        {
            objDatabase   Database = new objDatabase();
            SqlDataReader objReader;
            string        strSQL = "Select Role.Description from Role";

            objReader = Database.ReturnData(strSQL);

            while (objReader.Read())
            {
                cmbRole.Items.Add(objReader[0].ToString());
            }

            cmbRole.SelectedIndex = 0;
            txtFirstName.Focus();
        }
Esempio n. 12
0
        private void butDelete_Click(object sender, EventArgs e)
        {
            objDatabase Database = new objDatabase();
            string      strSQL   = "Delete From Shift Where Shift.Name = '" + cmbShift.Text + "'";

            Cursor.Current = Cursors.WaitCursor;
            int intRows = Database.AddData(strSQL);

            LoadControl();
            Cursor.Current = Cursors.Default;

            if (intRows > 0)
            {
                MessageBox.Show("The shift has been deleted.");
            }
        }
Esempio n. 13
0
        private void butEnter_Click(object sender, EventArgs e)
        {
            if (VerifyData() == true)
            {
                objDatabase Database = new objDatabase();
                string      strSQL   = "spAddShift '" + cmbShift.Text + "', '" + dtStartTime.Text + "', '" + dtEndTime.Text + "'";

                Cursor.Current = Cursors.WaitCursor;
                int intRows = Database.AddData(strSQL);
                LoadControl();
                Cursor.Current = Cursors.Default;

                if (intRows > 0)
                {
                    MessageBox.Show("The shift has been successfully updated.");
                }
            }
        }
Esempio n. 14
0
        private void AddPerson()
        {
            string      strSQL;
            objDatabase Database = new objDatabase();
            int         intRows;
            bool        blReady;

            blReady = CheckControl();
            if (blReady == true)
            {
                strSQL  = "spAddPerson '" + txtFirstName.Text + "','" + txtLastName.Text + "','" + cmbRole.SelectedItem.ToString() + "','" + strPicPath + "'";
                intRows = Database.AddData(strSQL);

                if (intRows > 0)
                {
                    MessageBox.Show(txtFirstName.Text + " " + txtLastName.Text + " has been added to the database.");
                    ClearControl();
                }
            }
        }
Esempio n. 15
0
        private void objTabs_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (objTabs.SelectedIndex == 2)
            {
                cmbShift.Items.Clear();
                // Filing cmbShifts
                objDatabase DataBase  = new objDatabase();
                string      strSQL    = "Select Shift.Name From Shift";
                DataTable   objDTable = DataBase.ReturnDataTable(strSQL);
                foreach (DataRow objRow in objDTable.Rows)
                {
                    cmbShift.Items.Add(objRow[0]);
                }

                cmbReports.Items.Clear();
                cmbReports.Items.Add("Schedule");
                cmbReports.Items.Add("Accounting");
                cmbReports.SelectedIndex = -1;
            }
        }
Esempio n. 16
0
        private void FillGrid()
        {
            objDatabase Database = new objDatabase();
            string      strSQL   = "spReturnUserTime " + strID;

            dtTimes = Database.ReturnDataTable(strSQL);

            grdTimes.Columns.Clear();
            grdTimes.DataSource = dtTimes;

            grdTimes.Columns[0].Visible = false;
            grdTimes.Columns[2].Visible = false;
            grdTimes.Columns[4].Visible = false;
            grdTimes.Columns[5].Visible = false;

            SetupDateTime(dtStart, chkAddStartTime, false);
            SetupDateTime(dtEnd, chkAddEndTime, false);

            butAdjust.Enabled = false;
            butAdd.Enabled    = false;
        }
Esempio n. 17
0
 private void FillDataTable()
 {
     objDatabase Database = new objDatabase();
 }