Exemplo n.º 1
0
        private void dgv_orgType_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int i  = dgv_orgType.CurrentRow.Index;
            int id = int.Parse(dgv_orgType.Rows[i].Cells["ID"].Value.ToString());

            iMain = DBAccess.get_institutinMain(id);

            if (iMain != null)
            {
                try
                {
                    txtID.Text        = iMain.Id.ToString();
                    txtTitle.Text     = iMain.Name;
                    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");
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (lblerror1.Visible == true)
                {
                    MessageBox.Show("Institution Main type 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
                {
                    iMain = new institutionTypeMain(txtTitle.Text);

                    DBAccess.insert_institution_Main(iMain);

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

                    MessageBox.Show("Successfully Added!", "", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    dgv_orgType.DataSource = DBAccess.dataTableLoad("sp_load_institution_type");
                    btnUpdate.Visible      = true;
                    btnAdd.Visible         = true;
                    btnUpdate.Visible      = true;
                    btnSave.Visible        = false;
                    btnCancel.Visible      = false;
                    dgv_orgType.Enabled    = true;

                    clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 3
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)
                {
                    MessageBox.Show("Please input Insitution type!", "", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else
                {
                    iMain = new institutionTypeMain(int.Parse(txtID.Text), txtTitle.Text);
                    DBAccess.update_institution_Main(iMain);

                    dgv_orgType.DataSource = DBAccess.dataTableLoad("sp_load_institution_type");

                    logs = new auditTrail(frm_login.UserName, "Updated Organization type 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);
            }


            // clear();
        }