private void savebutton_Click(object sender, EventArgs e) { Store aStore = new Store(); StoreDAO aStoreDao = new StoreDAO(); aStore = aStoreDao.GetStoreByItemId(ItemId); Transaction1 aTransaction1 = new Transaction1(); aTransaction1.ItemName = aStore.ItemName; aTransaction1.TransactionType = transactiontypelebel.Text; aTransaction1.Amount = Convert.ToDouble(quantitytextBox.Text) * aStore.UnitPrice; aTransaction1.Quantity = Convert.ToDouble(quantitytextBox.Text); aTransaction1.ItemUnit = aStore.Unit; aTransaction1.CauseOrPurpose = purposeTextBox.Text.Trim(); aStore.Quantity -= Convert.ToDouble(quantitytextBox.Text); if (aStore.Quantity >= 0) { aStoreDao.InsertTransaction(aTransaction1, CategoryId); string sr = aStoreDao.UpdateStore(aStore); MessageBox.Show(sr); if (sr == "Insert Sucessfully") { this.Close(); } } else { MessageBox.Show("Not Enough quantity"); } }
private void showreportButton_Click(object sender, EventArgs e) { DateTime fromDate = fromdateTimePicker.Value; fromDate = fromDate.Date; DateTime toDate = todateTimePicker.Value; toDate = toDate.Date; toDate = toDate.AddDays(1); toDate = toDate.AddSeconds(-1); List <Transaction1> aTransactions = new List <Transaction1>(); StoreDAO aStoreDao = new StoreDAO(); if (categoryRadioButton.Checked) { aTransactions = aStoreDao.GetOtherTransactionBydate(fromDate, toDate, Convert.ToInt32(categorycomboBox.SelectedValue)); } else if (transactionRadioButton.Checked) { aTransactions = aStoreDao.GetOtherTransactionBydateAndTransactionType(fromDate, toDate, transactionTypeComboBox.Text); } otherdataGridView.DataSource = aTransactions; }
public void Supplier_AddNewProduct4() { Supplier supplier = new Supplier() { ID = 8, UserName = "******", Password = "******", Company = "RadioShack" }; SupplierForms supplierForms = new SupplierForms(TestMode.On, supplier); supplierForms.input.Injections = new List <object>() { "Laptop", "500", 5 }; supplierForms.AddNewProduct(); List <Product> products = new StoreDAO().GetAllSupplierProducts(supplier.ID); Product product = products[products.Count - 1]; Assert.AreEqual(product.Name, "Laptop"); Assert.AreEqual(product.Price, 500); Assert.AreEqual(product.Quantity, 5); }
private void addbutton_Click(object sender, EventArgs e) { try { if (itemnametextBox.Text.Length > 0 && unitcomboBox.Text.Length > 0) { Store aStore = new Store(); aStore.ItemName = itemnametextBox.Text; aStore.Unit = unitcomboBox.Text; aStore.CategoryId = Convert.ToInt32(categorycomboBox.SelectedValue); aStore.CategoryName = categorycomboBox.Text; StoreDAO aStoreDao = new StoreDAO(); string sr = aStoreDao.InsertOtherItem(aStore); MessageBox.Show(sr); if (sr == "Insert Sucessfully") { this.Close(); } } else { MessageBox.Show("Please Check Input"); } } catch (Exception) { MessageBox.Show("Please Check Input"); } }
private void addbutton_Click(object sender, EventArgs e) { try { if (categorynametextBox.Text.Length > 0) { Store aStore = new Store(); aStore.ItemName = categorynametextBox.Text; StoreDAO aStoreDao = new StoreDAO(); string sr = aStoreDao.InsertOtherCategory(aStore); MessageBox.Show(sr); if (sr == "Insert Sucessfully") { this.Close(); } } else { MessageBox.Show("Please Check Input"); } } catch (Exception) { MessageBox.Show("Please Check Input"); } }
public void Customer_CreateNewOrder5() { Customer customer = new Customer() { ID = 12, UserName = "******", Password = "******", FirstName = "John", LastName = "Doe", CreditNumber = "4580" }; CustomerForms customerForms = new CustomerForms(TestMode.On, customer); customerForms.input.Injections = new List <object>() { 16, 1 }; customerForms.CreateNewOrder(); List <Order> orders = new StoreDAO().GetCustomerOrders(customer.ID); // Getting the latest order: Order order = orders[orders.Count - 1]; Assert.AreEqual(order.ProductName, "Batteries Pack"); Assert.AreEqual(order.CustomerID, 12); Assert.AreEqual(order.Amount, 1); Assert.AreEqual(order.TotalPrice, 8); }
private void LoadGridView() { StoreDAO aDao = new StoreDAO(); List <Store> aStores = new List <Store>(); aStores = aDao.GetAllOtherStore(); otherpurchaseStoredataGridView.DataSource = aStores; }
/// <summary> Retrieves in this StoreCollection object all StoreEntity objects which are related via a relation of type 'm:n' with the passed in ContactTypeEntity. /// All current elements in the collection are removed from the collection.</summary> /// <param name="contactTypeInstance">ContactTypeEntity object to be used as a filter in the m:n relation</param> /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param> /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param> /// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch.</param> /// <returns>true if the retrieval succeeded, false otherwise</returns> public bool GetMultiManyToManyUsingContactTypeCollectionViaStoreContact(IEntity contactTypeInstance, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath prefetchPathToUse) { if (!base.SuppressClearInGetMulti) { this.Clear(); } StoreDAO dao = DAOFactory.CreateStoreDAO(); return(dao.GetMultiUsingContactTypeCollectionViaStoreContact(base.Transaction, this, maxNumberOfItemsToReturn, sortClauses, base.EntityFactoryToUse, contactTypeInstance, prefetchPathToUse)); }
/// <summary> Retrieves in this StoreCollection object all StoreEntity objects which are related via a relation of type 'm:n' with the passed in ContactEntity. /// All current elements in the collection are removed from the collection.</summary> /// <param name="contactInstance">ContactEntity object to be used as a filter in the m:n relation</param> /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param> /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param> /// <param name="pageNumber">The page number to retrieve.</param> /// <param name="pageSize">The page size of the page to retrieve.</param> /// <returns>true if the retrieval succeeded, false otherwise</returns> public virtual bool GetMultiManyToManyUsingContactCollectionViaStoreContact(IEntity contactInstance, long maxNumberOfItemsToReturn, ISortExpression sortClauses, int pageNumber, int pageSize) { if (!base.SuppressClearInGetMulti) { this.Clear(); } StoreDAO dao = DAOFactory.CreateStoreDAO(); return(dao.GetMultiUsingContactCollectionViaStoreContact(base.Transaction, this, maxNumberOfItemsToReturn, sortClauses, base.EntityFactoryToUse, contactInstance, pageNumber, pageSize)); }
private void FoodAndNoonFoodTransaction_Load(object sender, EventArgs e) { StoreDAO aStoreDao = new StoreDAO(); List <Store> aList = new List <Store>(); aList = aStoreDao.GetAllRawmaterialCategory(); categorycomboBox.DataSource = aList; categorycomboBox.ValueMember = "StoreId"; categorycomboBox.DisplayMember = "ItemName"; }
private void AddOtherItem_Load(object sender, EventArgs e) { StoreDAO aStoreDao = new StoreDAO(); List <Store> aList = new List <Store>(); aList = aStoreDao.GetAllotherCategory(); categorycomboBox.DataSource = aList; categorycomboBox.ValueMember = "StoreId"; categorycomboBox.DisplayMember = "ItemName"; }
private void LoadRawmaterialCategory() { StoreDAO aStoreDao = new StoreDAO(); List <Store> aList = new List <Store>(); aList = aStoreDao.GetAllRawmaterialCategory(); categorycomboBox.DataSource = aList; categorycomboBox.ValueMember = "StoreId"; categorycomboBox.DisplayMember = "ItemName"; }
private void showreportButton_Click(object sender, EventArgs e) { DateTime fromDate = fromdateTimePicker.Value; fromDate = fromDate.Date; DateTime toDate = todateTimePicker.Value; toDate = toDate.Date; toDate = toDate.AddDays(1); toDate = toDate.AddSeconds(-1); List <Transaction1> otherTransactions = new List <Transaction1>(); List <Transaction1> aTransactions = new List <Transaction1>(); List <Transaction1> employeeTransactions = new List <Transaction1>(); StoreDAO aStoreDao = new StoreDAO(); EmployeeDAO aEmployeeDao = new EmployeeDAO(); otherTransactions = aStoreDao.GetOtherTransactionBydateForProfit(fromDate, toDate); aTransactions = aStoreDao.GetTransactionBydateForProfit(fromDate, toDate); employeeTransactions = aEmployeeDao.EmployeeTransactionReportBydate(fromDate, toDate); Int64 startDate = new DateTime(fromdateTimePicker.Value.Year, fromdateTimePicker.Value.Month, fromdateTimePicker.Value.Day, 0, 0, 0).Ticks; DateTime dtTemp = todateTimePicker.Value.AddDays(1); Int64 endDate = new DateTime(dtTemp.Year, dtTemp.Month, dtTemp.Day, 0, 0, 0).Ticks; List <Transaction1> saleTransactions = new List <Transaction1>(); saleTransactions = aStoreDao.showAllData(startDate, endDate); toDate = todateTimePicker.Value; toDate = toDate.Date; List <ProfitLoss> aProfitLosses = new List <ProfitLoss>(); while (fromDate <= toDate) { ProfitLoss aProfitLoss = new ProfitLoss(); aProfitLoss.Date = fromDate; aProfitLoss.AccsCost = AmountCalculate(otherTransactions, fromDate); aProfitLoss.RMCost = AmountCalculate(aTransactions, fromDate); aProfitLoss.SalaryCost = AmountCalculate(employeeTransactions, fromDate); aProfitLoss.SaleAmount = AmountCalculate(saleTransactions, fromDate); double amount1 = (aProfitLoss.AccsCost + aProfitLoss.RMCost + aProfitLoss.SalaryCost); if (aProfitLoss.SaleAmount - amount1 < 0) { aProfitLoss.Loss = aProfitLoss.SaleAmount - amount1; } else { aProfitLoss.Profit = aProfitLoss.SaleAmount - amount1; } aProfitLosses.Add(aProfitLoss); fromDate = fromDate.AddDays(1); } profitlossdataGridView.DataSource = aProfitLosses; }
public static StoreDTO MapToDTO(StoreDAO store) { var s = new StoreDTO(); s.Id = store.Id; s.Address = AddressMapper.MapToDTO(store.Address); s.PhoneNumber = PhoneMapper.MapToDTO(store.PhoneNumber); s.Hours = HoursMapper.MapToDTO(store.Hours); s.Active = store.Active; return(s); }
public static StoreDAO MapToStoreDAO(Store store) { var s = new StoreDAO(); s.Id = store.StoreID; s.Address = AddressDetailMapper.MapToAddressDetailDAO(store.AddressDetail); s.PhoneNumber = PhoneMapper.MapToPhoneDAO(store.Phone); s.Hours = StoreHourMapper.MapToStoreHourDAO(store.StoreHour); s.Active = store.Active; return(s); }
public static Store MapToStore(StoreDAO store) { var s = new Store(); s.StoreID = store.Id; s.AddressID = AddressDetailMapper.MapToAddressDetail(store.Address).AddressID; s.PhoneID = PhoneMapper.MapToPhone(store.PhoneNumber).PhoneID; s.HoursID = StoreHourMapper.MapToStoreHour(store.Hours).HoursID; s.Active = store.Active; return(s); }
public bool PostStore(StoreDAO store) { StoreServiceClient client = new StoreServiceClient(); try { bool result = client.CreateStore(store); return result; } catch (FaultException<KaskServiceException> e) { throw new HttpException(e.Message); } }
private void showreportButton_Click(object sender, EventArgs e) { DateTime fromDate = fromdateTimePicker.Value; fromDate = fromDate.Date; DateTime toDate = todateTimePicker.Value; toDate = toDate.Date; toDate = toDate.AddDays(1); toDate = toDate.AddSeconds(-1); List <Transaction1> aTransactions = new List <Transaction1>(); StoreDAO aStoreDao = new StoreDAO(); aTransactions = aStoreDao.GetTransactionBydate(fromDate, toDate, Convert.ToInt32(categorycomboBox.SelectedValue)); fooddataGridView.DataSource = aTransactions; }
/// <summary> Gets a scalar value, calculated with the aggregate and expression specified. the field index specified is the field the expression and aggregate are applied on.</summary> /// <param name="fieldIndex">Field index of field to which to apply the aggregate function and expression</param> /// <param name="expressionToExecute">The expression to execute. Can be null</param> /// <param name="aggregateToApply">Aggregate function to apply. </param> /// <param name="filter">The filter to apply to retrieve the scalar</param> /// <param name="relations">The relations to walk</param> /// <param name="groupByClause">The groupby clause to apply to retrieve the scalar</param> /// <returns>the scalar value requested</returns> public virtual object GetScalar(StoreFieldIndex fieldIndex, IExpression expressionToExecute, AggregateFunction aggregateToApply, IPredicate filter, IRelationCollection relations, IGroupByCollection groupByClause) { EntityFields fields = new EntityFields(1); fields[0] = EntityFieldFactory.Create(fieldIndex); if ((fields[0].ExpressionToApply == null) || (expressionToExecute != null)) { fields[0].ExpressionToApply = expressionToExecute; } if ((fields[0].AggregateFunctionToApply == AggregateFunction.None) || (aggregateToApply != AggregateFunction.None)) { fields[0].AggregateFunctionToApply = aggregateToApply; } StoreDAO dao = DAOFactory.CreateStoreDAO(); return(dao.GetScalar(fields, base.Transaction, filter, relations, groupByClause)); }
/// <summary> Retrieves in this StoreCollection object all StoreEntity objects which have data in common with the specified related Entities. /// If one is omitted, that entity is not used as a filter. All current elements in the collection are removed from the collection.</summary> /// <param name="salesPersonInstance">SalesPersonEntity instance to use as a filter for the StoreEntity objects to return</param> /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param> /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param> /// <param name="filter">Extra filter to limit the resultset. Predicate expression can be null, in which case it will be ignored.</param> /// <param name="pageNumber">The page number to retrieve.</param> /// <param name="pageSize">The page size of the page to retrieve.</param> /// <returns>true if succeeded, false otherwise</returns> public virtual bool GetMultiManyToOne(IEntity salesPersonInstance, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicateExpression filter, int pageNumber, int pageSize) { bool validParameters = false; validParameters |= (salesPersonInstance != null); if (!validParameters) { return(GetMulti(filter, maxNumberOfItemsToReturn, sortClauses, null, pageNumber, pageSize)); } if (!base.SuppressClearInGetMulti) { this.Clear(); } StoreDAO dao = DAOFactory.CreateStoreDAO(); return(dao.GetMulti(base.Transaction, this, maxNumberOfItemsToReturn, sortClauses, base.EntityFactoryToUse, filter, salesPersonInstance, pageNumber, pageSize)); }
private void cmbStoreBind() { List <Store> storeList = new StoreDAO().Store_GetAll(); cmbStore.DataSource = storeList; cmbStore.DisplayMember = "StoreName"; cmbStore.ValueMember = "StoreId"; if (MDIParent.roleId != 2) //2 is ADMIN { cmbStore.SelectedValue = MDIParent.storeId; cmbStore.Enabled = false; cmbDesignation.SelectedValue = 4; cmbDesignation.Enabled = false; } else { cmbStore.SelectedIndex = -1; } }
private void itemNametextBox_TextChanged(object sender, EventArgs e) { if (itemNametextBox.Text == "" || string.IsNullOrEmpty(itemNametextBox.Text)) { StoreDAO aDao = new StoreDAO(); List <Store> aStores = new List <Store>(); aStores = aDao.GetAllOtherStore(); otherpurchaseStoredataGridView.DataSource = aStores; } else { StoreDAO aDao = new StoreDAO(); List <Store> aStores = new List <Store>(); aStores = aDao.GetAllOtherStore(); List <Store> aastore = (from myRow in aStores.AsEnumerable() where myRow.ItemName.ToUpper().StartsWith(itemNametextBox.Text.ToUpper()) select myRow).ToList(); // DataView view = results.AsDataView(); otherpurchaseStoredataGridView.DataSource = aastore; } }
private void savebutton_Click(object sender, System.EventArgs e) { Store aStore = new Store(); StoreDAO aStoreDao = new StoreDAO(); aStore = aStoreDao.GetStoreByItemId(ItemId); Transaction1 aTransaction1 = new Transaction1(); aTransaction1.ItemName = aStore.ItemName; aTransaction1.TransactionType = "Purchase"; aTransaction1.SupplierName = supplierNamecomboBox.Text; aTransaction1.Amount = Convert.ToDouble(amounttextBox.Text); aTransaction1.Quantity = Convert.ToDouble(quantitytextBox.Text); aTransaction1.ItemUnit = aStore.Unit; aStoreDao.InsertTransaction(aTransaction1, CategoryId); double newstore = aStore.Amount + Convert.ToDouble(amounttextBox.Text); double newquantity = aStore.Quantity + Convert.ToDouble(quantitytextBox.Text); double unitprice = 0; if (newquantity != 0) { unitprice = (newstore / newquantity); } else { unitprice = 0; } aStore.UnitPrice = unitprice; aStore.Quantity = newquantity; string sr = aStoreDao.UpdateStore(aStore); MessageBox.Show(sr); if (sr == "Insert Sucessfully") { this.Close(); } }
private void otherpurchaseStoredataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } try { if (e.ColumnIndex == otherpurchaseStoredataGridView.Columns["Purchase"].Index) //when purchase { OtherPurchaseForm aForm = new OtherPurchaseForm(); aForm.CategoryId = Convert.ToInt32("0" + otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value); aForm.ItemId = Convert.ToInt32("0" + otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value); aForm.itemnamelabel.Text = (otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[1 + 2].Value).ToString(); aForm.unitnameLebel.Text = (otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[2 + 2].Value).ToString(); aForm.ShowDialog(); LoadGridView(); } if (e.ColumnIndex == otherpurchaseStoredataGridView.Columns["Return"].Index) //when purchase { OtherReturnForm aForm = new OtherReturnForm(); aForm.CategoryId = Convert.ToInt32("0" + otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value); aForm.ItemId = Convert.ToInt32("0" + otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value); aForm.itemnamelabel.Text = (otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[1 + 2].Value).ToString(); aForm.unitnameLebel.Text = (otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[2 + 2].Value).ToString(); aForm.ShowDialog(); LoadGridView(); } if (e.ColumnIndex == otherpurchaseStoredataGridView.Columns["StockOut"].Index) //when stockout { OtherDamageOrStockOut aForm = new OtherDamageOrStockOut(); aForm.CategoryId = Convert.ToInt32("0" + otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value); aForm.ItemId = Convert.ToInt32("0" + otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value); aForm.otheritemnamelabel.Text = (otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[1 + 2].Value).ToString(); aForm.otherunitnameLebel.Text = (otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[2 + 2].Value).ToString(); aForm.othertransactiontypelebel.Text = "Stock Out"; aForm.ShowDialog(); LoadGridView(); } if (e.ColumnIndex == otherpurchaseStoredataGridView.Columns["Damage"].Index) //when damage { OtherDamageOrStockOut aForm = new OtherDamageOrStockOut(); aForm.CategoryId = Convert.ToInt32("0" + otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value); aForm.ItemId = Convert.ToInt32("0" + otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value); aForm.otheritemnamelabel.Text = (otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[1 + 2].Value).ToString(); aForm.otherunitnameLebel.Text = (otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[2 + 2].Value).ToString(); aForm.othertransactiontypelebel.Text = "Damage"; aForm.ShowDialog(); LoadGridView(); } if (e.ColumnIndex == otherpurchaseStoredataGridView.Columns["Delete"].Index) //when delete { DialogResult dialogResult = MessageBox.Show("Are you sure want to delete it?", "Alert!", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { StoreDAO aStoreDao = new StoreDAO(); string sr = aStoreDao.OtherDeleteItem(Convert.ToInt32("0" + otherpurchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value)); MessageBox.Show(sr); LoadGridView(); } else if (dialogResult == DialogResult.No) { //do something else } } } catch (Exception) { } }
//Quick Testing for methods static void Main(string[] args) { SalespersonDAO spDAL = new SalespersonDAO(); DistrictDAO dDAL = new DistrictDAO(); StoreDAO sDAO = new StoreDAO(); //Test Insert //var result = spDAL.Insert(new Salesperson { Name = "Sangey" }); //Test get single //var result = spDAL.GetById(1).ToString(); //Test get all //var result = spDAL.GetAll(); //foreach (Salesperson sp in result) //{ // Console.WriteLine(sp.ToString()); //} //Test Update //spDAL.Update(new Salesperson { Id = 6, Name = "Updated" }); //var result = spDAL.GetById(6).ToString(); //Test Delete //spDAL.Delete(spDAL.GetSalespersonById(9)); //Test District Insert //var result = dDAL.Insert(new District { Name = "East Denmark", PrimarySalesperson = spDAL.GetById(5) }); //Test District Get //var result = dDAL.GetById(1).ToString(); //Test District GetAll //var result = dDAL.GetAll(); //foreach (District d in result) //{ // Console.WriteLine(d.ToString()); //} //Test District Update //var result = dDAL.Update(new District { Id = 1, Name = "North Denmark Updated", PrimarySalesperson = spDAL.GetById(4) }); //var result = dDAL.UpdateDS(new District { Id = 1, Name = "North Denmark Update2", PrimarySalesperson = spDAL.GetById(5) }); //Test District Delete //dDAL.Delete(dDAL.GetById(3)); //Test Get District using a data set //var result = dDAL.GetByIdDataSet(3).ToString(); //Test Store Insert //var result = sDAO.Insert(new Store { Name = "Fotex" }); //Test Store GetByID //var result = sDAO.GetById(1); //Test Store GetAll //var result = sDAO.GetAll(); //foreach (Store s in result) //{ // Console.WriteLine(s.ToString()); //} // Test Store Update //var result = sDAO.Update(new Store { Id = 1, Name = "Rema 1000 Updated"}); //Test Store Delete //var result = sDAO.Delete(sDAO.GetById(3)); //District dist = dDAL.GetByIdDataSet(2); //var tempSalespersons = new List<Salesperson>(); //tempSalespersons.Add(spDAL.GetById(1)); //tempSalespersons.Add(spDAL.GetById(3)); //tempSalespersons.Add(spDAL.GetById(5)); //tempSalespersons.Add(spDAL.GetById(7)); //dist.Salespersons = tempSalespersons; //var result = dDAL.UpdateSalespersonsList(dist); //Console.WriteLine(result.ToString()); Console.ReadLine(); }
/// <summary> Updates in the persistent storage all Store entities which have data in common with the specified related Entities. If one is omitted, that entity is not used as a filter. /// Which fields are updated in those matching entities depends on which fields are <i>changed</i> in the passed in entity entityWithNewValues. The new values of these fields are read from entityWithNewValues. </summary> /// <param name="entityWithNewValues">StoreEntity instance which holds the new values for the matching entities to update. Only changed fields are taken into account</param> /// <param name="salesPersonInstance">SalesPersonEntity instance to use as a filter for the StoreEntity objects to return</param> /// <returns>Amount of entities affected, if the used persistent storage has rowcounting enabled.</returns> public int UpdateMultiManyToOne(StoreEntity entityWithNewValues, IEntity salesPersonInstance) { StoreDAO dao = DAOFactory.CreateStoreDAO(); return(dao.UpdateMulti(entityWithNewValues, base.Transaction, salesPersonInstance)); }
private async Task Sync(DataContext context, string json) { List <EventMessage <Store> > EventMessageReceived = JsonConvert.DeserializeObject <List <EventMessage <Store> > >(json); await SaveEventMessage(context, SyncKey, EventMessageReceived); List <Guid> RowIds = EventMessageReceived.Select(a => a.RowId).Distinct().ToList(); List <EventMessage <Store> > StoreEventMessages = await ListEventMessage <Store>(context, SyncKey, RowIds); List <Store> Stores = StoreEventMessages.Select(x => x.Content).ToList(); var StoreIds = Stores.Select(x => x.Id).ToList(); List <StoreDAO> StoreInDB = await context.Store.Where(x => StoreIds.Contains(x.Id)).ToListAsync(); foreach (var RowId in RowIds) { EventMessage <Store> EventMessage = EventMessageReceived.Where(e => e.RowId == RowId).OrderByDescending(e => e.Time).FirstOrDefault(); if (EventMessage != null) { Stores.Add(EventMessage.Content); } } try { List <StoreDAO> StoreDAOs = new List <StoreDAO>(); List <ImageDAO> ImageDAOs = new List <ImageDAO>(); List <StoreImageMappingDAO> StoreImageMappingDAOs = new List <StoreImageMappingDAO>(); foreach (var Store in Stores) { StoreDAO StoreDAO = StoreInDB.Where(x => x.Id == Store.Id).FirstOrDefault(); if (StoreDAO == null) { StoreDAO = new StoreDAO(); } StoreDAO.Id = Store.Id; StoreDAO.Code = Store.Code; StoreDAO.Name = Store.Name; StoreDAO.Address = Store.Address; StoreDAO.AppUserId = Store.AppUserId; StoreDAO.CodeDraft = Store.CodeDraft; StoreDAO.CreatedAt = Store.CreatedAt; StoreDAO.UpdatedAt = Store.UpdatedAt; StoreDAO.DeletedAt = Store.DeletedAt; StoreDAO.DeliveryAddress = Store.DeliveryAddress; StoreDAO.DeliveryLatitude = Store.DeliveryLatitude; StoreDAO.DeliveryLongitude = Store.DeliveryLongitude; StoreDAO.ProvinceId = Store.ProvinceId; StoreDAO.DistrictId = Store.DistrictId; StoreDAO.WardId = Store.WardId; StoreDAO.Latitude = Store.Latitude; StoreDAO.Longitude = Store.Longitude; StoreDAO.LegalEntity = Store.LegalEntity; StoreDAO.OrganizationId = Store.OrganizationId; StoreDAO.OwnerEmail = Store.OwnerEmail; StoreDAO.OwnerName = Store.OwnerName; StoreDAO.OwnerPhone = Store.OwnerPhone; StoreDAO.ParentStoreId = Store.ParentStoreId; StoreDAO.RowId = Store.RowId; StoreDAO.StatusId = Store.StatusId; StoreDAO.StoreGroupingId = Store.StoreGroupingId; StoreDAO.StoreStatusId = Store.StoreStatusId; StoreDAO.StoreTypeId = Store.StoreTypeId; StoreDAO.TaxCode = Store.TaxCode; StoreDAO.Telephone = Store.Telephone; StoreDAO.UnsignAddress = Store.UnsignAddress; StoreDAO.UnsignName = Store.UnsignName; StoreDAO.Used = Store.Used; StoreDAOs.Add(StoreDAO); foreach (var StoreImageMapping in Store.StoreImageMappings) { StoreImageMappingDAO StoreImageMappingDAO = new StoreImageMappingDAO { StoreId = StoreImageMapping.StoreId, ImageId = StoreImageMapping.ImageId, }; StoreImageMappingDAOs.Add(StoreImageMappingDAO); ImageDAOs.Add(new ImageDAO { Id = StoreImageMapping.Image.Id, Url = StoreImageMapping.Image.Url, ThumbnailUrl = StoreImageMapping.Image.ThumbnailUrl, RowId = StoreImageMapping.Image.RowId, Name = StoreImageMapping.Image.Name, CreatedAt = StoreImageMapping.Image.CreatedAt, UpdatedAt = StoreImageMapping.Image.UpdatedAt, DeletedAt = StoreImageMapping.Image.DeletedAt, }); } } await context.StoreImageMapping .Where(x => StoreIds.Contains(x.StoreId)) .DeleteFromQueryAsync(); await context.BulkMergeAsync(ImageDAOs); await context.BulkMergeAsync(StoreDAOs); await context.BulkMergeAsync(StoreImageMappingDAOs); } catch (Exception ex) { Log(ex, nameof(StoreHandler)); } }
public StoreService(StoreDAO storeDAO) { _storeDAO = storeDAO; }
/// <summary> /// 构造函数 /// </summary> public StoreBLL(LoggingSessionInfo pUserInfo) { this.CurrentUserInfo = pUserInfo; this._currentDAO = new StoreDAO(pUserInfo); }
/// <summary> Retrieves Entity rows in a datatable which match the specified filter. It will always create a new connection to the database.</summary> /// <param name="selectFilter">A predicate or predicate expression which should be used as filter for the entities to retrieve.</param> /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param> /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param> /// <param name="relations">The set of relations to walk to construct to total query.</param> /// <param name="pageNumber">The page number to retrieve.</param> /// <param name="pageSize">The page size of the page to retrieve.</param> /// <returns>DataTable with the rows requested.</returns> public static DataTable GetMultiAsDataTable(IPredicate selectFilter, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, int pageNumber, int pageSize) { StoreDAO dao = DAOFactory.CreateStoreDAO(); return(dao.GetMultiAsDataTable(maxNumberOfItemsToReturn, sortClauses, selectFilter, relations, pageNumber, pageSize)); }
public StoreViewer() { _storeDAO = new StoreDAO(); }