Exemplo n.º 1
0
 private void addMember()
 {
     try
     {
         XuLyAnh.MaHoaHinhAnh mha = new XuLyAnh.MaHoaHinhAnh();
         SECURITY.RandomClass rdm = new SECURITY.RandomClass();
         int chucVu;
         int gioiTinh;
         if (frmaddmember.rdb_CTV.Checked)
         {
             chucVu = 8;
         }
         else
         {
             chucVu = 7;
         }
         if (frmaddmember.rdb_Nam.Checked)
         {
             gioiTinh = 1;
         }
         else
         {
             gioiTinh = 0;
         }
         string imageName = rdm.RandomText(20) + ".jpg";
         frmaddmember.pic_Avartar.Image.Save(imageName);
         string chuoiAnh = mha.byteToString(mha.AnhSangChuoi(imageName));
         string sqlquery = "insert into ThanhVien(HoThanhVien,TenThanhVien,GioiTinh,NgaySinh,IDDiaChi,SDT,MSSV,Khoa,Lop,LinkFB,"
                           + "IDChucVu,NgayGiaNhap,AnhDaiDien) values(N'" + frmaddmember.tb_Ho.Text + "',N'" + frmaddmember.tb_Ten.Text
                           + "'," + gioiTinh + ",'" + string.Format("{0:u}", frmaddmember.dtp_NgaySinh.Value).Substring(0, 10) + "'," + getidDiaChi() + ",'"
                           + frmaddmember.tb_SDT.Text + "','" + frmaddmember.tb_MSSV.Text + "',N'" + frmaddmember.cb_Khoa.Text + "',N'"
                           + frmaddmember.tb_Lop.Text + "',N'" + frmaddmember.tb_Facebook.Text + "'," + chucVu + ",getdate(),'" + chuoiAnh + "')";
         daladdmember.addMember(sqlquery);
         sqlquery = "select max(IDThanhVien) from ThanhVien";
         string idThanhVien = daladdmember.getNewID(sqlquery);
         sqlquery = "insert into DuyetThanhVien(IDThanhVien,NgayDuyet,NguoiDuyet) values(" + idThanhVien
                    + ",getdate()," + caseData.DataTam.DuLieu.ID + ")";
         if (daladdmember.addMember(sqlquery) > 0)
         {
             string              message = "Chúc mừng bạn: <HoTen>, MSSV: < MSSV > đã chính thức trở thành CTV của CLB Tình nguyện Sinh viên Duy Tân.Mời bạn truy cập link: https://www.facebook.com/groups/CLBTinhNguyenSinhVienDuyTan để vào group của CLB nhằm theo dõi các thông báo mới nhất. CLB Tình nguyện Sinh viên Duy Tân xin cám ơn bạn vì đã tham gia cùng chúng tôi";
             logical.APIeSMS     eSMS    = new logical.APIeSMS();
             XuLyChuoi.checkKyTu chkstr  = new XuLyChuoi.checkKyTu();
             eSMS.SendSMS(frmaddmember.tb_SDT.Text, chkstr.DetectChar(message, idThanhVien));
             MessageBox.Show("Thêm thành công");
         }
         sqlquery = "select AnhDaiDien from ThanhVien where IDThanhVien = '" + idThanhVien + "'";
         frmaddmember.pic_Avartar.Image = mha.ChuoiSangAnh(daladdmember.getNewID(sqlquery));
         caseData.MoFile fopen = new caseData.MoFile();
         fopen.deleteFile(imageName);
         linkFile = imageName;
         caseData.DataTam.DuLieu.client.Send(Serialize("volunteeraddmember:" + idThanhVien));
         mblist.addNewMember(idThanhVien, caseData.DataTam.DuLieu.mbList);
     }
     catch (Exception e)
     {
         MessageBox.Show("Lỗi: " + e.Message);
     }
 }
Exemplo n.º 2
0
        private void loadMember()
        {
            try
            {
                string    sqlquery = "select * from ThanhVien left join ChucVu on ThanhVien.IDChucVu = ChucVu.IDChucVu left join DiaChi on ThanhVien.IDDiaChi = DiaChi.IDDiaChi left join Tinh on Tinh.IDTinh = DiaChi.IDTinh left join Huyen on DiaChi.IDHuyen = Huyen.IDHuyen left join Xa on DiaChi.IDXa = Xa.IDXa where ThanhVien.IDThanhVien =" + caseData.DataTam.DuLieu.idTemp;
                DataTable dt       = daladdmember.getTable(sqlquery);

                if (dt.Rows[0]["IDChucVu"].ToString() != "5")
                {
                    frmaddmember.rdb_TVCT.Checked = true;
                }
                else
                {
                    frmaddmember.rdb_CTV.Checked = true;
                }
                frmaddmember.tb_Ho.Text  = dt.Rows[0]["HoThanhVien"].ToString();
                frmaddmember.tb_Ten.Text = dt.Rows[0]["TenThanhVien"].ToString();
                if (dt.Rows[0]["GioiTinh"].ToString() == "True")
                {
                    frmaddmember.rdb_Nam.Checked = true;
                }
                else
                {
                    frmaddmember.rdb_Nu.Checked = true;
                }
                frmaddmember.dtp_NgaySinh.Value   = DateTime.Parse(dt.Rows[0]["NgaySinh"].ToString());
                frmaddmember.tb_MSSV.Text         = dt.Rows[0]["MSSV"].ToString();
                frmaddmember.cb_Khoa.SelectedItem = dt.Rows[0]["Khoa"].ToString();
                try
                {
                    frmaddmember.cbb_TenTinh.SelectedIndex  = int.Parse(dt.Rows[0]["STTTinh"].ToString()) - 1;
                    frmaddmember.cbb_TenHuyen.SelectedIndex = int.Parse(dt.Rows[0]["STTHuyen"].ToString());
                    frmaddmember.cbb_TenXa.SelectedIndex    = int.Parse(dt.Rows[0]["STTXa"].ToString());
                }
                catch { }
                frmaddmember.tb_DiaChiCuThe.Text = dt.Rows[0]["DiaChiCuThe"].ToString();
                frmaddmember.tb_SDT.Text         = dt.Rows[0]["SDT"].ToString();
                frmaddmember.tb_Facebook.Text    = dt.Rows[0]["LinkFB"].ToString();
                frmaddmember.tb_Lop.Text         = dt.Rows[0]["Lop"].ToString();
                XuLyAnh.MaHoaHinhAnh mhimage = new XuLyAnh.MaHoaHinhAnh();
                idDiaChi = dt.Rows[0]["IDDiaChi"].ToString();
                frmaddmember.pic_Avartar.Image = mhimage.ChuoiSangAnh(dt.Rows[0]["AnhDaiDien"].ToString());
                if (int.Parse(dt.Rows[0]["IDChucVu"].ToString()) < 3)
                {
                    frmaddmember.cbb_ChucVu.Enabled = true;
                }
                frmaddmember.cbb_ChucVu.SelectedIndex = int.Parse(dt.Rows[0]["IDChucVu"].ToString()) - 1;

                frmaddmember.Text           = "Thông tin thành viên";
                frmaddmember.lb_TieuDe.Text = "THÔNG TIN THÀNH VIÊN";

                frmaddmember.lb_Export.Visible = true;
            }
            catch { }
        }
Exemplo n.º 3
0
 public void loadInfo()
 {
     try
     {
         string    sqlLayThongTin = "select HoThanhVien,TenThanhVien,MSSV,TenChucVu,AnhDaiDien,ThanhVien.IDChucVu from [ThanhVien],ChucVu where IDThanhVien = " + caseData.DataTam.DuLieu.ID + " and ThanhVien.IDChucVu = ChucVu.IDChucVu";
         DataTable dt             = dalUserInfo.layTTThanhVien(sqlLayThongTin);
         guiuserinfo.lb_HoTen.Text    = dt.Rows[0]["HoThanhVien"] + " " + dt.Rows[0]["TenThanhVien"];
         guiuserinfo.lb_MSSV.Text     = dt.Rows[0]["MSSV"].ToString();
         guiuserinfo.lb_ChucVu.Text   = dt.Rows[0]["TenChucVu"].ToString();
         guiuserinfo.pic_Avatar.Image = mhAnh.ChuoiSangAnh(dt.Rows[0]["AnhDaiDien"].ToString());
         caseData.DataTam.DuLieu.dt   = dt;
     }
     catch { }
 }
Exemplo n.º 4
0
        private void updateMember()
        {
            XuLyAnh.MaHoaHinhAnh mha = new XuLyAnh.MaHoaHinhAnh();
            SECURITY.RandomClass rdm = new SECURITY.RandomClass();
            string chucVu;
            int    gioiTinh;

            chucVu = frmaddmember.cbb_ChucVu.SelectedValue.ToString();
            if (frmaddmember.rdb_Nam.Checked)
            {
                gioiTinh = 1;
            }
            else
            {
                gioiTinh = 0;
            }
            string sqlquery;

            if (linkFile != "")
            {
                string imageName = rdm.RandomText(20) + ".jpg";
                frmaddmember.pic_Avartar.Image.Save(imageName);

                string chuoiAnh = mha.byteToString(mha.AnhSangChuoi(imageName));
                sqlquery = "update ThanhVien set HoThanhVien = N'" + frmaddmember.tb_Ho.Text + "',TenThanhVien = N'" + frmaddmember.tb_Ten.Text
                           + "',GioiTinh = " + gioiTinh + ",NgaySinh = '" + string.Format("{0:u}", frmaddmember.dtp_NgaySinh.Value).Substring(0, 10)
                           + "',SDT = '" + frmaddmember.tb_SDT.Text + "',MSSV = '" + frmaddmember.tb_MSSV.Text + "',Khoa = N'" + frmaddmember.cb_Khoa.Text + "',Lop = N'"
                           + frmaddmember.tb_Lop.Text + "',LinkFB = N'" + frmaddmember.tb_Facebook.Text + "',IDChucVu = " + chucVu + ",AnhDaiDien = '" + chuoiAnh + "' where IDThanhVien = " + caseData.DataTam.DuLieu.idTemp;

                caseData.MoFile fopen = new caseData.MoFile();
                fopen.deleteFile(imageName);
            }
            else
            {
                sqlquery = "update ThanhVien set HoThanhVien = N'" + frmaddmember.tb_Ho.Text + "',TenThanhVien = N'" + frmaddmember.tb_Ten.Text
                           + "',GioiTinh = " + gioiTinh + ",NgaySinh = '" + string.Format("{0:u}", frmaddmember.dtp_NgaySinh.Value).Substring(0, 10)
                           + "',SDT = '" + frmaddmember.tb_SDT.Text + "',MSSV = '" + frmaddmember.tb_MSSV.Text + "',Khoa = N'" + frmaddmember.cb_Khoa.Text + "',Lop = N'"
                           + frmaddmember.tb_Lop.Text + "',LinkFB = N'" + frmaddmember.tb_Facebook.Text + "',IDChucVu = " + chucVu + " where IDThanhVien = " + caseData.DataTam.DuLieu.idTemp;
            }
            if (daladdmember.addMember(sqlquery) > 0)
            {
                sqlquery = "select IDDiaChi from ThanhVien where IDThanhVien = " + caseData.DataTam.DuLieu.idTemp;
                updateAddress(daladdmember.getNewID(sqlquery));
                MessageBox.Show("Thay đổi thông tin của bạn thành công");
            }
            sqlquery = "select AnhDaiDien from ThanhVien where IDThanhVien = '" + caseData.DataTam.DuLieu.idTemp + "'";
            frmaddmember.pic_Avartar.Image = mha.ChuoiSangAnh(daladdmember.getNewID(sqlquery));
        }
Exemplo n.º 5
0
        private void addmessLoad(string mess, string name, string idmem)
        {
            if (mha.IsBase64String(mess.ToString()) && mess.Length > 200)
            {//đang ở đây
                pic_Image             = new PictureBox();
                pic_Image.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                pic_Image.Location    = new System.Drawing.Point(9, 6);
                pic_Image.Name        = "pic_Image";
                pic_Image.Size        = new System.Drawing.Size(157, 107);
                pic_Image.SizeMode    = System.Windows.Forms.PictureBoxSizeMode.Zoom;
                pic_Image.TabIndex    = 4;
                pic_Image.Image       = mha.ChuoiSangAnh(mess.ToString());
                pic_Image.TabStop     = false;

                pn_Image          = new Panel();
                pn_Image.Dock     = System.Windows.Forms.DockStyle.Top;
                pn_Image.Location = new System.Drawing.Point(0, 57);
                pn_Image.Name     = "pn_Image";
                pn_Image.Size     = new System.Drawing.Size(756, 119);
                pn_Image.TabIndex = 5;

                pn_Image.Controls.Add(pic_Image);

                frmmessange.pn_Mess.Controls.Add(pn_Image);

                if (idmem.ToString() == caseData.DataTam.DuLieu.ID)
                {
                    pic_Image.Location = new Point(pn_Image.Size.Width - pic_Image.Size.Width - 30, pic_Image.Location.Y);
                }
            }
            else
            {
                messange = new TextBox();

                messange.BackColor   = Color.White;
                messange.AllowDrop   = true;
                messange.BorderStyle = BorderStyle.None;
                messange.Dock        = System.Windows.Forms.DockStyle.Top;
                messange.Font        = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                messange.Location    = new System.Drawing.Point(0, 27);
                messange.Multiline   = true;
                messange.Name        = "messange";
                messange.ReadOnly    = true;
                messange.Size        = new System.Drawing.Size(756, 30);
                messange.TabIndex    = 3;

                frmmessange.pn_Mess.Controls.Add(messange);

                if (idmem.ToString() == caseData.DataTam.DuLieu.ID)
                {
                    messange.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
                    messange.Text      = "Bạn: " + mess;
                }
                else
                {
                    messange.Text = name + ": " + mess;
                }

                Size size = TextRenderer.MeasureText(messange.Text, messange.Font);
                messange.Width = size.Width - size.Width / 3;
                int linecount = mess.Split('\n').Length;
                messange.Height = size.Height + linecount * 26;
            }
            int change = frmmessange.pn_Mess.VerticalScroll.Value + frmmessange.VerticalScroll.SmallChange * 100;

            frmmessange.pn_Mess.AutoScrollPosition = new Point(0, change);
        }
Exemplo n.º 6
0
        public void loadInfo()
        {
            string    sqlMember = "select IDThanhVien,HoThanhVien + ' ' + TenThanhVien as HoTen, GioiTinh, NgaySinh,DiaChiCuThe,TenXa,TenHuyen,TenTinh,SDT,MSSV,Khoa,Lop,LinkFB,AnhDaiDien,TenChucVu from ChucVu,ThanhVien, DiaChi,Tinh,Huyen,Xa where ThanhVien.IDDiaChi = DiaChi.IDDiaChi and DiaChi.IDXa = Xa.IDXa and Xa.IDHuyen = Huyen.IDHuyen and Huyen.IDTinh = Tinh.IDTinh and ThanhVien.IDChucVu =  ChucVu.IDChucVu and MSSV =  '" + caseData.DataTam.DuLieu.idTemp + "';";
            DataTable dtInfo    = dalmember.getTable(sqlMember);

            XuLyChuoi.checkLink checklink = new XuLyChuoi.checkLink();
            if (dtInfo.Rows.Count < 1)
            {
                caseData.txtRead        txtread = new caseData.txtRead();
                logical.GgSheetAPI      ggsheet = new logical.GgSheetAPI();
                string[]                idTable = txtread.readfile(0);
                IList <IList <Object> > values  = ggsheet.docfile(idTable[1], idTable[2]);
                int       id                    = int.Parse(caseData.DataTam.DuLieu.idTemp);
                string    sqlBirthDay           = "SELECT * FROM [ThanhVien],[ChucVu] where ThanhVien.IDChucVu = ChucVu.IDChucVu and MSSV = '" + values[id][1].ToString() + "';";
                DataTable dt                    = dalmember.getTable(sqlBirthDay);
                List <XuLyChuoi.checkLink> link = checklink.DetectLink(values[id][10].ToString());
                frmMemberInfor.lb_HoTen.Text = (values[id][2].ToString() + " " + values[id][3].ToString()).ToUpper();
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["RoiCLB"].ToString() == "")
                    {
                        frmMemberInfor.lb_HoTen.Text += " - ĐÃ LÀ THÀNH VIÊN!";
                    }
                    else
                    {
                        frmMemberInfor.lb_HoTen.Text += " - ĐÃ RỜI CLB NGÀY: " + dt.Rows[0]["RoiCLB"].ToString();
                    }
                    try
                    {
                        XuLyAnh.MaHoaHinhAnh mhAnh = new XuLyAnh.MaHoaHinhAnh();
                        frmMemberInfor.pic_Avartar.Image = mhAnh.ChuoiSangAnh(dt.Rows[0]["AnhDaiDien"].ToString());
                    }
                    catch { }
                    frmMemberInfor.lb_HoTen.ForeColor = System.Drawing.Color.Red;
                    frmMemberInfor.tb_ChucVu.Text     = dt.Rows[0]["TenChucVu"].ToString();
                }
                else
                {
                    frmMemberInfor.tb_ChucVu.Text = "Chưa xét duyệt";
                }
                frmMemberInfor.tb_mssv.Text      = values[id][1].ToString();
                frmMemberInfor.tb_Sdt.Text       = values[id][4].ToString();
                frmMemberInfor.tb_Khoa.Text      = values[id][8].ToString();
                frmMemberInfor.tb_Lop.Text       = values[id][9].ToString();
                frmMemberInfor.tb_DiaChi.Text    = values[id][7].ToString();
                frmMemberInfor.dtp_NgaySinh.Text = values[id][6].ToString();
                frmMemberInfor.tb_Sdt.Text       = values[id][4].ToString();
                if (link.Count > 0)
                {
                    frmMemberInfor.link_Facebook.Text = "Mở Facebook";
                    frmMemberInfor.link_Facebook.Links.Add(0, link[0].getContent().Length, link[0].getContent());
                    frmMemberInfor.link_Facebook.LinkClicked += new LinkLabelLinkClickedEventHandler(linkClick);
                }
                else
                {
                    frmMemberInfor.link_Facebook.Text = values[id][10].ToString();
                    frmMemberInfor.link_Facebook.Links.Add(0, 0);
                }
                if (values[id][5].ToString() == "Nam")
                {
                    frmMemberInfor.ra_Nam.Checked = true;
                }
                else
                {
                    frmMemberInfor.ra_nu.Checked = true;
                }
            }
            else
            {
                frmMemberInfor.lb_HoTen.Text  = dtInfo.Rows[0]["HoTen"].ToString();
                frmMemberInfor.tb_mssv.Text   = dtInfo.Rows[0]["MSSV"].ToString();
                frmMemberInfor.tb_Sdt.Text    = dtInfo.Rows[0]["SDT"].ToString();
                frmMemberInfor.tb_Khoa.Text   = dtInfo.Rows[0]["Khoa"].ToString();
                frmMemberInfor.tb_Lop.Text    = dtInfo.Rows[0]["Lop"].ToString();
                frmMemberInfor.tb_DiaChi.Text = dtInfo.Rows[0]["DiaChiCuThe"].ToString() + " - " + dtInfo.Rows[0]["TenXa"].ToString() + " - " + dtInfo.Rows[0]["TenHuyen"].ToString() + " - " + dtInfo.Rows[0]["TenTinh"].ToString();
                DateTime ngay = Convert.ToDateTime(dtInfo.Rows[0]["NgaySinh"].ToString());
                frmMemberInfor.dtp_NgaySinh.Text = ngay.ToString("dd/MM/yyyy");
                frmMemberInfor.tb_Sdt.Text       = dtInfo.Rows[0]["SDT"].ToString();
                frmMemberInfor.tb_ChucVu.Text    = dtInfo.Rows[0]["TenChucVu"].ToString();
                List <XuLyChuoi.checkLink> link = checklink.DetectLink(dtInfo.Rows[0]["LinkFB"].ToString());
                if (link.Count > 0)
                {
                    frmMemberInfor.link_Facebook.Text = "Mở Facebook";
                    frmMemberInfor.link_Facebook.Links.Add(0, link[0].getContent().Length, link[0].getContent());
                    frmMemberInfor.link_Facebook.LinkClicked += new LinkLabelLinkClickedEventHandler(linkClick);
                }
                else
                {
                    frmMemberInfor.link_Facebook.Text = dtInfo.Rows[0]["LinkFB"].ToString();
                    frmMemberInfor.link_Facebook.Links.Add(0, 0);
                }
                if (Convert.ToBoolean(dtInfo.Rows[0]["GioiTinh"]))
                {
                    frmMemberInfor.ra_Nam.Checked = true;
                }
                else
                {
                    frmMemberInfor.ra_nu.Checked = true;
                }
                try
                {
                    XuLyAnh.MaHoaHinhAnh mhAnh = new XuLyAnh.MaHoaHinhAnh();
                    frmMemberInfor.pic_Avartar.Image = mhAnh.ChuoiSangAnh(dtInfo.Rows[0]["AnhDaiDien"].ToString());
                }
                catch { }
            }
        }