private void FillUnits() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; WareUnitsLogic units = new WareUnitsLogic(manager); List <ItemIntValue> items2 = new List <ItemIntValue>(); items2.Clear(); items2.Add(none); foreach (var a in units.GetAll().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items2.Add(i); } UnitsCB.DataSource = items2; UnitsCB.ValueMember = "ID"; UnitsCB.DisplayMember = "Name"; UnitsCB.Update(); if (UnitsCB.Items.Count > 1) { UnitsCB.SelectedIndex = 1; } }
public void Fill() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; List <ItemIntValue> items0 = new List <ItemIntValue>(); DocumentTypesLogic documentTypesLogic = new DocumentTypesLogic(manager); items0.Clear(); items0.Add(none); foreach (var a in documentTypesLogic.GetAll().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items0.Add(i); } DocumentTypesCB.DataSource = items0; DocumentTypesCB.ValueMember = "ID"; DocumentTypesCB.DisplayMember = "Name"; DocumentTypesCB.Update(); DateTime startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); }
/// <summary> /// /// </summary> /// <param name="category">батьківська категорія</param> private void FillCategoriesHierarchy(WareCategory category, string prefix, bool start) { if (start == true) { items.Clear(); } WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); List <WareCategory> categories = new List <WareCategory>(); if (category == null) { categories = categoriesLogic.GetAllRoot(); } else { categories = categoriesLogic.GetAll(category.ID); } foreach (WareCategory a in categories) { ItemIntValue item = new ItemIntValue(); item.ID = a.ID; item.Name = prefix + a.Name; item.Image = a.Image; items.Add(item); FillCategoriesHierarchy(a, prefix + @" ", false); } }
private void FillAvailableEmployees() { AvailableEmployeesLB.Items.Clear(); StaffEmployeeLogic employeesLogic = new StaffEmployeeLogic(manager); StaffEmployeePositionsLogic employeePositionsLogic = new StaffEmployeePositionsLogic(manager); //List<StaffEmployee> employees = employeesLogic.GetAll().Select(a => new { a.ID, a.LastName + " " + a.FirstName + " " + a.MiddleName}); AvailableEmployeesLB.ValueMember = "ID"; AvailableEmployeesLB.DisplayMember = "Name"; int structureObjectId = Convert.ToInt32(StructureObjectsCB.SelectedValue); //BindingList<Helpers.ItemIntValue> structureObjects = structureObjectsLogic.GetStructureObjectsHierarchy(false, structureObjectId); List <StaffEmployee> filteredEmloyees = employeePositionsLogic.GetByPositionID(Convert.ToInt32(PositionsCB.SelectedValue)).Select(a => a.StaffEmployee).ToList(); var employees = employeesLogic.GetAll().Where(a => filteredEmloyees.Contains(a)).Select(a => new { a.ID, Name = a.LastName + " " + a.FirstName + " " + a.MiddleName }); foreach (var employee in employees) { ItemIntValue item = new ItemIntValue(); item.ID = employee.ID; item.Name = employee.Name; AvailableEmployeesLB.Items.Add(item); } }
private void FillCategories() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; List <ItemIntValue> items0 = new List <ItemIntValue>(); WareCategoriesLogic categories = new WareCategoriesLogic(manager); items0.Clear(); //items0.Add(none); foreach (var a in categories.GetCategoriesHierarchy().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items0.Add(i); } CategoriesCB.DataSource = items0; if ((mode == "new") & (defaultCategoryId != null)) { foreach (ItemIntValue i in CategoriesCB.Items) { if (i.ID == Convert.ToInt32(defaultCategoryId)) { CategoriesCB.SelectedItem = i; } } } CategoriesCB.ValueMember = "ID"; CategoriesCB.DisplayMember = "Name"; CategoriesCB.Update(); }
//public string WareName //{ // get // { // string result = null; // if (NameTB.Text.Length > 0) // { // result = NameTB.Text; // } // return result; // } //} public void Fill() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; List <ItemIntValue> items0 = new List <ItemIntValue>(); WareCategoriesLogic categories = new WareCategoriesLogic(manager); items0.Clear(); //items0.Add(none); foreach (var a in categories.GetCategoriesHierarchy().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items0.Add(i); } CategoriesCB.DataSource = items0; CategoriesCB.ValueMember = "ID"; CategoriesCB.DisplayMember = "Name"; CategoriesCB.Update(); WareManufacturersLogic manufacturers = new WareManufacturersLogic(manager); List <ItemIntValue> items1 = new List <ItemIntValue>(); items1.Clear(); items1.Add(none); foreach (var a in manufacturers.GetAll().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items1.Add(i); } //ManufacturersCB.DataSource = manufacturers.GetAll(); ManufacturersCB.DataSource = items1; ManufacturersCB.ValueMember = "ID"; ManufacturersCB.DisplayMember = "Name"; ManufacturersCB.Update(); WareUnitsLogic units = new WareUnitsLogic(manager); List <ItemIntValue> items2 = new List <ItemIntValue>(); items2.Clear(); items2.Add(none); foreach (var a in units.GetAll().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items2.Add(i); } UnitsCB.DataSource = items2; UnitsCB.ValueMember = "ID"; UnitsCB.DisplayMember = "Name"; UnitsCB.Update(); }
/// <summary> /// ієрархія об'єктів(в текстовій формі) /// </summary> /// <returns></returns> private List <ItemIntValue> FillStructureObjectsHierarchy(bool IncludeNone) { List <ItemIntValue> list = new List <ItemIntValue>(); if (IncludeNone == true) { ItemIntValue none = new ItemIntValue(); //none.ID = -1; none.Name = "- не вибрано -"; list.Add(none); } list.AddRange(this.GetStructureObjectsHierarchy(IncludeNone).Select(a => a)); return(list); }
private void FillSelectedEmployees() { if (sheduler != null) { StaffShedulerEmployeesLogic shedulerEmployees = new StaffShedulerEmployeesLogic(manager); var employees = shedulerEmployees.GetBySheduler(sheduler.ID).Select(a => new { a.StaffEmployee.ID, Name = a.StaffEmployee.LastName + " " + a.StaffEmployee.FirstName + " " + a.StaffEmployee.MiddleName }); foreach (var employee in employees) { ItemIntValue item = new ItemIntValue(); item.ID = employee.ID; item.Name = employee.Name; SelectedEmployeesLB.Items.Add(item); } } }
private void FillStructureObjects() { StaffStructureObjectsLogic StructureObjects = new StaffStructureObjectsLogic(manager); StructureObjectsCB.ValueMember = "ID"; StructureObjectsCB.DisplayMember = "Name"; StructureObjectsCB.DropDownStyle = ComboBoxStyle.DropDownList; ItemIntValue none = new ItemIntValue(); //none.ID = -1; none.Name = "- не вибрано -"; List <ItemIntValue> list = new List <ItemIntValue>(); list.Add(none); list.AddRange(StructureObjects.GetStructureObjectsHierarchy(true).Select(a => a)); StructureObjectsCB.DataSource = list; }
private void FillStructureObjectsHierarchy(bool IncludeNone, StaffStructureObject structureObject, string prefix, bool start) { if (start == true) { items.Clear(); } if ((items.Count == 0) & (IncludeNone == true)) { ItemIntValue none = new ItemIntValue(); none.Name = "- не вибрано -"; items.Add(none); } //WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); //CompasLogger.Add(String.Format("Start Fill ToObjects Hierarchy"), CompasLogger.Level.Info); List <StaffStructureObject> structureObjects = new List <StaffStructureObject>(); if (structureObject == null) { structureObjects = this.GetAllRoot(); } else { structureObjects = this.GetByParentStructureObjectID(structureObject.ID); } foreach (StaffStructureObject a in structureObjects) { //TreeNode node = new TreeNode(; //node.Text = a.Name; //node. ItemIntValue item = new ItemIntValue(); item.ID = a.ID; item.Name = prefix + a.Name; items.Add(item); //CategoriesTV.Nodes.Add(a.ID.ToString(), a.Name); FillStructureObjectsHierarchy(IncludeNone, a, prefix.Replace("->", " ") + /*a.Name +*/ " -> ", false); } //CompasLogger.Add(String.Format("END Fill ToObjects Hierarchy"), CompasLogger.Level.Info); }
private void FillStructureObjects() { StaffStructureObjectsLogic StructureObjects = new StaffStructureObjectsLogic(manager); StructureObjectsCB.ValueMember = "ID"; StructureObjectsCB.DisplayMember = "Name"; StructureObjectsCB.DropDownStyle = ComboBoxStyle.DropDownList; StaffStructureObject none = new StaffStructureObject(); //none.ID = -1; none.Name = "- не вибрано -"; List <ItemIntValue> list = new List <ItemIntValue>(); list.AddRange(StructureObjects.GetStructureObjectsHierarchy(true)); StructureObjectsCB.DataSource = list; if (mode == "edit" || mode == "copy") { if (sheduler != null && sheduler.StructureObjectID != null) { int i = 0; foreach (object o in StructureObjectsCB.Items) { ItemIntValue StructureObject = (ItemIntValue)o; if (StructureObject.ID == sheduler.StructureObjectID) { StructureObjectsCB.SelectedIndex = i; } i++; } } if (mode == "copy") { StartDateDTP.Value = sheduler.StartDate.Date.AddDays(1); EndDateDTP.Value = sheduler.EndDate.Date.AddDays(1); StartTimeDTP.Value = sheduler.StartDate; EndTimeDTP.Value = sheduler.EndDate; } } }
private void FillStates() { StatesCB.Items.Clear(); StatesOfDocumentsLogic statesLogic = new StatesOfDocumentsLogic(manager); Compas.Helpers.ItemIntValue item = new ItemIntValue(); StatesCB.DisplayMember = "Name"; StatesCB.ValueMember = "ID"; item.ID = -1; item.Name = "- не обрано -"; StatesCB.Items.Add(item); foreach (var s in statesLogic.GetAll()) { item = new ItemIntValue(); item.ID = s.ID; item.Name = s.Name; StatesCB.Items.Add(item); } StatesCB.SelectedIndex = 0; }
private void FillCategoriesHierarchy(WareCategory category, string prefix, bool start) { if (start == true) { items.Clear(); } if (items.Count == 0) { ItemIntValue none = new ItemIntValue(); none.Name = " - не вибрано -"; items.Add(none); } //WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); List <WareCategory> categories = new List <WareCategory>(); if (category == null) { categories = this.GetAllRoot(); } else { categories = this.GetAll(category.ID); } foreach (WareCategory a in categories) { //TreeNode node = new TreeNode(; //node.Text = a.Name; //node. ItemIntValue item = new ItemIntValue(); item.ID = a.ID; item.Name = prefix + a.Name; items.Add(item); //CategoriesTV.Nodes.Add(a.ID.ToString(), a.Name); FillCategoriesHierarchy(a, prefix + a.Name + " -> ", false); } }
private void FillManufacturers() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; WareManufacturersLogic manufacturers = new WareManufacturersLogic(manager); List <ItemIntValue> items1 = new List <ItemIntValue>(); items1.Clear(); items1.Add(none); foreach (var a in manufacturers.GetAll().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items1.Add(i); } ManufacturersCB.DataSource = items1; ManufacturersCB.ValueMember = "ID"; ManufacturersCB.DisplayMember = "Name"; ManufacturersCB.Update(); }
private void FillCategories() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; List <ItemIntValue> items0 = new List <ItemIntValue>(); WareCategoriesLogic categories = new WareCategoriesLogic(manager); items0.Clear(); //items0.Add(none); foreach (var a in categories.GetCategoriesHierarchy().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items0.Add(i); } CategoriesCB.DataSource = items0; CategoriesCB.ValueMember = "ID"; CategoriesCB.DisplayMember = "Name"; CategoriesCB.Update(); }
private void SaveBt_Click(object sender, EventArgs e) { StaffShedulersLogic shedulers = new StaffShedulersLogic(manager); StaffShedulerEmployeesLogic shedulersEmployee = new StaffShedulerEmployeesLogic(manager); int? StructureObjectId = null; int? teamId = null; int? shiftId = null; int? workPlaceId = null; DateTime startDate = StartDateDTP.Value.Add(StartTimeDTP.Value.TimeOfDay); DateTime endDate = EndDateDTP.Value.Add(EndTimeDTP.Value.TimeOfDay); string description = DescriptionTB.Text; if (StructureObjectsCB.SelectedIndex > 0) { StructureObjectId = Convert.ToInt32(StructureObjectsCB.SelectedValue); } if (TeamsCB.SelectedIndex > 0) { teamId = Convert.ToInt32(TeamsCB.SelectedValue); } if (ShiftsCB.SelectedIndex > 0) { shiftId = Convert.ToInt32(ShiftsCB.SelectedValue); } if (mode == "new" || mode == "copy") { int userId = Compas.Logic.Security.CurrentSecurityContext.Identity.ID; // Define a transaction scope for the operations. using (TransactionScope transaction = new TransactionScope()) { try { StaffSheduler sheduler = shedulers.Create(StructureObjectId, shiftId, teamId, startDate, endDate, userId, DateTime.Now, description); //додаємо працівників foreach (object item in SelectedEmployeesLB.Items) { ItemIntValue i = (ItemIntValue)item; int employeeId = i.ID; shedulersEmployee.Create(sheduler, employeeId); } } catch (Exception ex) { // Handle errors and deadlocks here and retry if needed. // Allow an UpdateException to pass through and // retry, otherwise stop the execution. if (ex.GetType() != typeof(UpdateException)) { MessageBox.Show("An error occured. " + "The operation cannot be retried." + ex.Message); } // If we get to this point, the operation will be retried. } } } if (mode == "edit") { // Define a transaction scope for the operations. using (TransactionScope transaction = new TransactionScope()) { try { shedulers.Update(Convert.ToInt32(id), StructureObjectId, shiftId, teamId, startDate, endDate, description); //додаємо працівників shedulersEmployee.DeleteBySheduler(Convert.ToInt32(id)); foreach (object item in SelectedEmployeesLB.Items) { ItemIntValue i = (ItemIntValue)item; int employeeId = i.ID; shedulersEmployee.Create(sheduler, employeeId); } } catch (Exception ex) { // Handle errors and deadlocks here and retry if needed. // Allow an UpdateException to pass through and // retry, otherwise stop the execution. if (ex.GetType() != typeof(UpdateException)) { MessageBox.Show("An error occured. " + "The operation cannot be retried." + ex.Message); } // If we get to this point, the operation will be retried. } } } manager.Save(); this.Close(); }
private void Fill() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; FillCategories(); FillManufacturers(); FillUnits(); FillSecondaryUnits(); FillCodes(); FillTimeLimits(); if (mode == "edit") { WaresLogic wares = new WaresLogic(manager); var ware = wares.Get(Convert.ToInt32(id)); if (ware != null) { NameTB.Text = ware.Name; int? categoryId = ware.CategoryID; int? manufacturerId = ware.ManufacturerID; int? unitId = ware.UnitID; int? secondaryUnitId = ware.SecondaryUnitID; decimal?secondaryUnitQuantity = ware.SecondaryUnitQuantity; if (secondaryUnitQuantity != null) { SecondaryQuantityNUD.Value = Convert.ToDecimal(secondaryUnitQuantity); } if (categoryId != null) { int i = 0; foreach (ItemIntValue a in CategoriesCB.Items) { if (a.ID == categoryId) { CategoriesCB.SelectedIndex = i; } i++; } } if (unitId != null) { int i = 0; foreach (ItemIntValue a in UnitsCB.Items) { if (a.ID == unitId) { UnitsCB.SelectedIndex = i; } i++; } } if (secondaryUnitId != null) { int i = 0; foreach (ItemIntValue a in SecondaryUnitsCB.Items) { if (a.ID == secondaryUnitId) { SecondaryUnitsCB.SelectedIndex = i; } i++; } } if (manufacturerId != null) { int i = 0; foreach (ItemIntValue a in ManufacturersCB.Items) { if (a.ID == manufacturerId) { ManufacturersCB.SelectedIndex = i; } i++; } } ImagePB.SizeMode = PictureBoxSizeMode.Zoom; _image = Helpers.ImageOperations.ByteArrayToImage(ware.Image); image = ware.Image; ImagePB.Image = _image; } } }