Example #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                // Sửa dữ liệu
                TourDLEntities   db  = new TourDLEntities();
                QLTour.DiaDiemDL obj = db.DiaDiemDL.FirstOrDefault(x => x.MaDDDL == txtMaDDDL.Text);
                if (obj == null)
                {
                    Response.Redirect("KhachHangs.aspx");
                }
                else
                {
                    if (txtTenDDDL.Text == "" || txtDiaChi.Text == "")
                    {
                        lbErrordangky.Text = "Bạn chưa nhập đủ thông tin!!!";
                    }
                    else
                    {
                        //obj.MaDDDL = txtMaDDDL.Text;
                        obj.TenDDDL = txtTenDDDL.Text;
                        obj.DiaChi  = txtDiaChi.Text;

                        db.SaveChanges();
                        Response.Redirect("DiaDiemDLs.aspx");
                    }
                }
            }
            catch
            {
                // Lỗi
                lbErrordangky.Text = "Lỗi không thể lưu!!!, Vui lòng kiểm tra lại";
            }
        }
Example #2
0
 protected void btnXoa_Command(object sender, CommandEventArgs e)
 {
     try
     {
         string           Mdddl = e.CommandArgument.ToString();
         TourDLEntities   db    = new TourDLEntities();
         QLTour.DiaDiemDL obj   = db.DiaDiemDL.FirstOrDefault(x => x.MaDDDL == Mdddl);
         if (obj != null)
         {
             db.DiaDiemDL.Remove(obj);
             db.SaveChanges();
             getData();
         }
     }
     catch
     {
         //
     }
 }
Example #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //getcmbTenLoaitour();
     if (!IsPostBack)
     {
         // kiểm tra trường hợp sửa/thêm mới
         // nếu url có dạng ?masp=123 => sửa, ngược lại là thêm mới
         if (Request.QueryString["MaDDDL"] == null)
         {
             // thêm mới
             btnSave.Visible = false;
             btnAdd.Visible  = true;
             //txtMaDDDL.Text = Request.QueryString["MaDDDL"];
             txtMaDDDL.Enabled  = false;
             txtMaDDDL.CssClass = txtMaDDDL.CssClass + " form-control";
         }
         else
         {
             // Sửa
             btnSave.Visible    = true;
             btnAdd.Visible     = false;
             txtMaDDDL.Text     = Request.QueryString["MaDDDL"];
             txtMaDDDL.Enabled  = false;
             txtMaDDDL.CssClass = txtMaDDDL.CssClass + " form-control";
             // Query về db để lấy các thông tin còn lại
             TourDLEntities   db  = new TourDLEntities();
             QLTour.DiaDiemDL obj = db.DiaDiemDL.FirstOrDefault(x => x.MaDDDL == txtMaDDDL.Text);
             if (obj == null)
             {
                 Response.Redirect("DiaDiemDLs.aspx");
             }
             else
             {
                 txtMaDDDL.Text  = obj.MaDDDL;
                 txtTenDDDL.Text = obj.TenDDDL;
                 txtDiaChi.Text  = obj.DiaChi;
             }
         }
     }
 }
Example #4
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                TourDLEntities   db  = new TourDLEntities();
                QLTour.DiaDiemDL obj = db.DiaDiemDL.FirstOrDefault(x => x.MaDDDL == txtMaDDDL.Text);
                if (obj != null)
                {
                    // Cảnh báo mã sản phẩm đã tồn tại
                }
                else
                {
                    if (txtTenDDDL.Text == "" || txtDiaChi.Text == "")
                    {
                        lbErrordangky.Text = "Bạn chưa nhập đủ thông tin!!!";
                    }
                    else
                    {
                        obj         = new QLTour.DiaDiemDL();
                        obj.MaDDDL  = getmadl();
                        obj.TenDDDL = txtTenDDDL.Text;
                        obj.DiaChi  = txtDiaChi.Text;


                        db.DiaDiemDL.Add(obj);
                        db.SaveChanges();
                        Response.Redirect("DiaDiemDLs.aspx");
                    }
                }
            }
            catch
            {
                // Lỗi
                lbErrordangky.Text = "Lỗi không thể thêm!!!, Vui lòng kiểm tra lại";
            }
        }