// Search for order public void SearchOrder() { string srcTxt = txtName.Text; List <Orders> orderList = new List <Orders>(); List <Orders> orderList2 = new List <Orders>(); List <Books> bookList = new List <Books>(); using (var db = new LibData()) { orderList = db.Orders.Where(o => o.Clients.Name.ToLower().Contains(srcTxt.ToLower()) || o.Clients.Surname.ToLower().Contains(srcTxt.ToLower())).ToList(); bookList = db.AuthorsBooks.Where(ab => ab.Authors.Name.ToLower().Contains(srcTxt.ToLower()) || ab.Authors.Surname.ToLower().Contains(srcTxt.ToLower())).Select(b => b.Books).ToList(); if (orderList.Count > 0) { fillGrid(orderList); } if (bookList.Count > 0) { for (int i = 0; i < bookList.Count; i++) { int bookid = bookList[i].id; orderList2 = (db.Orders.Where(b => b.BookID == bookid)).ToList(); } } orderList.AddRange(orderList2); fillGrid(orderList); } }
// Update row public bool Update(Authors author, int oldID) { bool result = false; using (var db = new LibData()) { var selectedAuthor = db.Authors.Find(oldID); selectedAuthor.Name = author.Name; selectedAuthor.Surname = author.Surname; if (db.SaveChanges() != 0) { result = true; } else { result = false; } } if (result == true) { return(true); } return(false); }
/// <summary> /// /// </summary> /// <param name="sources"></param> /// <returns></returns> IList IImportData.AnalyzeFile(Dictionary <int, string> sources) { List <dynamic> result = new List <dynamic>(); DateTime now = DateTime.Now; string importBatchNo = $"MART{now.ToString("yyyyMMddhhmmss")}"; foreach (int line in sources.Keys) { if (LibData.ByteSubString(sources[line], 9, 3) == "I0O") { result.Add(new ReceiptInfoBillMarketSPIModel() { Id = line, Source = sources[line], ImportBatchNo = importBatchNo }); } else { result.Add(new ReceiptInfoBillMarketModel() { Id = line, Source = sources[line], ImportBatchNo = importBatchNo }); } } return(result); }
private string Template(dynamic set) { string tableTemplate = string.Empty; foreach (var table in set.Fields) { dynamic tableInst = Activator.CreateInstance(table.Type); if (tableInst is ListGraphType) { tableInst = Activator.CreateInstance(tableInst.Type); } else { tableTemplate += GetTableTemplate(tableInst, $"{tableInst.Name}List"); } tableTemplate += GetTableTemplate(tableInst, tableInst.Name); } return($@"import {{ gql }} from ""apollo-boost""; const {LibData.ToCamelCase(set.Name)}Fragment = {{ {tableTemplate} }}; export default {LibData.ToCamelCase(set.Name)}Fragment; "); }
// Update row public bool Update(Books book, int oldID) { bool result = false; using (var db = new LibData()) { var selectedBook = db.Books.Find(oldID); selectedBook.Name = book.Name; selectedBook.CategoryID = book.CategoryID; selectedBook.Count = book.Count; selectedBook.Price = book.Price; if (db.SaveChanges() != 0) { result = true; } else { result = false; } } if (result == true) { return(true); } return(false); }
// Update row public bool Update(AuthorsBooks authorBook, int bookId) { bool result = false; using (var db = new LibData()) { var selectedAuthorBook = db.AuthorsBooks.Where(s => s.BookID == bookId).FirstOrDefault(); selectedAuthorBook.AuthorID = authorBook.AuthorID; selectedAuthorBook.BookID = authorBook.BookID; if (db.SaveChanges() != 0) { result = true; } else { result = false; } } if (result == true) { return(true); } return(false); }
// Update row public bool Update(Categories category, int oldID) { bool result = false; using (var db = new LibData()) { var selectedCategory = db.Categories.Find(oldID); selectedCategory.Name = category.Name; if (db.SaveChanges() != 0) { result = true; } else { result = false; } } if (result == true) { return(true); } return(false); }
private string GetDataList(dynamic set) { dynamic tableInst = null; foreach (var table in set.Fields) { tableInst = Activator.CreateInstance(table.Type); if (tableInst is ListGraphType) { continue; } else { break; } } return($@"export const GET_{tableInst.Name.ToUpper()}_List = searchFields => {{ return gql` query {nameof(BasicRepository<object>.QueryList)}(${SystemCP.Condition}: String!, ${SystemCP.JWT}: String!){{ {nameof(BasicRepository<object>.QueryList)}({SystemCP.Condition}: ${SystemCP.Condition}, {SystemCP.JWT}: ${SystemCP.JWT}){{ ${{searchFields || ""...{LibData.ToCamelCase(tableInst.Name)}List""}} }} }} ${{searchFields ? """" : {LibData.ToCamelCase(set.Name)}Fragment.{LibData.ToCamelCase(tableInst.Name)}List}} `; }}; "); }
// Delete multiple rows by bookID public bool DeleteRows(int bookID) { bool result; using (var db = new LibData()) { db.AuthorsBooks.RemoveRange(db.AuthorsBooks.Where(s => s.BookID == bookID)); if (db.SaveChanges() != 0) { result = true; } else { result = false; } } if (result == true) { return(true); } else { return(false); } }
/// <summary> /// 獲取啟用代收類別 /// </summary> /// <param name="accftt"></param> /// <returns></returns> private static string GetCollectionType(ACCFTT accftt) { List <string> collections = new List <string>(); if (!accftt.RECVITEM1.IsNullOrEmpty()) { collections.Add(accftt.RECVITEM1); } if (!accftt.RECVITEM2.IsNullOrEmpty()) { collections.Add(accftt.RECVITEM2); } if (!accftt.RECVITEM3.IsNullOrEmpty()) { collections.Add(accftt.RECVITEM3); } if (!accftt.RECVITEM4.IsNullOrEmpty()) { collections.Add(accftt.RECVITEM4); } if (!accftt.RECVITEM5.IsNullOrEmpty()) { collections.Add(accftt.RECVITEM5); } collections.Sort(); return(LibData.Merge(",", false, collections.ToArray())); }
// Update row public bool Update(Clients client, int oldID) { bool result = false; using (var db = new LibData()) { var selectedClient = db.Clients.Find(oldID); selectedClient.Name = client.Name; selectedClient.Surname = client.Surname; if (db.SaveChanges() != 0) { result = true; } else { result = false; } } if (result == true) { return(true); } return(false); }
// Delete row public bool Delete(Authors author) { bool result = false; using (var db = new LibData()) { db.Authors.Attach(author); db.Authors.Remove(author); try { if (db.SaveChanges() != 0) { result = true; } else { result = false; } } catch (Exception exp) { } } if (result == true) { return(true); } return(false); }
// fill grid public void fillGrid(List <Orders> orderList) { dataGridView2.Rows.Clear(); using (var db = new LibData()) { List <Authors> authorList = new List <Authors>(); for (int i = 0; i < orderList.Count; i++) { DataGridViewRow row = (DataGridViewRow)dataGridView2.Rows[0].Clone(); row.Cells[0].Value = orderList[i].id; row.Cells[1].Value = orderList[i].Clients.Name + " " + orderList[i].Clients.Surname; int bookid = orderList[i].BookID; authorList = db.AuthorsBooks.Where(b => b.BookID == bookid).Select(ab => ab.Authors).ToList(); foreach (Authors author in authorList) { row.Cells[2].Value += author.Name + " " + author.Surname + " , "; } row.Cells[3].Value = orderList[i].OrderDate; row.Cells[4].Value = orderList[i].ReturnDate; if (DateTime.Compare(orderList[i].OrderDate, orderList[i].ReturnDate) > 0) { row.DefaultCellStyle.BackColor = Color.Red; } dataGridView2.Rows.Add(row); } } }
private string GetTableTemplate(dynamic tableInst, string fragName) { string fields = GetFieldsTemplate(tableInst); return($@" {LibData.ToCamelCase(fragName)}: gql` fragment {LibData.ToCamelCase(fragName)} on {tableInst.Name} {{ {fields} }}`, "); }
// Select all rows public List <Books> SelectAll() { List <Books> bookList = new List <Books>(); using (var db = new LibData()) { bookList = db.Books.ToList(); } return(bookList); }
// Select by Name or Cathegory property public List <Categories> GetCategory(string prop) { List <Categories> categoryList = new List <Categories>(); using (var db = new LibData()) { categoryList = db.Categories.Where(c => c.Name.ToLower() == prop.ToLower()).ToList(); } return(categoryList); }
// Select all rows public List <Categories> SelectAll() { List <Categories> categories = new List <Categories>(); using (var db = new LibData()) { categories = db.Categories.ToList(); } return(categories); }
// Get row by any property public List <Clients> GetClient(string prop) { List <Clients> clientList = new List <Clients>(); using (var db = new LibData()) { clientList = db.Clients.Where(c => c.Name.Contains(prop) || c.Surname.Contains(prop) || c.Phone.Contains(prop) || c.Email.Contains(prop)).ToList(); } return(clientList); }
// Select by Name or Cathegory property public List <Books> GetBook(string prop) { List <Books> bookList = new List <Books>(); using (var db = new LibData()) { bookList = db.Books.Where(c => c.Name.ToLower() == prop.ToLower()).ToList(); } return(bookList); }
private string GetSearch(int count) { string result = string.Empty; for (int i = 1; i <= count; i++) { result = LibData.Merge(", ", false, result, $"search{i}"); } return(result); }
// Select all rows public List <Orders> SelectAll() { List <Orders> orders = new List <Orders>(); using (var db = new LibData()) { orders = db.Orders.ToList(); } return(orders); }
private string GetFieldsTemplate(dynamic tableInst) { StringBuilder str = new StringBuilder(); foreach (var field in tableInst.Fields) { str.AppendLine($" {LibData.ToCamelCase(field.Name)}"); } return(str.ToString()); }
// Select all rows public List <Clients> SelectAll() { List <Clients> clients = new List <Clients>(); using (var db = new LibData()) { clients = db.Clients.ToList(); } return(clients); }
/// <summary> /// 7-11、全家、郵局、農金、亞太 /// 入帳日:入帳日為非營業日時,會與前一個傳輸日一同匯款 /// Ex:T+3為例 /// ------------------------- /// |資料傳輸日|入帳,撥款日| /// ------------------------- /// |星期一 |星期四 | /// ------------------------- /// |星期二 |(本週)星期五| /// ------------------------- /// |星期三 |(本週)星期五| /// ------------------------- /// |星期四 |(本週)星期五| /// ------------------------- /// |星期五 |星期一 | /// ------------------------- /// |星期六 |星期二 | /// ------------------------- /// |星期日 |星期三 | /// ------------------------- /// </summary> /// <returns></returns> private static DateTime GetNDay_A(Dictionary <DateTime, bool> workDic, DateTime transDate, int days = 3) { DateTime result = transDate.AddDays(days); if (!workDic[result]) { result = LibData.GetWorkDate(workDic, result, 0, false); } return(result); }
// Select by Author id property public List <AuthorsBooks> GetPairByAuthor(int authorID) { List <AuthorsBooks> abList = new List <AuthorsBooks>(); using (var db = new LibData()) { abList = db.AuthorsBooks.Where(c => c.AuthorID == authorID).ToList(); } return(abList); }
// Select by Name property public List <Authors> GetAuthor(string prop) { List <Authors> authorList = new List <Authors>(); using (var db = new LibData()) { authorList = db.Authors.Where(c => c.Name.ToLower() == prop.ToLower()).ToList(); } return(authorList); }
// Select all rows public List <Authors> SelectAll() { List <Authors> authors = new List <Authors>(); using (var db = new LibData()) { authors = db.Authors.ToList(); } return(authors); }
// Select one row by id public Authors Select(int id) { Authors myAuthor; using (var db = new LibData()) { myAuthor = db.Authors.Where(a => a.id == id).FirstOrDefault(); } return(myAuthor); }
// Select one row by id public Books Select(int bookID) { Books myBook; using (var db = new LibData()) { myBook = db.Books.Where(a => a.id == bookID).FirstOrDefault(); } return(myBook); }
// Select book By category public List <Books> GetBooksByCategory(int categoryID) { List <Books> bookList = new List <Books>(); using (var db = new LibData()) { bookList = db.Books.Where(a => a.CategoryID == categoryID).ToList(); } return(bookList); }