本文整理汇总了C#中DAL.Connection.openConnection方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.openConnection方法的具体用法?C# Connection.openConnection怎么用?C# Connection.openConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DAL.Connection
的用法示例。
在下文中一共展示了Connection.openConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CapNhatDuNoKhachHang
/// <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;
}
示例2: Delete
//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;
}
示例3: Delete
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;
}
}
示例4: InsertUpdate
public int InsertUpdate(Entities.KMThuChi km1)
{
try
{
Kmtc = new Constants.KMThuChi();
Sql = new Constants.Sql();
string sql = Sql.InsertUpdateKMThuChi;
Connection conn = new Connection();
SqlConnection cn = conn.openConnection();
SqlCommand cmd = new SqlCommand(sql, cn);
cmd.Parameters.Add(Kmtc.HanhDong, SqlDbType.NVarChar, 20).Value = km1.HanhDong;
cmd.Parameters.Add(Kmtc.ThuChiID, SqlDbType.Int).Value = km1.ThuChiID;
cmd.Parameters.Add(Kmtc.MaKhoanMuc, SqlDbType.NVarChar, 20).Value = km1.MaKhoanMuc;
cmd.Parameters.Add(Kmtc.TenKhoanMuc, SqlDbType.NVarChar, 200).Value = km1.TenKhoanMuc;
cmd.Parameters.Add(Kmtc.LoaiKM, SqlDbType.Bit).Value = km1.LoaiKM;
cmd.Parameters.Add(Kmtc.DoiTuong, SqlDbType.NVarChar, 200).Value = km1.DoiTuong;
cmd.Parameters.Add(Kmtc.NoTK, SqlDbType.VarChar, 20).Value = km1.NoTK;
cmd.Parameters.Add(Kmtc.CoTK, SqlDbType.VarChar, 20).Value = km1.CoTK;
cmd.Parameters.Add(Kmtc.GhiChu, SqlDbType.NVarChar, 200).Value = km1.GhiChu;
cmd.Parameters.Add(Kmtc.Deleted, SqlDbType.Bit).Value = km1.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; }
}
示例5: Delete
/// <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;
}
示例6: InsertUpdate
public int InsertUpdate(Entities.ChiTietPhieuDieuChuyenKho CTPhieuDCK)
{
try
{
ctpdck = new Constants.ChiTietPhieuDieuChuyenKho();
Sql = new Constants.Sql();
string sql = Sql.InsertUpdateChiTietPhieuDieuChuyenKho;
Connection conn = new Connection();
SqlConnection cn = conn.openConnection();
SqlCommand cmd = new SqlCommand(sql, cn);
cmd.Parameters.Add(ctpdck.HanhDong, SqlDbType.NVarChar, 20).Value = CTPhieuDCK.HanhDong;
cmd.Parameters.Add(ctpdck.MaPhieuDieuChuyenKho, SqlDbType.NVarChar, 20).Value = CTPhieuDCK.MaPhieuDieuChuyenKho;
cmd.Parameters.Add(ctpdck.MaHangHoa, SqlDbType.NVarChar, 50).Value = CTPhieuDCK.MaHangHoa;
cmd.Parameters.Add(ctpdck.SoLuong, SqlDbType.Int).Value = CTPhieuDCK.SoLuong;
cmd.Parameters.Add(ctpdck.GhiChu, SqlDbType.NVarChar, 100).Value = CTPhieuDCK.GhiChu;
cmd.Parameters.Add(ctpdck.Deleted, SqlDbType.Bit).Value = CTPhieuDCK.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;
}
}
示例7: Insert
/// <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;
}
}
示例8: BackUp
public void BackUp()
{
try
{
string path = duongdanFolder;
DirectoryInfo FI = new DirectoryInfo(path);
string fileName = "BUSuperMarketDHT" + DateTime.Now.ToString().Replace('/', '-').Replace(" ","_").Replace(":","_");
string sql = "BACKUP DATABASE [SupermarketManagementDHT] TO DISK=N'" + path + @"\" + fileName + "'";
if (!FI.Exists)
{
FI.Create();
}
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();
}
}
示例9: InsertUpdate
//insert update
public int InsertUpdate(Entities.CapNhatGia cng1)
{
cng = new Constants.CapNhatGia();
Sql = new Constants.Sql();
string sql = Sql.InsertUpdateCapNhatGia;
Connection conn = new Connection();
SqlConnection cn = conn.openConnection();
SqlCommand cmd = new SqlCommand(sql, cn);
cmd.Parameters.Add(cng.HanhDong, SqlDbType.NVarChar, 20).Value = cng1.HanhDong;
cmd.Parameters.Add(cng.CapNhatGiaID, SqlDbType.Int).Value = cng1.CapNhatGiaID;
cmd.Parameters.Add(cng.MaCapNhatGia, SqlDbType.NVarChar, 20).Value = cng1.MaCapNhatGia;
cmd.Parameters.Add(cng.NgayBatDau, SqlDbType.DateTime).Value = cng1.NgayBatDau;
cmd.Parameters.Add(cng.NgayKetThuc, SqlDbType.DateTime).Value = cng1.NgayKetThuc;
cmd.Parameters.Add(cng.MaHangHoa, SqlDbType.NVarChar,20).Value = cng1.MaHangHoa;
cmd.Parameters.Add(cng.PhanTramGiaBanBuon, SqlDbType.Float).Value = cng1.PhanTramGiaBanBuon;
cmd.Parameters.Add(cng.PhanTramGiaBanLe, SqlDbType.Float).Value = cng1.PhanTramGiaBanLe;
cmd.Parameters.Add(cng.GiaNhap, SqlDbType.Float).Value = cng1.GiaNhap;
cmd.Parameters.Add(cng.Trangthai, SqlDbType.Bit).Value = cng1.Trangthai;
cmd.Parameters.Add(cng.GhiChu, SqlDbType.NVarChar, 100).Value = cng1.GhiChu;
cmd.Parameters.Add(cng.Deleted, SqlDbType.Bit).Value = cng1.Deleted;
int i = cmd.ExecuteNonQuery();
cmd.Connection.Dispose();
cn.Close();
conn.closeConnection();
cn = null;
conn = null;
return i;
}
示例10: InsertUpdate
public int InsertUpdate(Entities.PhieuDieuChuyenKhoNoiBo PhieuDCK)
{
try
{
pdcknb = new Constants.PhieuDieuChuyenKhoNoiBo();
Sql = new Constants.Sql();
string sql = Sql.InsertUpdatePhieuDieuChuyenKhoNoiBo;
Connection conn = new Connection();
SqlConnection cn = conn.openConnection();
SqlCommand cmd = new SqlCommand(sql, cn);
cmd.Parameters.Add(pdcknb.HanhDong, SqlDbType.NVarChar, 20).Value = PhieuDCK.HanhDong;
cmd.Parameters.Add(pdcknb.PhieuDieuChuyenKhoID, SqlDbType.Int).Value = PhieuDCK.PhieuDieuChuyenKhoID;
cmd.Parameters.Add(pdcknb.MaPhieuDieuChuyenKho, SqlDbType.NVarChar, 20).Value = PhieuDCK.MaPhieuDieuChuyenKho;
cmd.Parameters.Add(pdcknb.NgayDieuChuyen, SqlDbType.DateTime).Value = PhieuDCK.NgayDieuChuyen;
cmd.Parameters.Add(pdcknb.TuKho, SqlDbType.VarChar, 20).Value = PhieuDCK.TuKho;
cmd.Parameters.Add(pdcknb.DenKho, SqlDbType.VarChar, 20).Value = PhieuDCK.DenKho;
cmd.Parameters.Add(pdcknb.MaHoaDonNhap, SqlDbType.VarChar, 20).Value = PhieuDCK.MaHoaDonNhap;
cmd.Parameters.Add(pdcknb.XacNhan, SqlDbType.Bit).Value = PhieuDCK.XacNhan;
cmd.Parameters.Add(pdcknb.GhiChu, SqlDbType.NVarChar, 100).Value = PhieuDCK.GhiChu;
cmd.Parameters.Add(pdcknb.Deleted, SqlDbType.Bit).Value = PhieuDCK.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;
}
}
示例11: InsertUpdate
public int InsertUpdate(Entities.PhongBan pb1)
{
try
{
pb = new Constants.PhongBan();
Sql = new Constants.Sql();
string sql = Sql.InsertUpdatePhongBan;
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.Parameters.Add(pb.MaPhongBan, SqlDbType.NVarChar, 20).Value = pb1.MaPhongBan;
cmd.Parameters.Add(pb.TenPhongBan, SqlDbType.NVarChar, 200).Value = pb1.TenPhongBan;
cmd.Parameters.Add(pb.GhiChu, SqlDbType.NVarChar, 100).Value = pb1.GhiChu;
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;
}
}
示例12: Insert
/// <summary>
/// Insert Update Bảng
/// </summary>
public bool Insert(Entities.SoDuSoQuy pxh)
{
try
{
bool kt = false;
pt = new Constants.SoQuy();
Sql = new Constants.Sql();
string sql = Sql.InsertSoDuSoQuy;
Connection conn = new Connection();
SqlConnection cn = conn.openConnection();
SqlCommand cmd = new SqlCommand(sql, cn);
cmd.Parameters.Add(pt.MaSoDuSoQuy, SqlDbType.VarChar, 20).Value = pxh.MaSoDuSoQuy;
cmd.Parameters.Add(pt.SoDuDauKy, SqlDbType.Float).Value = pxh.SoDuDauKy;
cmd.Parameters.Add(pt.NgayKetChuyen, SqlDbType.DateTime).Value = pxh.NgayKetChuyen;
cmd.Parameters.Add(pt.SoDuCuoiKy, SqlDbType.Float).Value = pxh.SoDuCuoiKy;
cmd.Parameters.Add(pt.TrangThai, SqlDbType.Bit).Value = pxh.TrangThai;
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;
}
}
示例13: Delete
//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;
}
}
示例14: InsertUpdate
public int InsertUpdate(Entities.QuyDoiDonViTinh nhom)
{
int rt = 0;
try
{
conn = new Connection();
SqlConnection cn = conn.openConnection();
SqlCommand cmd = new SqlCommand(Common.Constants.Sql.QuyDoiDonViTinh.InsertUpdateQuyDoiDonViTinh, cn);
cmd.Parameters.Add(Common.Constants.QuyDoiDonViTinh.HanhDong, SqlDbType.NVarChar).Value = nhom.HanhDong;
cmd.Parameters.Add(Common.Constants.QuyDoiDonViTinh.QuyDoiDonViTinhID, SqlDbType.Int).Value = nhom.QuyDoiDonViTinhID;
cmd.Parameters.Add(Common.Constants.QuyDoiDonViTinh.MaQuyDoiDonViTinh, SqlDbType.NVarChar, 50).Value = nhom.MaQuyDoiDonViTinh;
cmd.Parameters.Add(Common.Constants.QuyDoiDonViTinh.MaHangQuyDoi, SqlDbType.NVarChar, 50).Value = nhom.MaHangQuyDoi;
cmd.Parameters.Add(Common.Constants.QuyDoiDonViTinh.TenHangQuyDoi, SqlDbType.NVarChar, 200).Value = nhom.TenHangQuyDoi;
cmd.Parameters.Add(Common.Constants.QuyDoiDonViTinh.MaDonViTinh, SqlDbType.NVarChar, 50).Value = nhom.MaDonViTinh;
cmd.Parameters.Add(Common.Constants.QuyDoiDonViTinh.SoLuongQuyDoi, SqlDbType.Int).Value = nhom.SoLuongQuyDoi;
cmd.Parameters.Add(Common.Constants.QuyDoiDonViTinh.MaHangDuocQuyDoi, SqlDbType.NVarChar, 50).Value = nhom.MaHangDuocQuyDoi;
cmd.Parameters.Add(Common.Constants.QuyDoiDonViTinh.TenHangDuocQuyDoi, SqlDbType.NVarChar, 200).Value = nhom.TenHangDuocQuyDoi;
cmd.Parameters.Add(Common.Constants.QuyDoiDonViTinh.MaDonViTinhDuocQuyDoi, SqlDbType.NVarChar, 50).Value = nhom.MaDonViTinhDuocQuyDoi;
cmd.Parameters.Add(Common.Constants.QuyDoiDonViTinh.SoLuongDuocQuyDoi, SqlDbType.Int).Value = nhom.SoLuongDuocQuyDoi;
cmd.Parameters.Add(Common.Constants.QuyDoiDonViTinh.Deleted, SqlDbType.Bit).Value = nhom.Deleted;
rt = cmd.ExecuteNonQuery();
}
catch (Exception ex)
{ string s = ex.Message.ToString(); rt = 0; }
return rt;
}
示例15: Insert
/// <summary>
/// Insert
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public int Insert(Entities.KhuyenMaiSoLuong item)
{
int rt = 0;
try
{
conn = new Connection();
SqlConnection cn = conn.openConnection();
string sql = "exec sp_InsertKMSL @Id,@MaHangHoa,@TenHangHoa,@NgayBatDau,@NgayKetThuc,@SoLuong,@GiaBanBuon,@GiaBanLe";
SqlCommand cmd = new SqlCommand(sql, cn);
cmd.Parameters.Add("Id", SqlDbType.Int).Value = 0;
cmd.Parameters.Add("MaHangHoa", SqlDbType.VarChar, 50).Value = item.MaHangHoa;
cmd.Parameters.Add("TenHangHoa", SqlDbType.NVarChar, 200).Value = item.TenHangHoa;
cmd.Parameters.Add("NgayBatDau", SqlDbType.DateTime).Value = item.NgayBatDau;
cmd.Parameters.Add("NgayKetThuc", SqlDbType.DateTime).Value = item.NgayKetThuc;
cmd.Parameters.Add("SoLuong", SqlDbType.Float).Value = item.SoLuong;
cmd.Parameters.Add("GiaBanBuon", SqlDbType.Float).Value = item.GiaBanBuon;
cmd.Parameters.Add("GiaBanLe", SqlDbType.Float).Value = item.GiaBanLe;
rt = cmd.ExecuteNonQuery();
}
catch
{
rt = 0;
}
return rt;
}