Ejemplo n.º 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            //Add new master

            CrewDetailsForm form = new CrewDetailsForm();

            var rslt = form.ShowDialog();

            if (rslt == DialogResult.OK)
            {
                fillMasters();

                String searchValue = form.crewName;

                int rowIndex = -1;

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

                if (rowIndex >= 0)
                {
                    adgvMasters.CurrentCell = adgvMasters[1, rowIndex];
                }
            }
        }
Ejemplo n.º 2
0
        private void editMaster()
        {
            if (adgvMasters.Rows.Count == 0)
            {
                return;
            }

            Guid crewGuid = MainForm.StrToGuid(adgvMasters.CurrentRow.Cells["CREW_GUID"].Value.ToString());

            CrewDetailsForm form = new CrewDetailsForm();

            form.crewGuid = crewGuid;

            var rslt = form.ShowDialog();

            if (rslt == DialogResult.OK)
            {
                if (form.wasChanged)
                {
                    int visibleRow = adgvMasters.FirstDisplayedScrollingRowIndex;
                    int curRow     = adgvMasters.CurrentCell.RowIndex;
                    int curCol     = adgvMasters.CurrentCell.ColumnIndex;

                    fillMasters();

                    adgvMasters.FirstDisplayedScrollingRowIndex = visibleRow;

                    adgvMasters.CurrentCell = adgvMasters[curCol, curRow];
                }
            }
        }
Ejemplo n.º 3
0
        private void btnAddMaster_Click(object sender, EventArgs e)
        {
            //Add new master

            CrewDetailsForm form = new CrewDetailsForm();

            var rslt = form.ShowDialog();

            if (rslt == DialogResult.OK)
            {
                fillMasters();
            }
        }
Ejemplo n.º 4
0
        private void btnEditMaster_Click(object sender, EventArgs e)
        {
            //Edit master

            if (cbMasterName.SelectedValue == null)
            {
                MessageBox.Show("You are able to edit just registered master record", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Guid masterGuid = MainForm.StrToGuid(cbMasterName.SelectedValue.ToString());

            CrewDetailsForm form = new CrewDetailsForm();

            form.crewGuid = masterGuid;

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

            cmd.CommandText =
                "select * \n" +
                "from CREW \n" +
                "where CREW_GUID=" + MainForm.GuidToStr(masterGuid);

            OleDbDataReader reader = cmd.ExecuteReader();

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

            reader.Close();

            var rslt = form.ShowDialog();

            if (rslt == DialogResult.OK)
            {
                if (form.wasChanged)
                {
                    fillMasters();

                    cbMasterName.Text = form.crewName;
                }
            }
        }
Ejemplo n.º 5
0
        private void btnInfo_Click(object sender, EventArgs e)
        {
            if (!CheckCrewExists())
            {
                MessageBox.Show("Unable to show details for \"" + cbCrewmember.Text + "\"", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

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

            //Проверяем наличие имени в списке

            cmd.CommandText =
                "select Count(CREW_GUID) \n" +
                "from CREW \n" +
                "where \n" +
                "CREW_NAME like '" + MainForm.StrToSQLStr(cbCrewmember.Text) + "' \n" +
                "and CREW_POSITION_GUID=" + MainForm.GuidToStr(_positionGuid);

            int recCount = (int)cmd.ExecuteScalar();

            if (recCount == 0)
            {
                return;
            }

            if (_crewGuid == MainForm.zeroGuid)
            {
                if (recCount == 1)
                {
                    cmd.CommandText =
                        "select CREW_GUID \n" +
                        "from CREW \n" +
                        "where \n" +
                        "CREW_NAME like '" + MainForm.StrToSQLStr(cbCrewmember.Text) + "' \n" +
                        "and CREW_POSITION_GUID=" + MainForm.GuidToStr(_positionGuid);

                    object x = cmd.ExecuteScalar();

                    try
                    {
                        _crewGuid = (Guid)x;
                    }
                    catch
                    {
                        MessageBox.Show("Unable to get crewmember GUID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    FormSelectCrewmemberFromList form = new FormSelectCrewmemberFromList();

                    form.crewmemberName = cbCrewmember.Text;
                    form.positionGuid   = _positionGuid;

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                    }
                }
            }

            if (cbCrewmember.SelectedValue.ToString().Length > 0)
            {
                this.Cursor = Cursors.WaitCursor;

                CrewDetailsForm form = new CrewDetailsForm();

                //form.positionGuid = _positionGuid;

                form.crewGuid = MainForm.StrToGuid(cbCrewmember.SelectedValue.ToString());
                //form.crewmemberName = cbCrewmember.Text;

                var rslt = form.ShowDialog();

                if (rslt == DialogResult.OK)
                {
                    FillCrewmembers(_positionGuid);

                    //Записываем имя в поле
                    cbCrewmember.Text = form.crewName;
                }

                this.Cursor = Cursors.Default;
            }
        }