示例#1
0
 private void item8_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.CurrentRow == null || (this.CurrentRow.DataRow as DataRowView) == null)
         {
             return;
         }
         DataRow   row       = (this.CurrentRow.DataRow as DataRowView).Row;
         int       maGiaoDan = (int)row[GiaoDanConst.MaGiaoDan];
         DataTable tblTVGD   = Memory.GetTable(ThanhVienGiaDinhConst.TableName, " AND MaGiaoDan=" + maGiaoDan.ToString());
         if (!Memory.ShowError())
         {
             //neu khong tim thay
             if (tblTVGD.Rows.Count == 0)
             {
                 MessageBox.Show("Giáo dân này không thuộc gia đình nào");
                 return;
             }
             //neu chi co 1 gia dinh thoi thi show gia dinh len luon
             if (tblTVGD.Rows.Count == 1)
             {
                 frmGiaDinh frmGD = new frmGiaDinh();
                 frmGD.Id = (int)tblTVGD.Rows[0][ThanhVienGiaDinhConst.MaGiaDinh];
                 frmGD.AssignControlData();
                 frmGD.Operation = GxOperation.EDIT;
                 frmGD.ShowDialog();
                 return;
             }
             //neu co nhieu hon 1 gia đinh thi show danh sach cho nguoi ta chon
             List <int> lstMaGiaDinh = new List <int>();
             foreach (DataRow rowTV in tblTVGD.Rows)
             {
                 lstMaGiaDinh.Add((int)rowTV[ThanhVienGiaDinhConst.MaGiaDinh]);
             }
             frmXemGiaDinhGiaoDan frmXem = new frmXemGiaDinhGiaoDan();
             frmXem.MaGiaDinhList = lstMaGiaDinh;
             frmXem.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         Memory.ShowError(ex.Message);
     }
 }
示例#2
0
        public virtual void EditRow()
        {
            if (this.CurrentRow == null || (this.CurrentRow.DataRow as DataRowView) == null ||
                (this.CurrentRow.DataRow as DataRowView).Row.RowState == DataRowState.Deleted)
            {
                return;
            }
            frmGiaDinh frm = new frmGiaDinh();

            frm.Operation = Operation;
            DataRow row = (this.CurrentRow.DataRow as DataRowView).Row;

            SetFormData(frm);
            frm.MaGiaoHo = (int)row[GiaDinhConst.MaGiaoHo];
            frm.AssignControlData();
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.DataReturn != null)
                {
                    DataTable tbl = Memory.GetData(string.Concat(SqlConstants.SELECT_GIADINH_LIST, " AND MaGiaDinh=" + frm.DataReturn[GiaDinhConst.MaGiaDinh].ToString()));
                    if (Memory.ShowError())
                    {
                        return;
                    }
                    if (tbl != null && tbl.Rows.Count > 0)
                    {
                        foreach (DataColumn col in tbl.Columns)
                        {
                            if (row.Table.Columns.Contains(col.ColumnName))
                            {
                                row[col.ColumnName] = tbl.Rows[0][col.ColumnName];
                            }
                        }
                    }
                }
            }
        }
示例#3
0
        protected override void SetFormData(frmGiaDinh frm)
        {
            DataRow row = (this.CurrentRow.DataRow as DataRowView).Row;

            frm.Id = (int)row[MergeData.MaGiaDinhMoi];
        }
示例#4
0
        protected virtual void SetFormData(frmGiaDinh frm)
        {
            DataRow row = (this.CurrentRow.DataRow as DataRowView).Row;

            frm.Id = (int)row[GiaDinhConst.MaGiaDinh];
        }