Esempio n. 1
0
 protected void btnSua_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtID.Text.Length > 0)
         {
             tbl_Style style = db.tbl_Style.Find(Int32.Parse(txtID.Text));
             style.Style_Name = txtName.Text;
             db.SaveChanges();
             load();
             reset();
             lbThongBao.Text      = "Sửa thành công";
             lbThongBao.ForeColor = System.Drawing.Color.Green;
         }
         else
         {
             lbThongBao.Text      = "Chưa nhập dữ liệu";
             lbThongBao.ForeColor = System.Drawing.Color.Red;
         }
     }
     catch (Exception ex)
     {
         lbThongBao.Text      = "Lỗi " + ex.Message;
         lbThongBao.ForeColor = System.Drawing.Color.Red;
     }
 }
Esempio n. 2
0
 protected void btnThem_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtName.Text.Length > 0)
         {
             tbl_Style style = new tbl_Style();
             style.Style_Name = txtName.Text;
             db.tbl_Style.Add(style);
             db.SaveChanges();
             load();
             reset();
             lbThongBao.Text      = "Thêm thành công";
             lbThongBao.ForeColor = System.Drawing.Color.Green;
         }
         else
         {
             lbThongBao.Text      = "Chưa nhập dữ liệu";
             lbThongBao.ForeColor = System.Drawing.Color.Red;
         }
     }
     catch (Exception ex)
     {
         lbThongBao.Text      = "Lỗi " + ex.Message;
         lbThongBao.ForeColor = System.Drawing.Color.Red;
     }
 }
Esempio n. 3
0
        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            Label     lblMa = (Label)GridView1.Rows[e.NewEditIndex].FindControl("lbMa");
            tbl_Style p     = db.tbl_Styles.SingleOrDefault(c => c.Style_ID == int.Parse(lblMa.Text));

            txtMa.Text          = (p.Style_ID).ToString();
            txtTenPC.Text       = p.Style_Name.ToString();
            GridView1.EditIndex = e.NewEditIndex;
            load();
        }
Esempio n. 4
0
 protected void btnXoa_Click(object sender, EventArgs e)
 {
     if (KT(txtTenPC.Text))
     {
         tbl_Style t = db.tbl_Styles.SingleOrDefault(c => c.Style_ID == int.Parse(txtMa.Text));
         db.tbl_Styles.DeleteOnSubmit(t);
         db.SubmitChanges();
         load();
         Label1.Text = "Xoá thành công.";
         rong();
         txtTenPC.Focus();
     }
     else
     {
         Label1.Text = "Chưa chọn phong cách.";
     }
 }
Esempio n. 5
0
 protected void btnNhap_Click(object sender, EventArgs e)
 {
     if (KT(txtTenPC.Text))
     {
         tbl_Style s = new tbl_Style();
         s.Style_Name = txtTenPC.Text;
         db.tbl_Styles.InsertOnSubmit(s);
         db.SubmitChanges();
         load();
         Label1.Text = "Thêm thành công";
         rong();
         txtTenPC.Focus();
     }
     else
     {
         Label1.Text = "Chưa nhập tên phong cách.";
     }
 }