Ejemplo n.º 1
0
 private int addShift()
 {
     return(SqlCEHelper.ExecuteNonQuery("INSERT INTO shifts (shift_desc, time_from, time_to) VALUES(@shift_desc, @time_from, @time_to)",
                                        new SqlCeParameter("@shift_desc", txtShift.Text.ToUpper()),
                                        new SqlCeParameter("@time_from", dtpFrom.Text),
                                        new SqlCeParameter("@time_to", dtpTo.Text)));
 }
Ejemplo n.º 2
0
 private int updateLine()
 {
     return(SqlCEHelper.ExecuteNonQuery("UPDATE lines SET line=@line,tag=@tag WHERE id=@id",
                                        new SqlCeParameter("@line", txtName.Text.ToUpper()),
                                        new SqlCeParameter("@tag", txtTag.Text),
                                        new SqlCeParameter("@id", txtId.Text.ToString())));
 }
Ejemplo n.º 3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (btnEdit.Text == "Edit")
            {
                inputStatas(true);
                btnEdit.Text    = "Update";
                btnEdit.Enabled = true;
                btnAdd.Enabled  = false;
                txtShift.Focus();
            }
            else
            {
                if (txtShift.Text == "")
                {
                    MessageBox.Show("Shift name is required!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    txtShift.Focus();
                }
                else if (dtpFrom.Text == "")
                {
                    MessageBox.Show("Time from is required!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    dtpFrom.Focus();
                }

                else if (dtpTo.Text == "")
                {
                    MessageBox.Show("Time to is required!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    dtpTo.Focus();
                }
                else
                {
                    DataSet   ds = SqlCEHelper.ExecuteDataTable("SELECT * FROM shifts where shift_desc ='" + txtShift.Text.Trim().ToUpper() + "' AND id != '" + txtId.Text.ToString() + "'");
                    DataTable dt = ds.Tables["data"];
                    if (dt.Rows.Count > 0)
                    {
                        MessageBox.Show("Shift already exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                        txtShift.Focus();
                        txtShift.Text = "";
                    }
                    else
                    {
                        if (updateShift() == 1)
                        {
                            loadGrid();
                            inputStatas(false);
                            btnAdd.Text    = "Add";
                            btnAdd.Enabled = true;
                        }
                        else
                        {
                            MessageBox.Show("Unable to update shift", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);;
                        }
                    }

                    loadGrid();
                    inputStatas(false);
                    btnEdit.Text = "Edit";
                }
            }
        }
Ejemplo n.º 4
0
 private int updateShift()
 {
     return(SqlCEHelper.ExecuteNonQuery("UPDATE shifts SET shift_desc=@shift_desc,time_from=@time_from,time_to=@time_to WHERE id=@id",
                                        new SqlCeParameter("@shift_desc", txtShift.Text.ToUpper()),
                                        new SqlCeParameter("@time_from", dtpFrom.Text),
                                        new SqlCeParameter("@time_to", dtpTo.Text),
                                        new SqlCeParameter("@id", txtId.Text.ToString())));
 }
Ejemplo n.º 5
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (btnEdit.Text == "Edit")
            {
                inputStatas(true);
                btnEdit.Text    = "Update";
                btnEdit.Enabled = true;
                btnAdd.Enabled  = false;
                txtName.Focus();
            }
            else
            {
                if (txtName.Text == "")
                {
                    MessageBox.Show("Line description is required!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    txtName.Focus();
                }
                else if (txtTag.Text == "")
                {
                    MessageBox.Show("Line Tag is required!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    txtTag.Focus();
                }
                else
                {
                    DataSet   ds = SqlCEHelper.ExecuteDataTable("SELECT * FROM lines where tag ='" + txtTag.Text.Trim().ToUpper() + "' AND id != '" + txtId.Text.ToString() + "'");
                    DataTable dt = ds.Tables["data"];
                    if (dt.Rows.Count > 0)
                    {
                        MessageBox.Show("Tag description already exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                        txtTag.Focus();
                        txtTag.Text = "";
                    }
                    else
                    {
                        if (updateLine() == 1)
                        {
                            loadGrid();
                            inputStatas(false);
                            btnAdd.Text    = "Add";
                            btnAdd.Enabled = true;
                        }
                        else
                        {
                            MessageBox.Show("Unable to update line", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);;
                        }
                    }

                    loadGrid();
                    inputStatas(false);
                    btnEdit.Text = "Edit";
                }
            }
        }
Ejemplo n.º 6
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to delete this record?", "Delete Line", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

            if (result == DialogResult.OK)
            {
                int retVal = SqlCEHelper.ExecuteNonQuery("DELETE FROM lines where id ='" + txtId.Text + "'");
                if (retVal == 1)
                {
                    loadGrid();
                }
                else
                {
                    MessageBox.Show("Erorr deleting record.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
            }
        }
Ejemplo n.º 7
0
        private void loadGrid()
        {
            DataSet   ds     = SqlCEHelper.ExecuteDataTable("SELECT * FROM lines");
            DataTable dtable = ds.Tables["data"];

            bs.DataSource = dtable;
            if (dtable.Rows.Count > 0)
            {
                btnEdit.Enabled   = true;
                btnDelete.Enabled = true;
            }
            else
            {
                btnEdit.Enabled   = false;
                btnDelete.Enabled = false;
            }
            dgvLine.DataSource = bs;
        }
Ejemplo n.º 8
0
        private int addUser()
        {
            int active;

            if (chkActive.Checked)
            {
                active = 1;
            }
            else
            {
                active = 0;
            }

            string level = cmbLevel.SelectedValue.ToString();

            return(SqlCEHelper.ExecuteNonQuery("INSERT INTO users (name, password, active, level) VALUES(@name, @password, @active, @level)",
                                               new SqlCeParameter("@name", txtName.Text.ToUpper()),
                                               new SqlCeParameter("@password", txtPassword.Text),
                                               new SqlCeParameter("@active", active),
                                               new SqlCeParameter("@level", level)));
        }
Ejemplo n.º 9
0
        private void loadGrid()
        {
            DataSet   ds     = SqlCEHelper.ExecuteDataTable("SELECT * FROM users where level > 1");
            DataTable dtable = ds.Tables["data"];

            dtable.Columns.Add("status", typeof(String));
            dtable.Columns.Add("level_desc", typeof(String));
            foreach (DataRow dr in dtable.Rows)
            {
                if (dr["active"].ToString() == "1")
                {
                    dr["status"] = "ACTIVE";
                }
                else
                {
                    dr["status"] = "IN-ACTIVE";
                }

                if (dr["level"].ToString() == "2")
                {
                    dr["level_desc"] = "MANAGER";
                }
                if (dr["level"].ToString() == "3")
                {
                    dr["level_desc"] = "OPERATOR";
                }
            }
            bs.DataSource = dtable;
            if (dtable.Rows.Count > 0)
            {
                btnEdit.Enabled   = true;
                btnDelete.Enabled = true;
            }
            else
            {
                btnEdit.Enabled   = false;
                btnDelete.Enabled = false;
            }
            dgvUser.DataSource = bs;
        }
Ejemplo n.º 10
0
        private int updateUser()
        {
            int active;

            if (chkActive.Checked)
            {
                active = 1;
            }
            else
            {
                active = 0;
            }

            string level = cmbLevel.SelectedValue.ToString();

            return(SqlCEHelper.ExecuteNonQuery("UPDATE users SET name=@name,password=@password,active=@active,level=@level WHERE id=@id",
                                               new SqlCeParameter("@name", txtName.Text.ToUpper()),
                                               new SqlCeParameter("@password", txtPassword.Text),
                                               new SqlCeParameter("@active", active),
                                               new SqlCeParameter("@level", level),
                                               new SqlCeParameter("@id", txtId.Text.ToString())));
        }
Ejemplo n.º 11
0
        public void loadGrid()
        {
            DataSet ds = SqlCEHelper.ExecuteDataTable("SELECT schedules.id, schedules.sku, schedules.target, " +
                                                      "lines.line, shifts.shift_desc, schedules.run_date " +
                                                      "FROM schedules " +
                                                      "INNER JOIN lines ON schedules.id = lines.id " +
                                                      "INNER JOIN shifts ON schedules.id = shifts.id");
            DataTable dtable = ds.Tables["data"];

            bs.DataSource = dtable;
            if (dtable.Rows.Count > 0)
            {
                btnEdit.Enabled   = true;
                btnDelete.Enabled = true;
            }
            else
            {
                btnEdit.Enabled   = false;
                btnDelete.Enabled = false;
            }
            dgvSchedule.DataSource = bs;
        }
Ejemplo n.º 12
0
 private int addLine()
 {
     return(SqlCEHelper.ExecuteNonQuery("INSERT INTO lines (line, tag) VALUES(@line, @tag)",
                                        new SqlCeParameter("@line", txtName.Text.ToUpper()),
                                        new SqlCeParameter("@tag", txtTag.Text)));
 }