Exemplo n.º 1
0
    public bool LuuDangVien(string username, string password, DangVien kh)
    {
        try
        {
            authen a       = new authen();
            bool   bAuthen = a.fAuthen(username, password);
            if (bAuthen)
            {
                DangVien dv = (from c in db.DangViens
                               where c.ID == kh.ID
                               select c).FirstOrDefault();
                bool isInsert = false;
                if (dv == null)
                {
                    dv       = new DangVien();
                    isInsert = true;
                }

                dv.ID                      = kh.ID;
                dv.NgayVaoDang             = kh.NgayVaoDang;
                dv.ChiBoKetNap             = kh.ChiBoKetNap;
                dv.NguoiGioiThieu1         = kh.NguoiGioiThieu1;
                dv.ChucVuNguoiGioiThieu1   = kh.ChucVuNguoiGioiThieu1;
                dv.NgheNghiepKhiVaoDang    = kh.NgheNghiepKhiVaoDang;
                dv.NguoiGioiThieu2         = kh.NguoiGioiThieu2;
                dv.GhiChuVeNguoiGioiThieu2 = kh.GhiChuVeNguoiGioiThieu2;
                dv.NgayChinhThucVaoDang    = kh.NgayChinhThucVaoDang;
                dv.SoLyLichDangVien        = kh.SoLyLichDangVien;
                dv.SoTheDangVien           = kh.SoTheDangVien;
                dv.MaCoSoDangQLDangVien    = kh.MaCoSoDangQLDangVien;
                dv.ChucVuTrongDang         = kh.ChucVuTrongDang;

                if (isInsert == true)
                {
                    db.DangViens.Add(dv);
                }

                db.SaveChanges();
                return(true);
            }
            else
            {
                return(bAuthen);
            }
        }
        catch (Exception ex)
        {
            return(false);
        }
    }
Exemplo n.º 2
0
    protected void EditRecord(object sender, EventArgs e)
    {
        DangVien item = new DangVien();

        item.NgayVaoDang             = txtNgayVaoDang.Text;
        item.ChiBoKetNap             = txtChiBoKetNap.Text;
        item.NguoiGioiThieu1         = txtNguoiGioiThieu1.Text;
        item.ChucVuNguoiGioiThieu1   = txtChucVuNguoiGioiThieu1.Text;
        item.NgheNghiepKhiVaoDang    = txtNgheNghiepKhiVaoDang.Text;
        item.NguoiGioiThieu2         = txtNguoiGioiThieu2.Text;
        item.GhiChuVeNguoiGioiThieu2 = txtGhiChuVeNguoiGioiThieu2.Text;
        item.NgayChinhThucVaoDang    = txtNgayChinhThucVaoDang.Text;
        item.SoLyLichDangVien        = txtSoLyLichDangVien.Text;
        item.SoTheDangVien           = txtSoTheDangVien.Text;
        item.MaCoSoDangQLDangVien    = txtMaCoSoDangQLDangVien.Text;
        item.ChucVuTrongDang         = txtChucVuTrongDang.Text;

        ServiceDangVien es = new ServiceDangVien();

        try
        {
            var id = Common.TryParseObjectToInt(Request.QueryString["ID"] + "");
            item.ID = id;
            bool result = false;
            result = es.LuuDangVien("TheBinh", "12345678", item);
            if (result)
            {
                lblMessage.Text = "Đã lưu thông tin đảng viên thành công!";
            }
            else
            {
                lblMessage.Text = "Có lỗi xảy ra, chưa lưu được thông tin. Hãy kiểm tra và thử lại";
            }
        }
        catch (Exception ee)
        {
            lblMessage.Text = ee.Message;
        }
        finally
        {
            es.Dispose();
            item = null;
        }
    }