Beispiel #1
0
        public void XuatChungNhanBiTich()
        {
            if (this.CurrentRow == null || (this.CurrentRow.DataRow as DataRowView) == null)
            {
                return;
            }
            DataRow row = (this.CurrentRow.DataRow as DataRowView).Row;

            GetDataChungNhanBiTich((int)row[GiaoDanConst.MaGiaoDan]);
            frmGoiChungNhan frm = new frmGoiChungNhan();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                ds.Tables.Add(frm.GetTableNguoiNhan());
                int rs = ExcelReport.ReportChungNhanBT.Export(ds);
                Memory.ShowError();
            }
        }
Beispiel #2
0
        public static int ChungNhanHonPhoi(int maGiaDinh, bool isMaGiaDinh)
        {
            DataSet DataObj = new DataSet();
            //Get GiaoXu info
            DataTable tblGiaoXu = Memory.GetData(SqlConstants.SELECT_GIAOXU);

            if (Memory.ShowError())
            {
                return(-1);
            }
            if (tblGiaoXu == null || tblGiaoXu.Rows.Count == 0)
            {
                MessageBox.Show("Không tìm thấy thông tin giáo xứ. Vui lòng nhập thông tin giáo xứ trước khi sử dụng chức năng này.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(-1);
            }
            frmGoiChungNhan frm = new frmGoiChungNhan();

            if (frm.ShowDialog() != DialogResult.OK)
            {
                return(0);
            }
            DataObj.Tables.Add(frm.GetTableNguoiNhan());
            tblGiaoXu.TableName = GiaoXuConst.TableName;
            DataObj.Tables.Add(tblGiaoXu);

            if (isMaGiaDinh)
            {
                //Get GiaDinh info
                DataTable tblGiaDinh = Memory.GetData(string.Format(SqlConstants.SELECT_GIADINH_GIAODAN, " WHERE GiaDinh.MaGiaDinh=? AND (VaiTro=0 OR VaiTro=1)"), new object[] { maGiaDinh });
                //DataTable tblGiaDinh = Memory.GetTable(GiaDinhConst.TableName, string.Format(" AND MaGiaDinh={0}", maGiaDinh));
                if (Memory.ShowError())
                {
                    return(-1);
                }

                if (tblGiaDinh == null || tblGiaDinh.Rows.Count == 0)
                {
                    MessageBox.Show("Không lấy được thông tin gia đình.\r\nXuất chứng nhận thất bại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(-1);
                }

                if (Memory.IsNullOrEmpty(tblGiaDinh.Rows[0][GiaDinhConst.TenChong]) || Memory.IsNullOrEmpty(tblGiaDinh.Rows[0][GiaDinhConst.TenVo]))
                {
                    MessageBox.Show("Gia đình được chọn không có đầy đủ thông tin vợ chồng nên không thể xuất chứng nhận hôn phối.\r\nXin vui lòng xem lại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(-1);
                }
                tblGiaDinh.TableName = GiaDinhConst.TableName;
                DataObj.Tables.Add(tblGiaDinh);
            }
            else
            {
                //Get GiaDinh info
                DataTable tblGiaDinh = Memory.GetData("SELECT * FROM HonPhoi WHERE MaHonPhoi=?", new object[] { maGiaDinh });
                if (Memory.ShowError())
                {
                    return(-1);
                }

                if (tblGiaDinh == null || tblGiaDinh.Rows.Count == 0)
                {
                    MessageBox.Show("Không lấy được thông tin hôn phối.\r\nXuất chứng nhận thất bại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(-1);
                }

                tblGiaDinh.TableName = GiaDinhConst.TableName;
                DataObj.Tables.Add(tblGiaDinh);
            }

            //Get Chong + Vo Info
            DataTable tblVoChong = null;

            if (isMaGiaDinh)
            {
                tblVoChong = Memory.GetData(SqlConstants.SELECT_VOCHONG_THEO_MAGIADINH, new object[] { maGiaDinh });
                if (Memory.ShowError() || tblVoChong == null || tblVoChong.Rows.Count <= 1)
                {
                    MessageBox.Show("Không lấy được thông tin vợ chồng.\r\nXuất chứng nhận thất bại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(-1);
                }
            }
            else
            {
                tblVoChong = Memory.GetData(SqlConstants.SELECT_VOCHONG_THEO_HONPHOI, new object[] { maGiaDinh });
                if (Memory.ShowError() || tblVoChong == null || tblVoChong.Rows.Count <= 1)
                {
                    MessageBox.Show("Không lấy được thông tin vợ chồng.\r\nXuất chứng nhận thất bại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(-1);
                }
            }
            //Make main report data
            DataTable tblThongtinVoChong = new DataTable();

            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.HoTenNam);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.HoTenNu);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.NgaySinhNam);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.NgaySinhNu);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.NgayThangNamHP);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.NhanChung);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.NoiSinhNam);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.NoiSinhNu);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.TenChaNam);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.TenChaNu);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.TenLinhMucGui);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.TenMeNam);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.TenMeNu);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.GiaoXuNam);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.GiaoPhanNam);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.GiaoXuNu);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.GiaoPhanNu);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.NgayRuaToiNam);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.SoRuaToiNam);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.NgayRuaToiNu);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.SoRuaToiNu);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.NoiRuaToiNu);
            tblThongtinVoChong.Columns.Add(ReportChungNhanHPConst.NoiRuaToiNam);
            //honp hoi
            tblThongtinVoChong.Columns.Add(HonPhoiConst.SoHonPhoi);
            tblThongtinVoChong.Columns.Add(HonPhoiConst.LinhMucChung);
            tblThongtinVoChong.Columns.Add(HonPhoiConst.NoiHonPhoi);
            tblThongtinVoChong.Columns.Add(HonPhoiConst.NguoiChung1);
            tblThongtinVoChong.Columns.Add(HonPhoiConst.NguoiChung2);
            DataRow row = tblThongtinVoChong.NewRow();

            //Get thong tin chong
            DataRow[] rowCheck = null;
            if (isMaGiaDinh)
            {
                rowCheck = tblVoChong.Select("VaiTro=" + GxConstants.VAITRO_CHONG);
            }
            else
            {
                rowCheck = tblVoChong.Select(string.Format("Phai='{0}'", GxConstants.NAM));
            }
            int maChong = 0;

            if (rowCheck != null && rowCheck.Length > 0)
            {
                maChong = (int)rowCheck[0][GiaoDanConst.MaGiaoDan];
                row[ReportChungNhanHPConst.HoTenNam]      = rowCheck[0][GiaoDanConst.TenThanh].ToString() + " " + rowCheck[0][GiaoDanConst.HoTen].ToString();
                row[ReportChungNhanHPConst.NgaySinhNam]   = rowCheck[0][GiaoDanConst.NgaySinh];
                row[ReportChungNhanHPConst.NoiSinhNam]    = rowCheck[0][GiaoDanConst.NoiSinh];
                row[ReportChungNhanHPConst.NgayRuaToiNam] = rowCheck[0][GiaoDanConst.NgayRuaToi];
                row[ReportChungNhanHPConst.SoRuaToiNam]   = rowCheck[0][GiaoDanConst.SoRuaToi];
                row[ReportChungNhanHPConst.NoiRuaToiNam]  = rowCheck[0][GiaoDanConst.NoiRuaToi];
                //Get Cha Me Info
                Dictionary <object, object> dicChaMe = GetTenChaMe((int)rowCheck[0][GiaoDanConst.MaGiaoDan],
                                                                   rowCheck[0][GiaoDanConst.HoTenCha],
                                                                   rowCheck[0][GiaoDanConst.HoTenMe]);
                row[ReportChungNhanHPConst.TenChaNam] = dicChaMe[GxConstants.VAITRO_CHONG];
                row[ReportChungNhanHPConst.TenMeNam]  = dicChaMe[GxConstants.VAITRO_VO];
                row[ReportChungNhanHPConst.GiaoXuNam] = Memory.GetThuocXu(rowCheck[0]);
                if (Memory.IsNullOrEmpty(row[ReportChungNhanHPConst.GiaoXuNam]))
                {
                    row[ReportChungNhanHPConst.GiaoXuNam] = row[ReportChungNhanHPConst.NoiRuaToiNam];
                }
                row[ReportChungNhanHPConst.GiaoPhanNam] = ((int)rowCheck[0][GiaoDanConst.MaGiaoHo] != 0 && tblGiaoXu.Rows.Count > 0 ? tblGiaoXu.Rows[0][GiaoPhanConst.TenGiaoPhan] : rowCheck[0][GiaoDanConst.ThuocGiaoPhan]);
            }
            //Get thong tin vo
            int maVo = 0;

            if (isMaGiaDinh)
            {
                rowCheck = tblVoChong.Select("VaiTro=" + GxConstants.VAITRO_VO);
            }
            else
            {
                rowCheck = tblVoChong.Select(string.Format("Phai='{0}'", GxConstants.NU));
            }
            if (rowCheck != null && rowCheck.Length > 0)
            {
                maVo = (int)rowCheck[0][GiaoDanConst.MaGiaoDan];
                row[ReportChungNhanHPConst.HoTenNu]      = rowCheck[0][GiaoDanConst.TenThanh].ToString() + " " + rowCheck[0][GiaoDanConst.HoTen];
                row[ReportChungNhanHPConst.NgaySinhNu]   = rowCheck[0][GiaoDanConst.NgaySinh];
                row[ReportChungNhanHPConst.NoiSinhNu]    = rowCheck[0][GiaoDanConst.NoiSinh];
                row[ReportChungNhanHPConst.NgayRuaToiNu] = rowCheck[0][GiaoDanConst.NgayRuaToi];
                row[ReportChungNhanHPConst.SoRuaToiNu]   = rowCheck[0][GiaoDanConst.SoRuaToi];
                row[ReportChungNhanHPConst.NoiRuaToiNu]  = rowCheck[0][GiaoDanConst.NoiRuaToi];
                //Get Cha Me Info
                Dictionary <object, object> dicChaMe = GetTenChaMe((int)rowCheck[0][GiaoDanConst.MaGiaoDan],
                                                                   rowCheck[0][GiaoDanConst.HoTenCha],
                                                                   rowCheck[0][GiaoDanConst.HoTenMe]);
                row[ReportChungNhanHPConst.TenChaNu] = dicChaMe[GxConstants.VAITRO_CHONG];
                row[ReportChungNhanHPConst.TenMeNu]  = dicChaMe[GxConstants.VAITRO_VO];
                row[ReportChungNhanHPConst.GiaoXuNu] = Memory.GetThuocXu(rowCheck[0]);
                if (Memory.IsNullOrEmpty(row[ReportChungNhanHPConst.GiaoXuNu]))
                {
                    row[ReportChungNhanHPConst.GiaoXuNu] = row[ReportChungNhanHPConst.NoiRuaToiNu];
                }
                row[ReportChungNhanHPConst.GiaoPhanNu] = ((int)rowCheck[0][GiaoDanConst.MaGiaoHo] != 0 && tblGiaoXu.Rows.Count > 0 ? tblGiaoXu.Rows[0][GiaoPhanConst.TenGiaoPhan] : rowCheck[0][GiaoDanConst.ThuocGiaoPhan]);
            }

            bool coHP = false;

            if (maChong > 0 && maVo > 0)
            {
                DataTable tblHonPhoi = GxHonPhoiGiaDinh.GetHonPhoiTheoVoChong(maVo, maChong);
                if (!Memory.ShowError() && tblHonPhoi != null && tblHonPhoi.Rows.Count > 0)
                {
                    coHP = true;
                    row[ReportChungNhanHPConst.NgayThangNamHP] = tblHonPhoi.Rows[0][HonPhoiConst.NgayHonPhoi];

                    row[HonPhoiConst.SoHonPhoi]    = tblHonPhoi.Rows[0][HonPhoiConst.SoHonPhoi];
                    row[HonPhoiConst.LinhMucChung] = tblHonPhoi.Rows[0][HonPhoiConst.LinhMucChung];
                    row[HonPhoiConst.NoiHonPhoi]   = tblHonPhoi.Rows[0][HonPhoiConst.NoiHonPhoi];
                    row[HonPhoiConst.NguoiChung1]  = tblHonPhoi.Rows[0][HonPhoiConst.NguoiChung1];
                    row[HonPhoiConst.NguoiChung2]  = tblHonPhoi.Rows[0][HonPhoiConst.NguoiChung2];
                }
            }
            if (!coHP)
            {
                Memory.ShowError("Không tìm thấy thông tin hôn phối!");
                return(-1);
            }

            //Get thong tin linh muc
            DataTable tblLinhMuc = Memory.GetData(SqlConstants.SELECT_LINHMUC_LIST + " AND DenNgay IS NULL ");

            if (!Memory.ShowError() && tblLinhMuc != null && tblLinhMuc.Rows.Count > 0)
            {
                row[ReportChungNhanHPConst.TenLinhMucGui] = tblLinhMuc.Rows[0][LinhMucConst.TenThanh].ToString() + " " + tblLinhMuc.Rows[0][LinhMucConst.HoTen].ToString();
            }
            tblThongtinVoChong.Rows.Add(row);
            tblThongtinVoChong.TableName = ReportChungNhanHPConst.TableName;
            DataObj.Tables.Add(tblThongtinVoChong);

            int rs = ExcelReport.ReportChungNhanHP.Export(DataObj);

            Memory.ShowError();
            return(0);
        }