コード例 #1
0
        private void dgv_sub_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int i  = dgv_sub.CurrentRow.Index;
            int id = int.Parse(dgv_sub.Rows[i].Cells["ID"].Value.ToString());

            sub = DBAccess.get_specialization_sub(id);

            if (sub != null)
            {
                try
                {
                    txtID.Text     = sub.Id.ToString();
                    txtTitle.Text  = sub.Name;
                    cmbSector.Text = sub.Sector;
                    txtsec.Text    = sub.Sector;
                    cmbSpec.Text   = sub.Specialization;
                    txtSpec.Text   = sub.Specialization;

                    txtTitle.Enabled  = true;
                    lblerror1.Visible = false;
                    temp_name         = txtTitle.Text.Trim();
                }
                catch (IndexOutOfRangeException ex)
                {
                    MessageBox.Show(ex.Message, "Incomplete Data!", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Null");
            }
        }
コード例 #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtID.Text == string.Empty || txtID.Text == "(Auto Generated)")
                {
                    MessageBox.Show("Please select user to update!", "", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else if (txtTitle.Text == string.Empty.Trim())
                {
                    MessageBox.Show("Please input specilization!", "", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else if (lblerror1.Visible == true)
                {
                    MessageBox.Show("Specialization sub Title is already in use!", "", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else
                {
                    int sector = DBAccess.get_cmb_data(cmbSector.Text, "sp_get_cmb_sector", "sector_id");
                    int spec   = DBAccess.get_cmb_data(cmbSpec.Text, "sp_get_cmb_specialization", "specialization_id");
                    if (cmbSpec.Text == string.Empty)
                    {
                        spec = 106;
                    }
                    else
                    {
                        spec = DBAccess.get_cmb_data(cmbSpec.Text, "sp_get_cmb_specialization", "specialization_id");
                    }

                    sub = new specializationSub(int.Parse(txtID.Text), spec.ToString(), sector.ToString(), txtTitle.Text);
                    DBAccess.update_specialization_sub(sub);

                    dgv_sub.DataSource = DBAccess.dataTableLoad("sp_load_specialization_sub");

                    logs = new auditTrail(frm_login.UserName, "Updated Specialization sub id " + txtID.Text);
                    DBAccess.insert_logs(logs);

                    MessageBox.Show("Successfully Updated!", "", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);


                    clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }
コード例 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (lblerror1.Visible == true)
                {
                    MessageBox.Show("Specialization sub Title is already in use!", "", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else if (txtTitle.Text == string.Empty)
                {
                    MessageBox.Show("Please complete the required data!", "", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else
                {
                    int sector = DBAccess.get_cmb_data(cmbSector.Text, "sp_get_cmb_sector", "sector_id");
                    int spec   = DBAccess.get_cmb_data(cmbSpec.Text, "sp_get_cmb_specialization", "specialization_id");
                    if (cmbSpec.Text == string.Empty)
                    {
                        spec = 106;
                    }
                    else
                    {
                        spec = DBAccess.get_cmb_data(cmbSpec.Text, "sp_get_cmb_specialization", "specialization_id");
                    }

                    sub = new specializationSub(spec.ToString(), sector.ToString(), txtTitle.Text);
                    DBAccess.insert_specialization_sub(sub);

                    dgv_sub.DataSource = DBAccess.dataTableLoad("sp_load_specialization_sub");

                    logs = new auditTrail(frm_login.UserName, "Added a Specialization sub ");
                    DBAccess.insert_logs(logs);

                    MessageBox.Show("Successfully Added!", "", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);

                    clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }