public DataTable CreateTbHH(EC_HangHoa _hh) { string sqlquery = "SELECT * FROM tb_Hanghoa where mahang like N'%{0}%' and tenhang like N'%{1}%' and manhom like N'%{2}%' and madonvi like N'%{3}%' and" + " manuoc like N'%{4}%' and dongianhap like N'%{5}%' and dongiaban like N'%{6}%' and ghichu like N'%{7}%'"; sqlquery = string.Format(sqlquery, _hh.MaHangHoa, _hh.TenHangHoa, _hh.MaNhom, _hh.MaDonVi, _hh.MaNuoc, _hh.DonGiaNhap, _hh.DonGiaBan, _hh.GhiChu); return(Connect.CreateTable(sqlquery)); }
public void AddSP(EC_HangHoa _sp) { if (!sqlhanghoa.CheckHangHoa(_sp.MaHangHoa)) { sqlhanghoa.AddHangHoa(_sp); } else { MessageBox.Show("Mã này đã tồn tại,xin chọn Mã khác", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void UpdateHangHoa(EC_HangHoa _newhanghoa) { try { //Connect.SqlConnect.Open(); //string sqlquery = "UPDATE tb_Hanghoa" + // " SET tenhang =N'{0}', manhom =N'{1}', madonvi =N'{2}', manuoc =N'{3}', dongianhap ='{4}', dongiaban ='{5}', ghichu =N'6}' where mahang=N'{7}'"; //sqlquery = string.Format(sqlquery, _newhanghoa.TenHangHoa, _newhanghoa.MaNhom, _newhanghoa.MaDonVi, // _newhanghoa.MaNuoc, _newhanghoa.DonGiaNhap, _newhanghoa.DonGiaBan, _newhanghoa.GhiChu, _newhanghoa.MaHangHoa); Connect.ExcuteNonQuery(string.Format("UPDATE tb_Hanghoa" + " SET tenhang =N'{0}', manhom =N'{1}', madonvi =N'{2}', manuoc =N'{3}', dongianhap ='{4}', dongiaban ='{5}', ghichu ='{6}' where mahang=N'{7}'", _newhanghoa.TenHangHoa, _newhanghoa.MaNhom, _newhanghoa.MaDonVi, _newhanghoa.MaNuoc, _newhanghoa.DonGiaNhap, _newhanghoa.DonGiaBan, _newhanghoa.GhiChu, _newhanghoa.MaHangHoa)); //cmd.Parameters.Add(new SqlParameter("@hinhanh", (object)_hanghoa.HinhAnh)); //Connect.SqlConnect.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void AddHangHoa(EC_HangHoa _newhanghoa) { try { Connect.SqlConnect.Open(); string sqlquery = @"INSERT INTO tb_Hanghoa (mahang, tenhang, manhom, madonvi, manuoc, dongianhap, dongiaban, ghichu) VALUES (N'{0}',N'{1}',N'{2}',N'{3}',N'{4}','{5}','{6}','{7}')" ; sqlquery = string.Format(sqlquery, _newhanghoa.MaHangHoa, _newhanghoa.TenHangHoa, _newhanghoa.MaNhom, _newhanghoa.MaDonVi, _newhanghoa.MaNuoc, _newhanghoa.DonGiaNhap, _newhanghoa.DonGiaBan, _newhanghoa.GhiChu); SqlCommand cmd = new SqlCommand(sqlquery, Connect.SqlConnect); //cmd.Parameters.Add(new SqlParameter("@hinhanh", (object)_newhanghoa.HinhAnh)); cmd.ExecuteNonQuery(); //Connect.ExcuteNonQuery(sqlquery); Connect.SqlConnect.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void DeleteHangHoa(EC_HangHoa _hanghoa) { Connect.ExcuteNonQuery("DELETE FROM [tb_Hanghoa] WHERE mahang=N'" + _hanghoa.MaHangHoa + "'"); }
public void DeleteSP(EC_HangHoa _sp) { sqlhanghoa.DeleteHangHoa(_sp); }
public void UpdateSP(EC_HangHoa _sp) { sqlhanghoa.UpdateHangHoa(_sp); }
public DataTable CreateTbHH(EC_HangHoa _hh) { return(sqlhanghoa.CreateTbHH(_hh)); }