/// <summary> /// Cập nhật dữ liệu vào bảng: tienthanhtoanphieunhap /// </summary> /// <param name="obj">objtienthanhtoanphieunhap</param> /// <returns>Trả về trắng: Cập nhật thành công; Trả về khác trắng: Cập nhật không thành công</returns> public string Update(tienthanhtoanphieunhap objtienthanhtoanphieunhap) { string strProc = "fn_tienthanhtoanphieunhap_update"; try { NpgsqlParameter[] prmArr = new NpgsqlParameter[6]; prmArr[0] = new NpgsqlParameter("id", NpgsqlDbType.Varchar); prmArr[0].Value = objtienthanhtoanphieunhap.strid; prmArr[1] = new NpgsqlParameter("idpn", NpgsqlDbType.Varchar); prmArr[1].Value = objtienthanhtoanphieunhap.stridpn; prmArr[2] = new NpgsqlParameter("ngaytt", NpgsqlDbType.Varchar); prmArr[2].Value = objtienthanhtoanphieunhap.dtmngaytt.ToString("yyyy/MM/dd HH:mm:ss"); prmArr[3] = new NpgsqlParameter("tientt", NpgsqlDbType.Double); prmArr[3].Value = objtienthanhtoanphieunhap.dbltientt; prmArr[4] = new NpgsqlParameter("ghichu", NpgsqlDbType.Varchar); prmArr[4].Value = objtienthanhtoanphieunhap.strghichu; prmArr[5] = new NpgsqlParameter("ireturn", NpgsqlDbType.Text); prmArr[5].Direction = ParameterDirection.Output; mDataAccess.ExecuteQuery(strProc, CommandType.StoredProcedure, prmArr); string sKQ = prmArr[5].Value.ToString().Trim(); if (sKQ.ToUpper().Equals("Update".ToUpper()) == true) { return(""); } return("Cập nhật dữ liệu không thành công"); } catch (Exception ex) { return("Cập nhật dữ liệu không thành công. Chi Tiết: " + ex.Message); } }
/// <summary> /// Hàm lấy tất cả dữ liệu trong bảng tienthanhtoanphieunhap /// </summary> /// <returns>Trả về List<<tienthanhtoanphieunhap>></returns> public List <tienthanhtoanphieunhap> GetList() { List <tienthanhtoanphieunhap> list = new List <tienthanhtoanphieunhap>(); string strFun = "fn_tienthanhtoanphieunhap_getall"; try { DataSet dstienthanhtoanphieunhap = mDataAccess.ExecuteDataSet(strFun, CommandType.StoredProcedure); if ((dstienthanhtoanphieunhap != null) && (dstienthanhtoanphieunhap.Tables.Count > 0)) { for (int i = 0; i < dstienthanhtoanphieunhap.Tables[0].Rows.Count; i++) { tienthanhtoanphieunhap objtienthanhtoanphieunhap = new tienthanhtoanphieunhap(); DataRow dr = dstienthanhtoanphieunhap.Tables[0].Rows[i]; objtienthanhtoanphieunhap.id = dr["id"].ToString(); objtienthanhtoanphieunhap.idpn = dr["idpn"].ToString(); try { objtienthanhtoanphieunhap.ngaytt = Convert.ToDateTime(dr["ngaytt"].ToString()); } catch { objtienthanhtoanphieunhap.ngaytt = new DateTime(1900, 1, 1); } try { objtienthanhtoanphieunhap.tientt = Convert.ToDouble("0" + dr["tientt"].ToString()); } catch { objtienthanhtoanphieunhap.tientt = 0; } objtienthanhtoanphieunhap.ghichu = dr["ghichu"].ToString(); list.Add(objtienthanhtoanphieunhap); } return(list); } return(null); } catch { return(null); } }
/// <summary> /// Hàm lấy object tienthanhtoanphieunhap theo mã /// </summary> /// <returns>Trả về objttienthanhtoanphieunhap </returns> public tienthanhtoanphieunhap GetByID(string strid) { tienthanhtoanphieunhap obj = new tienthanhtoanphieunhap(); string strFun = "fn_tienthanhtoanphieunhap_getobjbyid"; try { NpgsqlParameter[] prmArr = new NpgsqlParameter[1]; prmArr[0] = new NpgsqlParameter("id", NpgsqlDbType.Varchar); prmArr[0].Value = strid; DataSet ds = mDataAccess.ExecuteDataSet(strFun, CommandType.StoredProcedure, prmArr); if ((ds != null) && (ds.Tables.Count > 0)) { if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; obj.id = dr["id"].ToString(); obj.idpn = dr["idpn"].ToString(); try { obj.ngaytt = Convert.ToDateTime(dr["ngaytt"].ToString()); } catch { obj.ngaytt = new DateTime(1900, 1, 1); } try { obj.tientt = Convert.ToDouble("0" + dr["tientt"].ToString()); } catch { obj.tientt = 0; } obj.ghichu = dr["ghichu"].ToString(); return(obj); } return(null); } return(null); } catch { return(null); } }
/// <summary> /// Hàm lấy danh sách objtienthanhtoanphieunhap /// </summary> /// <param name="recperpage">Số lượng bản ghi kiểu integer</param> /// <param name="pageindex">Số trang kiểu integer</param> /// <returns>Trả về List<<tienthanhtoanphieunhap>></returns> public List <tienthanhtoanphieunhap> GetListPaged(int recperpage, int pageindex) { List <tienthanhtoanphieunhap> list = new List <tienthanhtoanphieunhap>(); string strFun = "fn_tienthanhtoanphieunhap_getpaged"; try { NpgsqlParameter[] prmArr = new NpgsqlParameter[2]; prmArr[0] = new NpgsqlParameter("recperpage", NpgsqlDbType.Integer); prmArr[0].Value = recperpage; prmArr[1] = new NpgsqlParameter("pageindex", NpgsqlDbType.Integer); prmArr[1].Value = pageindex; DataSet dstienthanhtoanphieunhap = mDataAccess.ExecuteDataSet(strFun, CommandType.StoredProcedure, prmArr); if ((dstienthanhtoanphieunhap != null) && (dstienthanhtoanphieunhap.Tables.Count > 0)) { for (int i = 0; i < dstienthanhtoanphieunhap.Tables[0].Rows.Count; i++) { tienthanhtoanphieunhap objtienthanhtoanphieunhap = new tienthanhtoanphieunhap(); DataRow dr = dstienthanhtoanphieunhap.Tables[0].Rows[i]; objtienthanhtoanphieunhap.id = dr["id"].ToString(); objtienthanhtoanphieunhap.idpn = dr["idpn"].ToString(); try { objtienthanhtoanphieunhap.ngaytt = Convert.ToDateTime(dr["ngaytt"].ToString()); } catch { objtienthanhtoanphieunhap.ngaytt = new DateTime(1900, 1, 1); } try { objtienthanhtoanphieunhap.tientt = Convert.ToDouble("0" + dr["tientt"].ToString()); } catch { objtienthanhtoanphieunhap.tientt = 0; } objtienthanhtoanphieunhap.ghichu = dr["ghichu"].ToString(); list.Add(objtienthanhtoanphieunhap); } return(list); } return(null); } catch { return(null); } }