コード例 #1
0
ファイル: Form1.cs プロジェクト: doraemon100498/huhhi
        private void TsbThemLienLac_Click(object sender, EventArgs e)
        {
            try
            {
                int    hanghientai = dgvGroup.CurrentCell.RowIndex;
                String tenNhom     = dgvGroup.Rows[hanghientai].Cells[0].Value.ToString();
                if (tenNhom == "" || tenNhom == null)
                {
                    MessageBox.Show("Vui lòng chọn nhóm cần thêm liên hệ", "Thông báo", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                frmThemLienHe f = new frmThemLienHe(tenNhom);
                f.ShowDialog();
                dgvContacts.Rows.Clear();
                List <Nhom> dsn = Nhom.GetList();
                if (dsn != null)
                {
                    List <LienHe> dslh = LienHe.GetList(tenNhom);
                    foreach (var i in dslh)
                    {
                        dgvContacts.Rows.Add(i.TenGoi, i.Email, i.SDT);
                    }

                    LienHe lh = LienHe.GetLienHe(dgvContacts.Rows[0].Cells[0].FormattedValue.ToString());
                    if (lh != null)
                    {
                        label1.Text    = "Địa chỉ:";
                        label2.Text    = "Email:";
                        label3.Text    = "Số điện thoại:";
                        lblTenGoi.Text = lh.TenGoi;
                        lblDiaChi.Text = lh.DiaChi;
                        lblEmail.Text  = lh.Email;
                        lblSDT.Text    = lh.SDT;
                    }
                    else
                    {
                        lblTenGoi.Text = "";
                        lblDiaChi.Text = "";
                        lblEmail.Text  = "";
                        lblSDT.Text    = "";
                        label1.Text    = "";
                        label2.Text    = "";
                        label3.Text    = "";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Vui lòng chọn nhóm muốn thêm liên hệ", "Thông báo", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: doraemon100498/huhhi
        private void LoadForm1()
        {
            dgvContacts.Rows.Clear();
            dgvGroup.Rows.Clear();
            List <Nhom> dsn = Nhom.GetList();

            if (dsn != null)
            {
                foreach (var i in dsn)
                {
                    dgvGroup.Rows.Add(i.TenNhom);
                }

                List <LienHe> dslh = LienHe.GetList(dgvGroup.Rows[0].Cells[0].FormattedValue.ToString());
                foreach (var i in dslh)
                {
                    dgvContacts.Rows.Add(i.TenGoi, i.Email, i.SDT);
                }

                LienHe lh = LienHe.GetLienHe(dgvContacts.Rows[0].Cells[0].FormattedValue.ToString());
                if (lh != null)
                {
                    label1.Text    = "Địa chỉ:";
                    label2.Text    = "Email:";
                    label3.Text    = "Số điện thoại:";
                    lblTenGoi.Text = lh.TenGoi;
                    lblDiaChi.Text = lh.DiaChi;
                    lblEmail.Text  = lh.Email;
                    lblSDT.Text    = lh.SDT;
                }
                else
                {
                    lblTenGoi.Text = "";
                    lblDiaChi.Text = "";
                    lblEmail.Text  = "";
                    lblSDT.Text    = "";
                    label1.Text    = "";
                    label2.Text    = "";
                    label3.Text    = "";
                }
            }
        }