/// <summary> /// Insert Update Bảng /// </summary> public bool Insert(Entities.SoDuKho pxh) { try { bool kt = false; sdk = new Constants.SoDuKho(); Sql = new Constants.Sql(); string sql = Sql.InsertUpdateSoDuKho; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(sdk.HanhDong, SqlDbType.VarChar, 20).Value = pxh.HanhDong; cmd.Parameters.Add(sdk.SoDuKhoID, SqlDbType.Int).Value = pxh.SoDuKhoID; cmd.Parameters.Add(sdk.MaSoDuKho, SqlDbType.VarChar, 20).Value = pxh.MaSoDuKho; cmd.Parameters.Add(sdk.MaKho, SqlDbType.VarChar, 20).Value = pxh.MaKho; cmd.Parameters.Add(sdk.MaHangHoa, SqlDbType.VarChar, 50).Value = pxh.MaHangHoa; cmd.Parameters.Add(sdk.SoDuDauKy, SqlDbType.Int).Value = pxh.SoDuDauKy; cmd.Parameters.Add(sdk.NgayKetChuyen, SqlDbType.DateTime).Value = pxh.NgayKetChuyen; cmd.Parameters.Add(sdk.SoDuCuoiKy, SqlDbType.Int).Value = pxh.SoDuCuoiKy; cmd.Parameters.Add(sdk.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; } }
/// <summary> /// Insert Update Bảng /// </summary> ////public bool Update(Entities.SoDuKho pxh) ////{ //// try //// { //// bool kt = false; //// sdk = new Constants.SoDuKho(); //// Sql = new Constants.Sql(); //// string sql = Sql.UpdateSoDuSoQuy; //// Connection conn = new Connection(); //// SqlConnection cn = conn.openConnection(); //// SqlCommand cmd = new SqlCommand(sql, cn); //// cmd.Parameters.Add(sdk.MaSoDuKho, SqlDbType.VarChar, 20).Value = pxh.MaSoDuSoQuy; //// cmd.Parameters.Add(sdk.SoDuDauKy, SqlDbType.VarChar, 20).Value = pxh.SoDuDauKy; //// 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; //// } ////} /// <summary> /// Insert Update Bảng /// </summary> ////public bool UpdateTrangThai(Entities.SoDuKho pxh) ////{ //// try //// { //// if (pxh.SoDuKhoID == 0) //// { //// Entities.SoDuKho sdsq = new Entities.SoDuKho("",1, pxh.MaSoDuKho, 0, pxh.NgayKetChuyen, pxh.SoDuCuoiKy, true); //// return Insert(sdsq); //// } //// bool kt = false; //// sdk = new Constants.SoDuKho(); //// Sql = new Constants.Sql(); //// string sql = Sql.UpdateSoDuSoQuy; //// Connection conn = new Connection(); //// SqlConnection cn = conn.openConnection(); //// SqlCommand cmd = new SqlCommand(sql, cn); //// cmd.Parameters.Add(sdk.SoDuKhoID, SqlDbType.Int).Value = pxh.SoDuSoQuyID; //// cmd.Parameters.Add(sdk.SoDuCuoiKy, SqlDbType.Float).Value = pxh.SoDuDauKy; //// int i = cmd.ExecuteNonQuery(); //// if (i == 1) //// kt = true; //// else //// kt = false; //// cmd.Connection.Dispose(); //// cn.Close(); //// conn.closeConnection(); //// cn = null; //// conn = null; //// Insert(pxh); //// return kt; //// } //// catch //// { //// return false; //// } ////} //// <summary> //// Delete Bảng //// </summary> public bool Delete(Entities.SoDuKho pxh) { try { bool kt = false; sdk = new Constants.SoDuKho(); Sql = new Constants.Sql(); string sql = "exec sp_DeleteSoDuKho @MaSoDuKho"; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(sdk.MaSoDuKho, SqlDbType.VarChar, 20).Value = pxh.MaSoDuKho; 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 { return false; } }