Exemple #1
0
        private void btnAddChEng_Click(object sender, EventArgs e)
        {
            //Add new Chief Engineer
            ChEngDetailsForm chForm = new ChEngDetailsForm(connection, DS, this.Font, this.Icon, MainForm.zeroGuid);

            chForm.chengName       = "";
            chForm.chengPersonalID = "";
            chForm.chengNotes      = "";

            var rslt = chForm.ShowDialog();

            if (rslt == DialogResult.OK)
            {
                if (ChEngExists(chForm.chengName, MainForm.zeroGuid))
                {
                    return;
                }

                OleDbCommand cmd = new OleDbCommand("", connection);

                cmd.CommandText =
                    "insert into CHIEF_ENGINEERS (CHENG_NAME,PERSONAL_ID,CHENG_NOTES) \n" +
                    "values('" + MainForm.StrToSQLStr(chForm.chengName) + "','" +
                    MainForm.StrToSQLStr(chForm.chengPersonalID) + "','" +
                    MainForm.StrToSQLStr(chForm.chengNotes) + "')";
                MainForm.cmdExecute(cmd);

                fillChiefEngineers();
            }
        }
Exemple #2
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            //Add new chief engineer

            ChEngDetailsForm chForm = new ChEngDetailsForm(connection, DS, this.Font, this.Icon, MainForm.zeroGuid);

            chForm.chengName       = "";
            chForm.chengPersonalID = "";
            chForm.chengNotes      = "";

            var rslt = chForm.ShowDialog();

            if (rslt == DialogResult.OK)
            {
                if (checkSameName(chForm.chengName, MainForm.zeroGuid) != 0)
                {
                    return;
                }

                if (checkSameID(chForm.chengPersonalID, MainForm.zeroGuid) != 0)
                {
                    return;
                }

                OleDbCommand cmd = new OleDbCommand("", connection);

                cmd.CommandText =
                    "insert into CHIEF_ENGINEERS (CHENG_NAME,PERSONAL_ID,CHENG_NOTES) \n" +
                    "values('" + chForm.chengName + "','" + chForm.chengPersonalID + "','" + chForm.chengNotes + "')";
                cmd.ExecuteNonQuery();


                fillChiefEngineers();

                String searchValue = chForm.chengName;

                int rowIndex = -1;

                foreach (DataGridViewRow dgRow in adgvChEngineers.Rows)
                {
                    if (dgRow.Cells["CHENG_NAME"].Value.ToString().Equals(searchValue))
                    {
                        rowIndex = dgRow.Index;
                        break;
                    }
                }

                if (rowIndex >= 0)
                {
                    //dataGridView1.Rows[rowIndex].Selected = true;
                    adgvChEngineers.CurrentCell = adgvChEngineers[1, rowIndex];
                }
            }
        }
Exemple #3
0
        private void editChEng()
        {
            //Edit Chief Engineers

            if (adgvChEngineers.Rows.Count == 0)
            {
                return;
            }

            int  curRow     = adgvChEngineers.CurrentCell.RowIndex;
            int  curCol     = adgvChEngineers.CurrentCell.ColumnIndex;
            int  visibleRow = adgvChEngineers.FirstDisplayedCell.RowIndex;
            Guid chengGuid  = MainForm.StrToGuid(adgvChEngineers.CurrentRow.Cells["CHENG_GUID"].Value.ToString());

            ChEngDetailsForm chForm = new ChEngDetailsForm(connection, DS, this.Font, this.Icon, chengGuid);

            chForm.chengName       = adgvChEngineers.CurrentRow.Cells["CHENG_NAME"].Value.ToString();
            chForm.chengPersonalID = adgvChEngineers.CurrentRow.Cells["PERSONAL_ID"].Value.ToString();
            chForm.chengNotes      = adgvChEngineers.CurrentRow.Cells["CHENG_NOTES"].Value.ToString();

            var rslt = chForm.ShowDialog();

            if ((rslt == DialogResult.OK) && (MainForm.isPowerUser))
            {
                if (checkSameName(chForm.chengName, chengGuid) != 0)
                {
                    return;
                }

                if (checkSameID(chForm.chengPersonalID, chengGuid) != 0)
                {
                    return;
                }

                OleDbCommand cmd = new OleDbCommand("", connection);

                cmd.CommandText =
                    "update CHIEF_ENGINEERS set \n" +
                    "CHENG_NAME='" + StrToSQLStr(chForm.chengName) + "', \n" +
                    "PERSONAL_ID='" + StrToSQLStr(chForm.chengPersonalID) + "', \n" +
                    "CHENG_NOTES='" + StrToSQLStr(chForm.chengNotes) + "' \n" +
                    "where CHENG_GUID=" + MainForm.GuidToStr(chengGuid);
                cmd.ExecuteNonQuery();
            }

            fillChiefEngineers();

            adgvChEngineers.FirstDisplayedScrollingRowIndex = visibleRow;

            adgvChEngineers.CurrentCell = adgvChEngineers[curCol, curRow];
        }
Exemple #4
0
        private void btnEditChEng_Click(object sender, EventArgs e)
        {
            //Edit Chief Engineer
            if (cbChEngName.SelectedValue == null)
            {
                MessageBox.Show("You can edit just registered chief engineer", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Guid chengGuid = MainForm.StrToGuid(cbChEngName.SelectedValue.ToString());

            ChEngDetailsForm chForm = new ChEngDetailsForm(connection, DS, this.Font, this.Icon, chengGuid);

            OleDbCommand cmd = new OleDbCommand("", connection);

            cmd.CommandText =
                "select * \n" +
                "from CHIEF_ENGINEERS \n" +
                "where CHENG_GUID=" + MainForm.GuidToStr(chengGuid);

            OleDbDataReader reader = cmd.ExecuteReader();

            if (!reader.HasRows)
            {
                MessageBox.Show("Chief Engineer with GUID=" + chengGuid.ToString() + " was not found in database", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                reader.Close();

                return;
            }

            reader.Read();

            chForm.chengName       = reader["CHENG_NAME"].ToString();
            chForm.chengPersonalID = reader["PERSONAL_ID"].ToString();
            chForm.chengNotes      = reader["CHENG_NOTES"].ToString();

            reader.Close();

            var rslt = chForm.ShowDialog();

            if ((rslt == DialogResult.OK) && (MainForm.isPowerUser))
            {
                if (ChEngExists(chForm.chengName, chengGuid))
                {
                    MessageBox.Show("There is a recor for Chief Engineer with the same name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                cmd.CommandText =
                    "update CHIEF_ENGINEERS set \n" +
                    "CHENG_NAME='" + MainForm.StrToSQLStr(chForm.chengName) + "', \n" +
                    "PERSONAL_ID='" + MainForm.StrToSQLStr(chForm.chengPersonalID) + "', \n" +
                    "CHENG_NOTES='" + MainForm.StrToSQLStr(chForm.chengNotes) + "' \n" +
                    "where CHENG_GUID=" + MainForm.GuidToStr(chengGuid);
                MainForm.cmdExecute(cmd);
            }

            fillChiefEngineers();

            cbChEngName.Text = chForm.chengName;
        }