コード例 #1
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";
                }
            }
        }
コード例 #2
0
ファイル: frmLine.cs プロジェクト: renciebautista/andon
        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";
                }
            }
        }
コード例 #3
0
ファイル: frmLine.cs プロジェクト: renciebautista/andon
        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;
        }
コード例 #4
0
ファイル: frmUser.cs プロジェクト: renciebautista/andon
        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;
        }
コード例 #5
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;
        }