예제 #1
0
 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     string dataKey = GridView1.DataKeys[e.RowIndex].Value.ToString();
     string name = (GridView1.Rows[e.RowIndex].Cells[2].Controls[0] as TextBox).Text;
     string hanhTrinh = (GridView1.Rows[e.RowIndex].Cells[3].Controls[0] as TextBox).Text;
     int soNgay = Convert.ToInt16((GridView1.Rows[e.RowIndex].Cells[4].Controls[0] as TextBox).Text);
     double giaDiLai =Convert.ToDouble((GridView1.Rows[e.RowIndex].Cells[5].Controls[0] as TextBox).Text);
     double giaAno = Convert.ToDouble((GridView1.Rows[e.RowIndex].Cells[6].Controls[0] as TextBox).Text);
     string thongTin = (GridView1.Rows[e.RowIndex].Cells[7].Controls[0] as TextBox).Text;
     string trangThai = (GridView1.Rows[e.RowIndex].Cells[8].Controls[0] as TextBox).Text;
     DateTime ngayDi = Convert.ToDateTime((GridView1.Rows[e.RowIndex].Cells[9].Controls[0] as TextBox).Text);
     DateTime ngayVe = Convert.ToDateTime((GridView1.Rows[e.RowIndex].Cells[10].Controls[0] as TextBox).Text);
     var s = tk.Update(dataKey);
     s.IdTour = ID;
     s.TenTour = name;
     s.HanhTrinh = hanhTrinh;
     s.SoNgay = soNgay;
     s.GiaDiLai = giaDiLai;
     s.GiaPhong = giaAno;
     s.ThongTin = thongTin;
     s.TrangThai = trangThai;
     s.NgayDi = ngayDi;
     s.NgayVe = ngayVe;
     tk.SubmitChange();
     GridView1.EditIndex = -1;
     GridView1.DataSource = tk.GetAllTour();
     GridView1.DataBind();
 }
예제 #2
0
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtMatKhauCu.Text == currentUser.MatKhau)
                {
                    if (!string.IsNullOrEmpty(txtMatKhauMoi.Text) && txtMatKhauMoi.Text == txtMatKhauMoiAgain.Text)
                    {
                        currentUser.MatKhau = txtMatKhauMoi.Text;
                        TaiKhoan.Update(currentUser);

                        MessageBox.Show("Đổi mật khẩu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Mật khẩu mới trống hoặc không khớp", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("Mật khẩu cũ không chính xác", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch
            {
                MessageBox.Show("Có lỗi xảy ra", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
 public int edit(string Password, string OldPassword)
 {
     if (Session["Password"] != null && !Session["Password"].ToString().Equals(""))
     {
         if (md5.getMd5(OldPassword).Equals(Session["Password"].ToString()))
         {
             TaiKhoan tk = new TaiKhoan().Login(Session["Username"].ToString(), Session["Password"].ToString());
             tk.Password = md5.getMd5(Password);
             if (tk.Update() > 0)
             {
                 Session.RemoveAll();
                 return(1);
             }
             else
             {
                 return(0);
             }
         }
         else
         {
             return(-1);
         }
     }
     return(-1);
 }
예제 #4
0
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            try
            {
                TaiKhoan.Update(new TAIKHOAN()
                {
                    TenDangNhap = txtTenDangNhap.Text,
                    MatKhau     = txtMatKhau.Text,
                });

                MessageBox.Show("Cập nhật tài khoản thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnXemTatCa_Click(sender, e);
            }
            catch
            {
                MessageBox.Show("Có lỗi xảy ra", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #5
0
        public int login(string UserName, string Password)
        {
            TaiKhoan tk   = new TaiKhoan().Login(UserName, md5.getMd5(Password));
            int      flag = 0;

            if (tk.Username != null)
            {
                tk.LastLogin = DateTime.Now.ToString();
                tk.IP        = Request.UserHostAddress;
                if (tk.Update() > 0)
                {
                    Session.Timeout     = Int32.Parse(WebConfigurationManager.AppSettings["DURATION_TIMEOUT"]);
                    Session["Username"] = tk.Username;
                    Session["Password"] = tk.Password;
                    flag = 1;
                }
                else
                {
                    flag = 2;
                }
            }
            return(flag);
        }