Ejemplo n.º 1
0
        private void btn_Them_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Thêm Tỉnh / Thành phố?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (!string.IsNullOrWhiteSpace(txt_Ten.Text))
                {
                    oTinhTP.TenTinhTP = txt_Ten.Text;
                    oTinhTP.MoTa      = rTB_GhiChu.Text;
                    if (Convert.ToInt32(comB_QuocGia.SelectedValue) != -1)
                    {
                        oTinhTP.QuocGiaID = Convert.ToInt32(comB_QuocGia.SelectedValue);
                    }
                    else
                    {
                        oTinhTP.QuocGiaID = null;
                    }

                    try
                    {
                        int i = oTinhTP.AddWithReturnID();
                        MessageBox.Show("Thao tác thêm thành công.\r\n", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (i != 0) // them thanh cong
                        {
                            switch (UCCallerName)
                            {
                            case "QLNS_ThongTinNV":
                                QLNS.UCs.DanhMucThongTin.QLNS_ThongTinNV.nNewTinhTPID = i;
                                break;

                            case "QLNS_TrinhDo_ChuyenMon":
                                QLNS.UCs.DanhMucThongTin.QLNS_TrinhDo_ChuyenMon.nNewTinhTPID = i;
                                break;

                            case "QLNS_LichSuBanThan":
                                QLNS.UCs.DanhMucThongTin.QLNS_LichSuBanThan.nNewTinhTPID = i;
                                break;

                            case "QLNS_ThongTinNV_Phu":
                                QLNS.UCs.DanhMucThongTin.QLNS_ThongTinNV_Phu.nNewTinhTPID = i;
                                break;

                            case "QLNS_DaoTaoBoiDuong":
                                QLNS.UCs.DanhMucThongTin.QLNS_DaoTaoBoiDuong.nNewTinhTPID = i;
                                break;

                            default:
                                break;
                            }
                            ((Form)this.Parent.Parent).Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Thao tác thêm không thành công.\r\n" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Xin vui lòng điền tên tỉnh thành phố.\r\n", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }