public Result<bool> insert_chitietphieu(chitietphieu_ett chitietphieu) { Result<bool> rs = new Result<bool>(); try { // create new tbl_chitietphieu to insert to database_context tbl_chitietphieu temp = new tbl_chitietphieu(); temp.sophieumuon = chitietphieu.sophieumuon; temp.masach = chitietphieu.masach; temp.trangthaisach = chitietphieu.trangthaisach; db.tbl_chitietphieus.InsertOnSubmit(temp); db.SubmitChanges(); rs.data = true; rs.errcode = ErrorCode.sucess; return rs; } catch (Exception e) { rs.data = false; rs.errcode = ErrorCode.fail; rs.errInfor = e.ToString(); return rs; } }
private void get_ds_sach() { get_info(); var data = dtgv_sachmuon.Rows; foreach (DataGridViewRow item in data) { chitietphieu_ett temp = new chitietphieu_ett(); if (item.Cells[0].Value == null) { break; } temp.sophieumuon = phieumuontra_ett.sophieumuon; temp.masach = int.Parse(item.Cells[0].Value.ToString()); if (item.Cells[1].Value == null) { temp.trangthaisach = "Bình thường"; } else temp.trangthaisach = item.Cells[1].Value.ToString(); chitietphieu.Add(temp); } }
public Result<List<chitietphieu_ett>> select_all_chitietphieu_by_sopm(int sopm) { Result<List<chitietphieu_ett>> rs = new Result<List<chitietphieu_ett>>(); try { List<chitietphieu_ett> lst = new List<chitietphieu_ett>(); var dt = db.tbl_chitietphieus.Where(o => o.sophieumuon == sopm); if (dt.Count() > 0) { foreach (tbl_chitietphieu item in dt) { chitietphieu_ett temp = new chitietphieu_ett(item); lst.Add(temp); } rs.data = lst; rs.errcode = ErrorCode.sucess; } else { rs.data = null; rs.errInfor = Constants.empty_data; } return rs; } catch (Exception e) { rs.data = null; rs.errInfor = e.ToString(); rs.errcode = ErrorCode.fail; return rs; } }