/// <summary> /// khoi tao gia tri /// </summary> public ChiTietKiemKeKho() { dh = null; Sql = null; conn = null; cmd = null; arr = null; dr = null; cn = null; }
/// <summary> /// Delete /// </summary> /// <param name="maKiemKe"></param> /// <returns></returns> public int Delete(string maKiemKe) { int retVal = 0; try { Sql = new Constants.Sql(); string sql = Sql.sp_Xoa_ChiTietKiemKeKho; conn = new Connection(); cn = conn.openConnection(); dh = new Constants.ChiTietKiemKeKho(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(dh.HanhDong, SqlDbType.NVarChar, 20).Value = "MaPhieuKiemKe"; cmd.Parameters.Add(dh.MaPhieuKiemKe, SqlDbType.VarChar, 20).Value = maKiemKe; cmd.Parameters.Add(dh.MaHangHoa, SqlDbType.VarChar).Value = string.Empty; retVal = cmd.ExecuteNonQuery(); } catch { retVal = 0; } return retVal; }
/// <summary> /// vuong hung =================xu ly don dat hang================ /// </summary> /// <returns></returns> public int sp_XuLy_ChiTietKiemKeKho(Entities.ChiTietKiemKeKho ddh) { int Trave = 0; try { Sql = new Constants.Sql(); string sql = Sql.sp_XuLy_ChiTietKiemKeKho; conn = new Connection(); cn = conn.openConnection(); dh = new Constants.ChiTietKiemKeKho(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add(dh.HanhDong, SqlDbType.NVarChar, 20).Value = ddh.Hanhdong; cmd.Parameters.Add(dh.MaPhieuKiemKe, SqlDbType.VarChar, 20).Value = ddh.MaPhieuKiemKe; cmd.Parameters.Add(dh.MaHangHoa, SqlDbType.VarChar).Value = ddh.MaHangHoa; cmd.Parameters.Add(dh.TonThucTe, SqlDbType.Int).Value = ddh.TonThucTe; cmd.Parameters.Add(dh.TonSoSach, SqlDbType.Float, 20).Value = ddh.TonSoSach; cmd.Parameters.Add(dh.LyDo, SqlDbType.NVarChar).Value = ddh.LyDo; cmd.Parameters.Add(dh.GhiChu, SqlDbType.NVarChar).Value = ddh.GhiChu; cmd.Parameters.Add(dh.Deleted, SqlDbType.Bit).Value = ddh.Deleted; Trave = cmd.ExecuteNonQuery(); } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return Trave; }
/// <summary> /// vuong hung =================lay bang DonDatHang================ /// </summary> /// <returns></returns> public Entities.ChiTietKiemKeKho[] sp_LayBang_ChiTietKiemKeKho(Entities.ChiTietKiemKeKho kk) { Entities.ChiTietKiemKeKho[] arrC = null; try { dh = new Constants.ChiTietKiemKeKho(); Sql = new Constants.Sql(); string sql = Sql.sp_LayBang_ChiTietKiemKeKho; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaPhieuKiemKe", SqlDbType.NVarChar, 20).Value = kk.MaPhieuKiemKe; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); if (kk.MaPhieuKiemKe.Length <= 0) { while (dr.Read()) { Entities.ChiTietKiemKeKho chitietkiemkekho = new Entities.ChiTietKiemKeKho(); chitietkiemkekho.MaPhieuKiemKe = dr[dh.MaPhieuKiemKe].ToString().ToUpper(); chitietkiemkekho.MaHangHoa = dr[dh.MaHangHoa].ToString().ToUpper(); chitietkiemkekho.TonThucTe = int.Parse(0 + dr[dh.TonThucTe].ToString()).ToString(); chitietkiemkekho.TonSoSach = int.Parse(0 + dr[dh.TonSoSach].ToString()).ToString(); chitietkiemkekho.LyDo = "" + dr[dh.LyDo].ToString(); chitietkiemkekho.GhiChu = "" + dr[dh.GhiChu].ToString(); chitietkiemkekho.Deleted = Convert.ToBoolean(dr[dh.Deleted].ToString()); arr.Add(chitietkiemkekho); } } int n = arr.Count; if (n == 0) { return null; } arrC = new Entities.ChiTietKiemKeKho[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.ChiTietKiemKeKho)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return arrC; }