protected void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         String sql = "Select ma_loaiTB from loai_TB where ma_loaiTB='" + txt_maloaiTB.Text + "'";
         String ma  = "";
         foreach (DataRow dt in db.bindDataTable(sql).Rows)
         {
             ma = dt["ma_loaiTB"].ToString();
         }
         if (ma == txt_maloaiTB.Text)
         {
             ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myalert", "$.notify('Mã loại thiết bị đã tồn tại !!!', 'error');", true);
         }
         else
         {
             DTO_LTB tb = new DTO_LTB(txt_maloaiTB.Text, txt_tenloaiTB.Text, trang_thai.SelectedValue.ToString(), txt_mota.Text);
             if (bus_ltb.Query("_Insert_loaiTB", tb))
             {
                 ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myalert", "$.notify('Thêm loại thiết bị thành công !!!', 'success');", true);
                 hienthi();
                 ClearAll();
             }
             else
             {
                 ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myalert", "$.notify('Thêm loại thiết bị thất bại !!!', 'error');", true);
             }
         }
     }catch (Exception ex) { }
 }
        protected void btnEditChange_Click(object sender, EventArgs e)
        {
            DTO_LTB tb = new DTO_LTB(txt_maloaiTB_edit.Text, txt_tenloaiTB_edit.Text, trang_thai_edit.SelectedValue.ToString(), txt_mota_edit.Text);

            if (bus_ltb.Query("_Update_loaiTB", tb))
            {
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myalert", "$.notify('Cập nhật loại thiết bị thành công !!!', 'success');", true);
                hienthi();
                ClearAll();
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myalert", "$.notify('Cập nhật loại thiết bị thất bại !!!', 'error');", true);
            }
        }
Пример #3
0
 public bool ExcuteQuery_LTB(String name, DTO_LTB tb)
 {
     try
     {
         SqlConnection connection = new SqlConnection(conn);
         SqlCommand    command    = new SqlCommand(name, connection);
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.Add(new SqlParameter("@ma_loaiTB", tb.MaLoaiTB));
         command.Parameters.Add(new SqlParameter("@ten_loaiTB", tb.TenLoaiTB));
         command.Parameters.Add(new SqlParameter("@trang_thai", tb.TrangThai));
         command.Parameters.Add(new SqlParameter("@mota_tb", tb.MoTa));
         connection.Open();
         command.ExecuteNonQuery();
         connection.Close();
         connection.Dispose();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #4
0
 public bool Query(string name, DTO_LTB tb)
 {
     return(dal_ltb.ExcuteQuery_LTB(name, tb));
 }