protected void btn_themmautran_Click(object sender, EventArgs e) { mathang mh = new mathang(); mh.mamathang = txt_mamautran.Value; mh.madanhmuc = ddl_danhmucmautran.SelectedValue; mh.tenmathang = txt_tenmautran.Value; mh.ghichu = txt_ghichumautran.Text; mh.thumuchinh = txt_mamautran.Value; mh.mota = ""; mh.donvitinh = "Khong DVT"; mh.anhdaidien = ddl_anhdaidienmautran.SelectedValue; mh.ngaydang = DateTime.Now; mh.danhgia = 0; bool success = mathang_Action.add_Mathang(mh); if (success == true) { dtl_dsmautran.DataSource = mathang_Action.getFull_Mautran(); dtl_dsmautran.DataBind(); Response.Write("<script>alert('Thêm mẫu trần thành công')</script>"); } else { Response.Write("<script>alert('Thêm mẫu trần không thành công')</script>"); } }
protected void btn_themvattu_Click(object sender, EventArgs e) { mathang mh = new mathang(); mh.mamathang = txt_mavattu.Value; mh.madanhmuc = ddl_danhmucvattu.SelectedValue; mh.mota = cke_motavattu.Text; mh.tenmathang = txt_tenvattu.Value; mh.donvitinh = ddl_donvitinhvattu.SelectedValue; mh.ghichu = txt_ghichuvattu.Text; mh.thumuchinh = txt_mavattu.Value; mh.anhdaidien = ddl_anhdaidienvattu.SelectedValue; mh.ngaydang = DateTime.Now; mh.danhgia = 0; bool success = mathang_Action.add_Mathang(mh); if (success == true) { dtl_dsvattu.DataSource = mathang_Action.getFull_Vattu(); dtl_dsvattu.DataBind(); Response.Write("<script>alert('Thêm vật tư thành công')</script>"); } else { Response.Write("<script>alert('Thêm vật tư không thành công')</script>"); } }
public static bool delete_Mathang(mathang mh) { bool success = false; SqlCommand cmd = new SqlCommand("sp_delete_Mathang", cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@mamathang", mh.mamathang); cnn.Open(); SqlTransaction trans = cnn.BeginTransaction("delete_Mathang"); try { cmd.Transaction = trans; cmd.ExecuteNonQuery(); trans.Commit(); success = true; } catch (Exception) { success = false; trans.Rollback(); } finally { if (cnn.State != ConnectionState.Closed) { cnn.Close(); } } return(success); }
public static DataTable getByID_Mathang(mathang mh) { DataTable dt = new DataTable(); SqlCommand cmd = new SqlCommand("sp_getByID_Mathang", cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@mamathang", mh.mamathang); cnn.Open(); SqlTransaction trans = cnn.BeginTransaction("getByID_Mathang"); try { cmd.Transaction = trans; dt.Load(cmd.ExecuteReader()); trans.Commit(); } catch (Exception) { trans.Rollback(); } finally { if (cnn.State != ConnectionState.Closed) { cnn.Close(); } } return(dt); }
protected void Page_Load(object sender, EventArgs e) { string mamautran = ""; try { mamautran = Request.QueryString["materialID"].ToString(); if (mamautran == "") { Response.Redirect("~/default.aspx"); } } catch (Exception) { Response.Redirect("~/default.aspx"); } if (!IsPostBack) { mathang mh = new mathang(); mh.mamathang = mamautran; dtl_vatu.DataSource = mathang_Action.getByID_Mathang(mh); dtl_vatu.DataBind(); dtl_tinkhac.DataSource = baiviet_Action.getTop_Baiviet(5); dtl_tinkhac.DataBind(); dtl_hienthimautran.DataSource = mathang_Action.getTop_Mautran(3); dtl_hienthimautran.DataBind(); dtl_hienthivattu.DataSource = mathang_Action.getTop_Vattu(3); dtl_hienthivattu.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { string mamautran = ""; try { mamautran = Request.QueryString["ceilingID"].ToString(); if (mamautran == "") { Response.Redirect("~/default.aspx"); } } catch (Exception) { Response.Redirect("~/default.aspx"); } if (!IsPostBack) { mathang mh = new mathang(); mh.mamathang = mamautran; DataTable dt_mautran = new DataTable(); dt_mautran = mathang_Action.getByID_Mathang(mh); string tenmautran; tenmautran = dt_mautran.Rows[0]["tenmathang"].ToString(); lbl_tenmautran.InnerText = tenmautran; try { string[] listFile = Directory.GetFiles(Server.MapPath("~/mautran/" + mamautran)); DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("num", typeof(int))); dt.Columns.Add(new DataColumn("pathImg", typeof(string))); int num = 1; foreach (string i in listFile) { string pic = Path.GetFileName(i); dt.Rows.Add(num, "../mautran/" + mamautran + "/" + pic); num++; } dtl_hienthidsmautran.DataSource = dt; dtl_hienthidsmautran.DataBind(); } catch (Exception) { Response.Write("<script>alert('Ảnh chưa được upload')</script>"); } dtl_tinkhac.DataSource = baiviet_Action.getTop_Baiviet(5); dtl_tinkhac.DataBind(); dtl_hienthimautran.DataSource = mathang_Action.getTop_Mautran(3); dtl_hienthimautran.DataBind(); dtl_hienthivattu.DataSource = mathang_Action.getTop_Vattu(3); dtl_hienthivattu.DataBind(); } }
public void Add(mathang Mathang) { try { dbContext.mathang.Add(Mathang); dbContext.SaveChanges(); } catch (Exception ex) { throw ex; } }
// tìm mặt hàng public List <mathang> SearchMatHang(string ma, string ten, string loaimathang, string maquay, string mancc) { List <mathang> list = new List <mathang>(); string query = string.Format("select * from mathang mh where mh.ma like N'%{0}%' and mh.ten like N'%{1}%' and mh.loaimathang like N'%{2}%' and mh.maquay like N'%{3}%' and mh.manhacc like N'%{4}%'", ma, ten, loaimathang, maquay, mancc); DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow i in data.Rows) { mathang mh = new mathang(i); list.Add(mh); } return(list); }
// xem mat hang public List <mathang> XemMatHang() { List <mathang> list = new List <mathang>(); string query = "select ma,ten,loaimathang,donvitinh,maquay,manhacc,gia from mathang"; DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { mathang mh = new mathang(item); list.Add(mh); } return(list); }
protected void dtl_dsvattu_DeleteCommand(object source, DataListCommandEventArgs e) { string argu = e.CommandArgument.ToString(); mathang mh = new mathang(); mh.mamathang = argu; bool success = mathang_Action.delete_Mathang(mh); if (success == true) { Directory.Delete(Server.MapPath(@"~/vattu/" + argu), true); Response.Redirect(Request.Url.AbsoluteUri); } else { Response.Write("<script>alert('Xóa vật tư thất bại')</script>"); } }
protected void Page_Load(object sender, EventArgs e) { string madanhmuc = ""; try { madanhmuc = Request.QueryString["categoryID"].ToString(); if (madanhmuc == "") { Response.Redirect("~/default.aspx"); } } catch (Exception) { Response.Redirect("~/default.aspx"); } mathang mh = new mathang(); mh.madanhmuc = madanhmuc; dtl_mathang.DataSource = mathang_Action.getByType_Mathang(mh); dtl_mathang.DataBind(); }
public static bool add_Mathang(mathang mh) { bool success = false; SqlCommand cmd = new SqlCommand("sp_add_Mathang", cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@mamathang", mh.mamathang); cmd.Parameters.AddWithValue("@madanhmuc", mh.madanhmuc); cmd.Parameters.AddWithValue("@mota", mh.mota); cmd.Parameters.AddWithValue("@tenmathang", mh.tenmathang); cmd.Parameters.AddWithValue("@donvitinh", mh.donvitinh); cmd.Parameters.AddWithValue("@ghichu", mh.ghichu); cmd.Parameters.AddWithValue("@thumuchinh", mh.thumuchinh); cmd.Parameters.AddWithValue("@anhdaidien", mh.anhdaidien); cmd.Parameters.AddWithValue("@ngaydang", mh.ngaydang); cmd.Parameters.AddWithValue("@danhgia", mh.danhgia); cnn.Open(); SqlTransaction trans = cnn.BeginTransaction("add_Mathang"); try { cmd.Transaction = trans; cmd.ExecuteNonQuery(); trans.Commit(); success = true; } catch (Exception) { success = false; trans.Rollback(); } finally { if (cnn.State != ConnectionState.Closed) { cnn.Close(); } } return(success); }
public IHttpActionResult Add(mathang course) { courseService.Add(course); return(Ok("Ok")); }
protected void btn_themvattu_Click(object sender, EventArgs e) { mathang mh = new mathang(); mh.mamathang = txt_mavattu.Value; mh.madanhmuc = ddl_danhmucvattu.SelectedValue; mh.mota = cke_motavattu.Text; mh.tenmathang = txt_tenvattu.Value; mh.donvitinh = ddl_donvitinhvattu.SelectedValue; mh.ghichu = txt_ghichuvattu.Text; mh.thumuchinh = txt_mavattu.Value; mh.anhdaidien = ddl_anhdaidienvattu.SelectedValue; mh.ngaydang = DateTime.Now; mh.danhgia = 0; bool success = mathang_Action.add_Mathang(mh); if(success == true) { dtl_dsvattu.DataSource = mathang_Action.getFull_Vattu(); dtl_dsvattu.DataBind(); Response.Write("<script>alert('Thêm vật tư thành công')</script>"); } else { Response.Write("<script>alert('Thêm vật tư không thành công')</script>"); } }
public static bool delete_Mathang(mathang mh) { bool success = false; SqlCommand cmd = new SqlCommand("sp_delete_Mathang", cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@mamathang", mh.mamathang); cnn.Open(); SqlTransaction trans = cnn.BeginTransaction("delete_Mathang"); try { cmd.Transaction = trans; cmd.ExecuteNonQuery(); trans.Commit(); success = true; } catch (Exception) { success = false; trans.Rollback(); } finally { if (cnn.State != ConnectionState.Closed) { cnn.Close(); } } return success; }
public void Update(mathang course) { }
public static DataTable getByType_Mathang(mathang mh) { DataTable dt = new DataTable(); SqlCommand cmd = new SqlCommand("sp_getByType_Mathang", cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@madanhmuc", mh.madanhmuc); cnn.Open(); SqlTransaction trans = cnn.BeginTransaction("getByType_Mathang"); try { cmd.Transaction = trans; dt.Load(cmd.ExecuteReader()); trans.Commit(); } catch (Exception) { trans.Rollback(); } finally { if (cnn.State != ConnectionState.Closed) { cnn.Close(); } } return dt; }
public static bool add_Mathang(mathang mh) { bool success = false; SqlCommand cmd = new SqlCommand("sp_add_Mathang", cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@mamathang", mh.mamathang); cmd.Parameters.AddWithValue("@madanhmuc", mh.madanhmuc); cmd.Parameters.AddWithValue("@mota", mh.mota); cmd.Parameters.AddWithValue("@tenmathang", mh.tenmathang); cmd.Parameters.AddWithValue("@donvitinh", mh.donvitinh); cmd.Parameters.AddWithValue("@ghichu", mh.ghichu); cmd.Parameters.AddWithValue("@thumuchinh", mh.thumuchinh); cmd.Parameters.AddWithValue("@anhdaidien", mh.anhdaidien); cmd.Parameters.AddWithValue("@ngaydang", mh.ngaydang); cmd.Parameters.AddWithValue("@danhgia", mh.danhgia); cnn.Open(); SqlTransaction trans = cnn.BeginTransaction("add_Mathang"); try { cmd.Transaction = trans; cmd.ExecuteNonQuery(); trans.Commit(); success = true; } catch (Exception) { success = false; trans.Rollback(); } finally { if (cnn.State != ConnectionState.Closed) { cnn.Close(); } } return success; }