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; } }
public ChiTietPhieuDieuChuyenKho() { ctpdck = null; Sql = null; conn = null; cmd = null; arr = null; dr = null; cn = null; }
public Entities.ChiTietPhieuDieuChuyenKho[] SelectTheoMaPhieu(string maPDCK) { Entities.ChiTietPhieuDieuChuyenKho[] arrC = null; try { ctpdck = new Constants.ChiTietPhieuDieuChuyenKho(); string sql = ""; sql = "select * from ChiTietPhieuDieuChuyenKho where MaPhieuDieuChuyenKho='"+maPDCK+"' and Deleted=0"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.ChiTietPhieuDieuChuyenKho CTphieudieuchuyen = new Entities.ChiTietPhieuDieuChuyenKho(); CTphieudieuchuyen.MaPhieuDieuChuyenKho = dr[ctpdck.MaPhieuDieuChuyenKho].ToString(); CTphieudieuchuyen.MaHangHoa = dr[ctpdck.MaHangHoa].ToString(); CTphieudieuchuyen.SoLuong = int.Parse(dr[ctpdck.SoLuong].ToString()); CTphieudieuchuyen.GhiChu = dr[ctpdck.GhiChu].ToString(); CTphieudieuchuyen.Deleted = (Boolean)dr[ctpdck.Deleted]; arr.Add(CTphieudieuchuyen); } int n = arr.Count; if (n == 0) { return null; } arrC = new Entities.ChiTietPhieuDieuChuyenKho[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.ChiTietPhieuDieuChuyenKho)arr[i]; } for (int i = 0; i < n; i++) { arrC[i].NgayHetHan = LayHSD(arrC[i].MaPhieuDieuChuyenKho, arrC[i].MaHangHoa); } } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return arrC; }