Example #1
0
        private void gxAddEdit1_AddClick(object sender, EventArgs e)
        {
            //if (gxGiaoDanList1.CurrentRow == null || (gxGiaoDanList1.CurrentRow.DataRow as DataRowView) == null) return;
            frmGiaoDan frm = new frmGiaoDan();

cont:
            if (frm is frmGiaoDan)
            {
                if (cbGiaoHo.MaGiaoHo > -1)
                {
                    ((frmGiaoDan)frm).MaGiaoHo = cbGiaoHo.MaGiaoHo;
                }
            }
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.DataReturn != null)
                {
                    DataTable tbl = (DataTable)gxGiaoDanList1.DataSource;
                    if (tbl != null)
                    {
                        tbl.ImportRow(frm.DataReturn);
                        gxGiaoDanList1.FindAll(gxGiaoDanList1.RootTable.Columns[0], Janus.Windows.GridEX.ConditionOperator.Equal, frm.DataReturn[GiaoDanConst.MaGiaoDan]);
                        frm = new frmGiaoDan();
                        goto cont;
                    }
                }
            }
        }
Example #2
0
        private void gxAddEdit1_AddClick(object sender, EventArgs e)
        {
            //if (gxGiaoDanList1.CurrentRow == null || (gxGiaoDanList1.CurrentRow.DataRow as DataRowView) == null) return;
            frmGiaoDan frm = new frmGiaoDan();

cont:
            if (frm is frmGiaoDan)
            {
                if (cbGiaoHo.MaGiaoHo > -1)
                {
                    ((frmGiaoDan)frm).MaGiaoHo = cbGiaoHo.MaGiaoHo;
                }
            }
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.DataReturn != null)
                {
                    DataTable tbl = (DataTable)gxGiaoDanList1.DataSource;
                    if (tbl != null)
                    {
                        tbl.ImportRow(frm.DataReturn);
                        frm = new frmGiaoDan();
                        goto cont;
                    }
                }
            }
        }
Example #3
0
        private void gxAddEdit2_AddClick(object sender, EventArgs e)
        {
            frmGiaoDan frm = new frmGiaoDan();

            bool rs = addGiaoLyVien(frm, true);

            if (rs)
            {
                gxGiaoLyVien1.Row = gxGiaoLyVien1.RowCount - 1;
            }
        }
Example #4
0
        private void gxAddEdit1_AddClick(object sender, EventArgs e)
        {
            frmGiaoDan frm = new frmGiaoDan();

            bool rs = addGiaoDan(frm, true);

            if (rs)
            {
                gxHocSinhList1.Row = gxHocSinhList1.RowCount - 1;
            }
        }
Example #5
0
        private void gxAddEdit1_AddClick(object sender, EventArgs e)
        {
            frmGiaoDan frm = new frmGiaoDan();

            addGiaoDan(frm);
        }
Example #6
0
        private bool addGiaoLyVien(frmBase frm, bool isAdd)
        {
cont:
            if (frm is frmGiaoDan)
            {
                ((frmGiaoDan)frm).FromGiaDinhForm = true;
            }
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.DataReturn != null)
                {
                    DataTable tbl = (DataTable)gxGiaoLyVien1.DataSource;
                    if (tbl != null)
                    {
                        int maGiaoDan = (int)frm.DataReturn[GiaoDanConst.MaGiaoDan];


                        //check ton tai trong danh sac
                        DataRow[] rows = tbl.Select("MaGiaoDan=" + maGiaoDan.ToString());
                        if (rows != null && rows.Length > 0)
                        {
                            MessageBox.Show("Giáo lý viên này đã tồn tại trong danh sách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }

                        //frm.DataReturn.AcceptChanges();
                        //frm.DataReturn.SetAdded();
                        tbl.ImportRow(frm.DataReturn);
                        DataRow drGLV = tblGiaoLyVien.NewRow();
                        if (operation == GxOperation.ADD)
                        {
                            drGLV["MaLop"] = Memory.Instance.GetNextId("LopGiaoLy", "malop", true);
                        }
                        else
                        {
                            drGLV["MaLop"] = id;
                        }

                        drGLV["MaGiaoDan"] = maGiaoDan;
                        tblGiaoLyVien.Rows.Add(drGLV);
                        gxGiaoLyVien1.Row = gxGiaoLyVien1.RowCount - 1;

                        if (isAdd)
                        {
                            frm = new frmGiaoDan();
                            goto cont;
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }
Example #7
0
        private bool addGiaoDan(frmBase frm, bool isAdd)
        {
cont:
            if (frm is frmGiaoDan)
            {
                ((frmGiaoDan)frm).FromGiaDinhForm = true;
            }
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.DataReturn != null)
                {
                    DataTable tbl = (DataTable)gxHocSinhList1.DataSource;
                    if (tbl != null)
                    {
                        int maGiaoDan = (int)frm.DataReturn[GiaoDanConst.MaGiaoDan];


                        //check ton tai trong danh sac
                        DataRow[] rows = tbl.Select("MaGiaoDan=" + maGiaoDan.ToString());
                        if (rows != null && rows.Length > 0)
                        {
                            MessageBox.Show("Giáo dân này đã tồn tại trong danh sách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }

                        //check da thuoc ve lop giao ly nao chua
                        DataTable tblCheck = Memory.GetData("select * from ChiTietLopGiaoLy where MaGiaoDan = ? and MaLop in (select MaLop from LopGiaoLy where MaKhoi = ?)", new object[] { maGiaoDan, idKhoi });
                        if (Memory.ShowError())
                        {
                            return(false);
                        }
                        if (tblCheck != null && tblCheck.Rows.Count > 0)
                        {
                            //string tenGiaDinh = tblCheck.Rows[0][GiaDinhConst.TenGiaDinh].ToString();
                            MessageBox.Show("Giáo dân này đã thuộc về lớp khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }

                        frm.DataReturn.AcceptChanges();
                        frm.DataReturn.SetAdded();
                        frm.DataReturn.Table.Columns.Add("HoanThanh", System.Type.GetType("System.Boolean"));
                        frm.DataReturn.Table.Columns.Add("GhiChuGLy", System.Type.GetType("System.String"));
                        frm.DataReturn.Table.Columns.Add("SoThuTu", System.Type.GetType("System.Int32"));
                        frm.DataReturn["HoanThanh"] = false;
                        frm.DataReturn["GhiChuGLy"] = "";
                        frm.DataReturn["SoThuTu"]   = getNextSoThuTu();
                        tbl.ImportRow(frm.DataReturn);
                        //DataRow drHS = tblHocSinh.NewRow();
                        //drHS["MaLop"] = id;
                        //drHS["MaGiaoDan"] = maGiaoDan;
                        //drHS["SoThuTu"] = frm.DataReturn["SoThuTu"];
                        //drHS["HoanThanh"] = false;
                        //drHS["GhiChuGLy"] = "";
                        //tblHocSinh.Rows.Add(drHS);
                        gxHocSinhList1.Row = gxHocSinhList1.RowCount - 1;

                        if (isAdd)
                        {
                            frm = new frmGiaoDan();
                            goto cont;
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }
Example #8
0
        private bool addGiaoDan(frmBase frm, bool isAdd)
        {
cont:
            if (frm is frmGiaoDan)
            {
                ((frmGiaoDan)frm).MaGiaoHo        = MaGiaoHo;
                ((frmGiaoDan)frm).FromGiaDinhForm = true;
            }
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.DataReturn != null)
                {
                    DataTable tbl = (DataTable)gxGiaoDanList1.DataSource;
                    if (tbl != null)
                    {
                        int maGiaoDan = (int)frm.DataReturn[GiaoDanConst.MaGiaoDan];
                        if (maGiaoDan == txtNguoiChong.MaGiaoDan || maGiaoDan == txtNguoiVo.MaGiaoDan)
                        {
                            MessageBox.Show("Giáo dân này đã có trong gia đình", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }

                        //check ton tai trong danh sac
                        DataRow[] rows = tbl.Select("MaGiaoDan=" + maGiaoDan.ToString());
                        if (rows != null && rows.Length > 0)
                        {
                            MessageBox.Show("Giáo dân này đã tồn tại trong danh sách thành viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }

                        //check da thuoc gia dinh nao chua
                        DataTable tblCheck = Memory.GetData(SqlConstants.SELECT_THANHVIEN_GIADINH_LIST + " AND MaGiaoDan = ? AND VaiTro>1", new object[] { maGiaoDan });
                        if (Memory.ShowError())
                        {
                            return(false);
                        }
                        if (tblCheck != null && tblCheck.Rows.Count > 0)
                        {
                            string tenGiaDinh = tblCheck.Rows[0][GiaDinhConst.TenGiaDinh].ToString();
                            MessageBox.Show("Giáo dân này đã thuộc về gia đình [" + tenGiaDinh + "].\r\nBạn có thể sử dụng chức năng [tìm gia đình của giáo dân] để biết giáo dân này đã thuộc về những gia đình nào.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }

                        frm.DataReturn.Table.Columns.Add(GiaDinhConst.MaGiaDinh, typeof(int));
                        frm.DataReturn.Table.Columns.Add(ThanhVienGiaDinhConst.VaiTro, typeof(int));
                        frm.DataReturn[ThanhVienGiaDinhConst.VaiTro] = 2;
                        frm.DataReturn.AcceptChanges();
                        frm.DataReturn.SetAdded();
                        tbl.ImportRow(frm.DataReturn);

                        gxGiaoDanList1.Row = gxGiaoDanList1.RowCount - 1;
                        if (Memory.IsRedGiaoDan(frm.DataReturn))
                        {
                            gxGiaoDanList1.CurrentRow.RowStyle = new GridEXFormatStyle();
                            gxGiaoDanList1.CurrentRow.RowStyle.FontStrikeout = TriState.True;
                            gxGiaoDanList1.CurrentRow.RowStyle.ForeColor     = Color.Red;
                        }

                        if (isAdd)
                        {
                            frm = new frmGiaoDan();
                            goto cont;
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }