public int Insert(Entities.TheGiamGia pb1) { try { pb = new Constants.TheGiamGia(); Sql = new Constants.Sql(); string sql = Sql.InsertTheGiamGia; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(pb.HanhDong, SqlDbType.NVarChar, 50).Value = pb1.HanhDong; cmd.Parameters.Add(pb.MaTheGiamGia, SqlDbType.VarChar, 50).Value = pb1.MaTheGiamGia; cmd.Parameters.Add(pb.MaKhachHang, SqlDbType.VarChar, 50).Value = pb1.MaKhachHang; cmd.Parameters.Add(pb.GiaTriThe, SqlDbType.Float).Value = pb1.GiaTriThe; cmd.Parameters.Add(pb.NgayBatDau, SqlDbType.DateTime).Value = pb1.NgayBatDau; cmd.Parameters.Add(pb.NgayKetThuc, SqlDbType.DateTime).Value = pb1.NgayKetThuc; cmd.Parameters.Add(pb.Deleted, SqlDbType.Bit).Value = pb1.Deleted; int i = cmd.ExecuteNonQuery(); cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return i; } catch (Exception ex) { string s = ex.Message; return 0; } }
public void Delete(Entities.TKNganHang tk1) { try { TKNH = new Constants.TKNganHang(); Entities.TKNganHang TKNganHang = new Entities.TKNganHang(); Sql = new Constants.Sql(); string sql = Sql.DeleteTKNganHang; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(TKNH.HanhDong, SqlDbType.NVarChar, 20).Value = tk1.HanhDong; cmd.Parameters.Add(TKNH.TKNganHangID, SqlDbType.Int).Value = tk1.TKNganHangID; cmd.ExecuteNonQuery(); cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; } catch (Exception ex) { string s = ex.Message; } }
//delete public bool Delete(Entities.NhomHang NhomHang) { bool kt = false; try { nhh = new Constants.NhomHangHoa(); Entities.NhomHang nhomhanghoa = new Entities.NhomHang(); Sql = new Constants.Sql(); string sql = Sql.DeleteNhomHangHoa; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(nhh.HanhDong, SqlDbType.NVarChar, 20).Value = NhomHang.HanhDong; cmd.Parameters.Add(nhh.NhomHangID, SqlDbType.Int).Value = NhomHang.NhomHangID; int i = cmd.ExecuteNonQuery(); if (i == 1) kt = true; else kt = false; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return kt; } catch { return kt; } }
public int InsertUpdate(Entities.NhomTKKeToan pb1) { try { ntkkt = new Constants.NhomTKKeToan(); Sql = new Constants.Sql(); string sql = Sql.InsertUpdateNhomTKKeToan; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(ntkkt.HanhDong, SqlDbType.NVarChar, 20).Value = pb1.HanhDong; cmd.Parameters.Add(ntkkt.NhomTKKeToanID, SqlDbType.Int).Value = pb1.NhomTKKeToanID; cmd.Parameters.Add(ntkkt.MaNhomTKKeToan, SqlDbType.NVarChar, 20).Value = pb1.MaNhomTKKeToan; cmd.Parameters.Add(ntkkt.TenNhomTKKeToan, SqlDbType.NVarChar, 200).Value = pb1.TenNhomTKKeToan; cmd.Parameters.Add(ntkkt.GhiChu, SqlDbType.NVarChar, 100).Value = pb1.GhiChu; cmd.Parameters.Add(ntkkt.Deleted, SqlDbType.Bit).Value = pb1.Delete; int i = cmd.ExecuteNonQuery(); cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return i; } catch (Exception ex) { string s = ex.Message; return 0; } }
/// <summary> /// /// </summary> /// <param name="giatri"></param> /// <returns></returns> public int CapNhatDuNoKhachHang(Entities.TruyenGiaTri giatri) { int tra = 0; try { Sql = new Constants.Sql(); string sql = "exec sp_CapNhatDuNoKhachHang @MaKhachHang,@DuNo"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaKhachHang", SqlDbType.VarChar, 20).Value = giatri.Giatritruyen; cmd.Parameters.Add("DuNo", SqlDbType.Float).Value = giatri.Giatrithuhai; tra = cmd.ExecuteNonQuery(); } catch (Exception ex) { string s = ex.Message.ToString(); tra = 0; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return tra; }
public bool deleteNhomQuyen(Entities.NhomQuyen nq1) { try { bool kt = false; nq = new Constants.NhomQuyen(); Sql = new Constants.Sql(); string sql = Sql.deleteNhomQuyen; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(nq.TenNhomQuyen, SqlDbType.VarChar, 50).Value = nq1.TenNhomQuyen; int i = cmd.ExecuteNonQuery(); if (i >= 0) kt = true; else kt = false; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return kt; } catch (Exception ex) { string s = ex.Message; return false; } }
/// <summary> /// lay bang cong ty /// </summary> /// <param name="ct"></param> /// <returns></returns> public Entities.ThongTinCongTy sp_ThongTinCongTy(Entities.TruyenGiaTri ct) { Entities.ThongTinCongTy banghi = new Entities.ThongTinCongTy(); try { string sql = "exec sp_ThongTinCongTy @MaCongTy"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaCongTy", SqlDbType.VarChar, 20).Value = ct.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); ArrayList arr = new ArrayList(); while (dr.Read()) { banghi.MaCongTy = dr[0].ToString(); banghi.TenCongTy = dr[1].ToString(); banghi.DiaChi = dr[2].ToString(); banghi.SoDienThoai = dr[3].ToString(); banghi.Email = dr[4].ToString(); banghi.Website = dr[5].ToString(); banghi.Fax = dr[6].ToString(); } } catch (Exception ex) { string s = ex.Message.ToString(); banghi = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return banghi; }
public bool Delete(string maHDBanHang) { try { bool kt = false; hdbh = new Constants.HDBanHang(); Sql = new Constants.Sql(); string sql = Sql.DeleteHDBanHang; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("@maHDBanHang", SqlDbType.VarChar, 20).Value = maHDBanHang; int i = cmd.ExecuteNonQuery(); if (i == 1) kt = true; else kt = false; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return kt; } catch (Exception ex) { string s = ex.Message; return false; } }
/// <summary> /// /// </summary> /// <param name="gv"></param> /// <returns></returns> public bool Insert(Entities.GiaVonBanHang gv) { bool kt = false; try { string sql = Common.GiaVonBanHang.Insert; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(Common.GiaVonBanHang.MaHoaDon, SqlDbType.VarChar, 50).Value = gv.MaHoaDon; cmd.Parameters.Add(Common.GiaVonBanHang.MaHangHoa, SqlDbType.VarChar, 50).Value = gv.MaHangHoa; cmd.Parameters.Add(Common.GiaVonBanHang.GiaVon, SqlDbType.Float).Value = gv.GiaVon; int i = cmd.ExecuteNonQuery(); if (i == 1) kt = true; else kt = false; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return kt; } catch (Exception ex) { string s = ex.Message; return false; } }
public int Delete(Entities.TheGiamGia pb1) { try { pb = new Constants.TheGiamGia(); Sql = new Constants.Sql(); string sql = Sql.DeleteTheGiamGia; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(pb.MaTheGiamGia, SqlDbType.VarChar, 50).Value = pb1.MaTheGiamGia; int i = cmd.ExecuteNonQuery(); cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return i; } catch (Exception ex) { string s = ex.Message; return 0; } }
/// <summary> /// Delete Bảng /// </summary> public int Delete(Entities.NhomKH nkh2) { int Trave = 0; try { nkh = new Constants.NhomKH(); Sql = new Constants.Sql(); string sql = Sql.DeleteNhomKH; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(nkh.HanhDong, SqlDbType.NVarChar, 20).Value = nkh2.Hanhdong.ToString(); cmd.Parameters.Add(nkh.NhomKHID, SqlDbType.Int).Value = nkh2.NhomKHID; Trave = cmd.ExecuteNonQuery(); } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return Trave; }
/// <summary> /// Delete Bảng /// </summary> public bool Delete(Entities.SoDuCongNo pxh) { try { bool kt = false; pt = new Constants.CongNo(); Sql = new Constants.Sql(); string sql = Sql.DeleteSoDuCongNo; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(pt.MaSoDuCongNo, SqlDbType.VarChar, 20).Value = pxh.MaSoDuCongNo; int i = cmd.ExecuteNonQuery(); if (i == 1) kt = true; else kt = false; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return kt; } catch { return false; } }
//==============Insert======================== public int InsertTyLeTinh(Entities.TyLeTinh input) { int bg = 0; try { con = new Connection(); cn = con.openConnection(); cmd = new SqlCommand("exec sp_TyLeTinh @ThaoTac,@MaTyLeTinh,@SoTien,@NgayNhap,@GhiChu,@Deleted", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "insert"; //set cmd.Parameters.Add("MaTyLeTinh", SqlDbType.VarChar).Value = input.MaTyLeTinh; cmd.Parameters.Add("SoTien", SqlDbType.Float).Value = input.SoTien; cmd.Parameters.Add("NgayNhap", SqlDbType.DateTime).Value = input.NgayNhap; cmd.Parameters.Add("GhiChu", SqlDbType.NVarChar).Value = input.GhiChu; cmd.Parameters.Add("Deleted", SqlDbType.Bit).Value = input.Deleted; bg = cmd.ExecuteNonQuery(); } catch (Exception) { bg = 0; } finally { cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); } if (bg == 0) return bg; return bg; }
/// <summary> /// Delete Bảng /// </summary> public bool Delete(Entities.PhieuTTCuaKH pttckh) { try { bool kt = false; pt = new Constants.PhieuTTCuaKH(); Sql = new Constants.Sql(); string sql = Sql.DeletePhieuTTCuaKH; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(pt.HanhDong, SqlDbType.NVarChar, 20).Value = pttckh.HanhDong; cmd.Parameters.Add(pt.PhieuTTCuaKHID, SqlDbType.Int).Value = pttckh.PhieuTTCuaKHID; int i = cmd.ExecuteNonQuery(); if (i == 1) kt = true; else kt = false; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return kt; } catch { return false; } }
//delete public int Delete(Entities.KhoHang kh1) { int tra = 0; try { kh = new Constants.KhoHang(); Entities.KhoHang khohang = new Entities.KhoHang(); Sql = new Constants.Sql(); string sql = Sql.DeleteKhoHang; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(kh.HanhDong, SqlDbType.NVarChar, 20).Value = kh1.HanhDong; cmd.Parameters.Add(kh.KhoHangID, SqlDbType.Int).Value = kh1.KhoHangID; tra = cmd.ExecuteNonQuery(); cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; } catch (Exception ex) { string s = ex.Message; tra = 0; } return tra; }
public void BackUp(string duongdan) { try { if (duongdan.Equals("")) { if (!Directory.Exists(duongdanFolder)) { Directory.CreateDirectory(duongdanFolder); } duongdan = duongdanFolder + "\\BUSuperMarketDHT-" + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + "_" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second + ".bak"; } string sql = "BACKUP DATABASE [SupermarketManagementDHT] TO DISK=N'" + duongdan + "'"; conn = new Connection(); cmd = new SqlCommand(); cmd.CommandText = sql; cmd.Connection = conn.openConnection(); cmd.ExecuteNonQuery(); } catch { } finally { cmd.Connection.Dispose(); cmd.Connection.Close(); cmd.Dispose(); conn.closeConnection(); } }
/// <summary> /// Deleted Update Bảng /// </summary> public bool Delete(Entities.ChiTietXuatHuy ctxh1) { try { bool kt = false; ctxh = new Constants.ChiTietXuatHuy(); Sql = new Constants.Sql(); string sql = Sql.DeleteChiTietXuatHuy; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(ctxh.HanhDong, SqlDbType.VarChar, 20).Value = ctxh1.HanhDong; cmd.Parameters.Add(ctxh.MaPhieuXuatHuy, SqlDbType.VarChar, 20).Value = ctxh1.MaPhieuXuatHuy; cmd.Parameters.Add(ctxh.MaHangHoa, SqlDbType.VarChar, 50).Value = ctxh1.MaHangHoa; int i = cmd.ExecuteNonQuery(); if (i == 1) kt = true; else kt = false; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return kt; } catch (Exception ex) { string s = ex.Message; return false; } }
public bool deleteTaiKhoan(Entities.TaiKhoan tk1) { try { bool kt = false; tk = new Constants.TaiKhoan(); Sql = new Constants.Sql(); string sql = Sql.deleteTaiKhoan; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(tk.TenDangNhap, SqlDbType.VarChar, 200).Value = tk1.TenDangNhap; int i = cmd.ExecuteNonQuery(); if (i >= 0) kt = true; else kt = false; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return kt; } catch (Exception ex) { string s = ex.Message; return false; } }
/// <summary> /// Select Bảng /// </summary> /// <returns></returns> public object Select(Entities.LayID lid1) { Sql = new Constants.Sql(); string sql = Sql.LayID; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("@table", SqlDbType.NVarChar, 50).Value = lid1.TenBang; SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); //Fix 14/01/2013 string phandau = string.Empty; string max = "0"; while (dr.Read()) { string[] temp = dr["ID"].ToString().Split('_'); if (string.IsNullOrEmpty(phandau)) phandau = temp[0]; if (max.Equals("0")) max = temp[1]; try { int ss = int.Parse(temp[1]); int _max = int.Parse(max); max = _max < ss ? temp[1] : max; } catch { } } Entities.LayID arrC = new Entities.LayID(); arrC.ID = phandau + "_" + max; if (string.IsNullOrEmpty(phandau)) return null; //End Fix 14/01/2013 ////Insert Category into ArrayList //ArrayList arr = new ArrayList(); //while (dr.Read()) //{ // Entities.LayID lid = new Entities.LayID(); // lid.ID = dr["ID"].ToString(); // arr.Add(lid); //} //int n = arr.Count; //if (n == 0) return null; //Entities.LayID arrC = new Entities.LayID(); //for (int i = 0; i < n; i++) //{ // arrC = (Entities.LayID)arr[i]; //} ////Giai phong bo nho //arr = null; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return arrC; }
//==============Select======================== public Entities.DiemThuongKhachHang[] SelectDiemThuongKhachHang(Entities.DiemThuongKhachHang input) { Entities.DiemThuongKhachHang[] list = null; try { con = new Connection(); cn = con.openConnection(); cmd = new SqlCommand("exec sp_DiemThuongKhachHang @ThaoTac,@MaDiemThuongKhachHang,@MaKhachHang,@TenKhachHang,@TongDiem,@DiemDaDung,@DiemConLai,@GhiChu,@Deleted", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = input.ThaoTac; //set cmd.Parameters.Add("MaDiemThuongKhachHang", SqlDbType.VarChar).Value = input.MaDiemThuongKhachHang; cmd.Parameters.Add("MaKhachHang", SqlDbType.VarChar).Value = input.MaKhachHang; cmd.Parameters.Add("TenKhachHang", SqlDbType.NVarChar).Value = input.TenKhachHang; cmd.Parameters.Add("TongDiem", SqlDbType.Int).Value = input.TongDiem; cmd.Parameters.Add("DiemDaDung", SqlDbType.Int).Value = input.DiemDaDung; cmd.Parameters.Add("DiemConLai", SqlDbType.Int).Value = input.DiemConLai; cmd.Parameters.Add("GhiChu", SqlDbType.NVarChar).Value = input.GhiChu; cmd.Parameters.Add("Deleted", SqlDbType.Bit).Value = input.Deleted; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.DiemThuongKhachHang row = new Entities.DiemThuongKhachHang(); row.MaDiemThuongKhachHang = dr["MaDiemThuongKhachHang"].ToString(); row.MaKhachHang = dr["MaKhachHang"].ToString(); row.TenKhachHang = dr["TenKhachHang"].ToString(); row.TongDiem = int.Parse(dr["TongDiem"].ToString()); row.DiemDaDung = int.Parse(dr["DiemDaDung"].ToString()); row.DiemConLai = int.Parse(dr["DiemConLai"].ToString()); row.GhiChu = dr["GhiChu"].ToString(); row.Deleted = bool.Parse(dr["Deleted"].ToString()); arr.Add(row); } int n = arr.Count; if (n == 0) list = null; list = new Entities.DiemThuongKhachHang[n]; for (int i = 0; i < n; i++) { list[i] = (Entities.DiemThuongKhachHang)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); list = null; } finally { cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); } return list; }
//==============Select======================== public Entities.ChiTietTheGiamGia[] SelectChiTietTheGiamGia(Entities.ChiTietTheGiamGia input) { Entities.ChiTietTheGiamGia[] list = null; try { con = new Connection(); cn = con.openConnection(); cmd = new SqlCommand("exec sp_ChiTietTheGiamGia @ThaoTac,@MaTheGiamGia,@MaKhachHang,@TenKhachHang,@GiaTriThe,@NgayThu,@MaPhieuThu,@Deleted", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = input.ThaoTac; //set cmd.Parameters.Add("MaTheGiamGia", SqlDbType.VarChar).Value = input.MaTheGiamGia; cmd.Parameters.Add("MaKhachHang", SqlDbType.VarChar).Value = input.MaKhachHang; cmd.Parameters.Add("TenKhachHang", SqlDbType.NVarChar).Value = input.TenKhachHang; cmd.Parameters.Add("GiaTriThe", SqlDbType.Float).Value = input.GiaTriThe; cmd.Parameters.Add("NgayThu", SqlDbType.DateTime).Value = input.NgayThu; cmd.Parameters.Add("MaPhieuThu", SqlDbType.VarChar).Value = input.MaPhieuThu; cmd.Parameters.Add("Deleted", SqlDbType.Bit).Value = input.Deleted; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.ChiTietTheGiamGia row = new Entities.ChiTietTheGiamGia(); row.MaTheGiamGia = dr["MaTheGiamGia"].ToString(); row.MaKhachHang = dr["MaKhachHang"].ToString(); row.TenKhachHang = dr["TenKhachHang"].ToString(); row.GiaTriThe = float.Parse(dr["GiaTriThe"].ToString()); row.NgayThu = DateTime.Parse(dr["NgayThu"].ToString()); row.MaPhieuThu = dr["MaPhieuThu"].ToString(); row.Deleted = bool.Parse(dr["Deleted"].ToString()); arr.Add(row); } int n = arr.Count; if (n == 0) list = null; list = new Entities.ChiTietTheGiamGia[n]; for (int i = 0; i < n; i++) { list[i] = (Entities.ChiTietTheGiamGia)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); list = null; } finally { cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); } return list; }
public bool Delete(Entities.TheVip thevip) { bool trave = false; try { string sql = new Common.Constants.Sql().deleteTheVip; conn = new Connection(); Constants.TheVip tv = new Constants.TheVip(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(tv.MaThe, SqlDbType.VarChar, 50).Value = thevip.MaThe.ToUpper(); int i = cmd.ExecuteNonQuery(); if (i == 1) { trave = true; } cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } catch (Exception ex) { string s = ex.Message.ToString(); trave = false; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return trave; }
/// <summary> /// Select Bảng /// </summary> /// <returns></returns> public Entities.BCDTTheoNhanVien[] Select(Entities.BCDTTheoNhanVien bcdtt) { Sql = new Constants.Sql(); dttnv = new Constants.BCDTTheoNhanVien(); string sql = Sql.BCDTTheoNhanVienTheoMa; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("@ID", SqlDbType.VarChar,20).Value = bcdtt.MaNhanVien; cmd.Parameters.Add("@Truoc", SqlDbType.DateTime).Value = bcdtt.Truoc; cmd.Parameters.Add("@Sau", SqlDbType.DateTime).Value = bcdtt.Sau; SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); //Insert Category into ArrayList ArrayList arr = new ArrayList(); while (dr.Read()) { Entities.BCDTTheoNhanVien bcdtnv1 = new Entities.BCDTTheoNhanVien(); bcdtnv1.MaNhanVien = dr[dttnv.MaNhanVien].ToString(); bcdtnv1.TenNhanVien = dr[dttnv.TenNhanVien].ToString(); bcdtnv1.MaHDBanHang = dr[dttnv.MaHDBanHang].ToString(); bcdtnv1.NgayBan = Convert.ToDateTime(dr[dttnv.NgayBan].ToString()); bcdtnv1.ThanhToanNgay = double.Parse(dr[dttnv.ThanhToanNgay].ToString()); bcdtnv1.ThanhToanKhiLapPhieu = double.Parse(dr[dttnv.ThanhToanKhiLapPhieu].ToString()); bcdtnv1.TongTienThanhToan = double.Parse(dr["TongTienThanhToan"].ToString()); bcdtnv1.GiaTriThe = double.Parse(dr["GiaTriThe"].ToString()); bcdtnv1.GiaTriTheGiaTri = double.Parse(dr["GiaTriTheGiaTri"].ToString()); arr.Add(bcdtnv1); } int n = arr.Count; if (n == 0) return null; Entities.BCDTTheoNhanVien[] arrC = new Entities.BCDTTheoNhanVien[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.BCDTTheoNhanVien)arr[i]; } //Giai phong bo nho arr = null; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return arrC; }
public void Delete(Entities.PhongBan pb1) { pb = new Constants.PhongBan(); Sql = new Constants.Sql(); string sql = Sql.DeletePhongBan; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(pb.HanhDong, SqlDbType.NVarChar, 20).Value = pb1.HanhDong; cmd.Parameters.Add(pb.PhongBanID, SqlDbType.Int).Value = pb1.PhongBanID; cmd.ExecuteNonQuery(); cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; }
//delete public void Delete(Entities.CapNhatGia kh1) { cng = new Constants.CapNhatGia(); Entities.CapNhatGia capnhatgia = new Entities.CapNhatGia(); Sql = new Constants.Sql(); string sql = Sql.DeleteKhoHang; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(cng.HanhDong, SqlDbType.NVarChar, 20).Value = kh1.HanhDong; cmd.Parameters.Add(cng.CapNhatGiaID, SqlDbType.Int).Value = kh1.CapNhatGiaID; cmd.ExecuteNonQuery(); cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; }
//delete public void Delete(Entities.LoaiThue LoaiThue) { lt = new Constants.LoaiThue(); Entities.LoaiThue loaithue = new Entities.LoaiThue(); Sql = new Constants.Sql(); string sql = Sql.DeleteLoaiThue; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(lt.HanhDong, SqlDbType.NVarChar, 20).Value = LoaiThue.HanhDong; cmd.Parameters.Add(lt.LoaiThueID, SqlDbType.Int).Value = LoaiThue.LoaiThueID; cmd.ExecuteNonQuery(); cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; }
/// <summary> /// Select Bảng /// </summary> /// <returns></returns> public Entities.BCTonKhoTheoKho[] Select(Entities.BCTonKhoTheoKho bctktk1) { Sql = new Constants.Sql(); bctktk = new Constants.BCTonKhoTheoKho(); string sql = Sql.selectBCTonKhoTheoKhoTheoMa; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("@MaKho", SqlDbType.VarChar, 20).Value = bctktk1.MaKho; SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); //Insert Category into ArrayList ArrayList arr = new ArrayList(); while (dr.Read()) { Entities.BCTonKhoTheoKho bctktkk = new Entities.BCTonKhoTheoKho(); bctktkk.MaKho = dr[bctktk.MaKho].ToString(); bctktkk.TenKho = dr[bctktk.TenKho].ToString(); bctktkk.MaHangHoa = dr[bctktk.MaHangHoa].ToString(); bctktkk.TenHangHoa = dr[bctktk.TenHangHoa].ToString(); bctktkk.NgayNhap = DateTime.Parse(dr[bctktk.NgayNhap].ToString()); bctktkk.HanSuDung = DateTime.Parse(dr[bctktk.HanSuDung].ToString()); bctktkk.SoLuong = Convert.ToInt32(dr[bctktk.SoLuong].ToString()); arr.Add(bctktkk); } int n = arr.Count; if (n == 0) return null; Entities.BCTonKhoTheoKho[] arrC = new Entities.BCTonKhoTheoKho[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.BCTonKhoTheoKho)arr[i]; } //Giai phong bo nho arr = null; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return arrC; }
//delete public void Delete(Entities.LoaiHangHoa lhh1) { lhh = new Constants.LoaiHangHoa(); Entities.LoaiHangHoa loaihanghoa = new Entities.LoaiHangHoa(); Sql = new Constants.Sql(); string sql = Sql.DeleteLoaiHangHoa; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(lhh.HanhDong, SqlDbType.NVarChar, 20).Value = lhh1.HanhDong; cmd.Parameters.Add(lhh.LoaiHangID, SqlDbType.Int).Value = lhh1.LoaiHangID; cmd.ExecuteNonQuery(); cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; }
//delete public void Delete(Entities.DVT dvt1) { dvt = new Constants.DVT(); Entities.DVT loaihanghoa = new Entities.DVT(); Sql = new Constants.Sql(); string sql = Sql.DeleteDVT; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(dvt.HanhDong, SqlDbType.NVarChar, 20).Value = dvt1.HanhDong; cmd.Parameters.Add(dvt.DVTID, SqlDbType.Int).Value = dvt1.DVTID; cmd.ExecuteNonQuery(); cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; }
//Entities public Entities.ThongTinMaVach[] sp_LayBang_ThongTinMaVachHangHoa() { Entities.ThongTinMaVach[] arrC = null; try { string sql = "exec sp_LayBang_ThongTinMaVachHangHoa"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { mavach = new Entities.ThongTinMaVach(); mavach.ChonIn = false; mavach.MaHangHoa = dr[0].ToString(); mavach.TenHangHoa = dr[1].ToString(); mavach.GiaNhap = dr[2].ToString(); mavach.GiaBanBuon = dr[3].ToString(); mavach.GiaBanLe = dr[4].ToString(); mavach.GhiChu = ""; arr.Add(mavach); } int n = arr.Count; if (n == 0) { arrC= null; } arrC = new Entities.ThongTinMaVach[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.ThongTinMaVach)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); arrC = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return arrC; }