ResponsiblePerson GetModelDatas(ResponsiblePersonViewModel _viewModel)
        {
            ResponsiblePerson _model = new ResponsiblePerson()
            {
                RespPersID            = _viewModel.RespPersID,
                DeviceID              = _viewModel.DeviceID,
                SurnameRespPers       = _viewModel.SurnameRespPers,
                NameRespPers          = _viewModel.NameRespPers,
                PatronymicRespPers    = _viewModel.PatronymicRespPers,
                PersonNumberRespPers  = _viewModel.PersonNumberRespPers,
                PositionRespPers      = _viewModel.PositionRespPers.ToString(),
                DepartmentRespPers    = _viewModel.DepartmentRespPers.ToString(),
                CorpRespPers          = _viewModel.CorpRespPers.ToString(),
                FloorRespPers         = _viewModel.FloorRespPers.ToString(),
                RoomRespPers          = _viewModel.RoomRespPers,
                PhoneRespPers         = _viewModel.PhoneRespPers,
                InternalPnoneRespPers = _viewModel.InternalPnoneRespPers,
                MobilePhoneRespPers   = _viewModel.MobilePhoneRespPers,
                EmailRespPers         = _viewModel.EmailRespPers,
                CreateDateTime        = _viewModel.CreateDateTime,
                ChangeDateTime        = _viewModel.ChangeDateTime
            };

            //_model.Device = _viewModel.Device;

            return(_model);
        }
示例#2
0
        public IList <ResponsiblePerson> GetResposiblesPersons(string company, Guid user)
        {
            CleanErrors();
            IList <ResponsiblePerson> result = new List <ResponsiblePerson>();

            try
            {
                string executeQuery        = "SELECT * FROM UCASCHEMA.V_UCA_RESPONSABLES";
                var    returnResultDataSet = connectionDataAccessErp.runQuerySqlDataSet(executeQuery);
                foreach (DataRow dr in returnResultDataSet.Tables[0].Rows)
                {
                    ResponsiblePerson newRp = ResponsiblePerson.Create(Convert.ToString(dr["NOMBRE"]), Convert.ToString(dr["RESPONSABLE"]), user, DateTime.Now, company);
                    result.Add(newRp);
                }

                if (connectionDataAccessErp.IsError)
                {
                    Error            = true;
                    ErrorDescription = connectionDataAccessErp.ErrorDescription;
                }
            }
            catch (Exception xp)
            {
                Error            = true;
                ErrorDescription = xp.Message;
            }
            return(result);
        }
        private void okButton_Click(object sender, EventArgs e)
        {
            var id = GetSelectedIdFromTable(grid);

            SelectedResponsiblePerson = EntityManager.GetResponsiblePerson(id);
            DialogResult = DialogResult.OK;
            Close();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ResponsiblePerson responsiblePerson = db.ResponsiblePersons.Find(id);

            db.ResponsiblePersons.Remove(responsiblePerson);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#5
0
 public AdInfo(string advertizeDescription, string responsibleName, string responsibleSurname, string phoneNumber, int price)
 {
     Person                    = new ResponsiblePerson();
     Person.Name               = responsibleName;
     Person.Surname            = responsibleSurname;
     this.AdvertizeDescription = advertizeDescription;
     this.PhoneNumber          = phoneNumber;
     this.Price                = price;
 }
        public ActionResult DeleteConfirmed(Guid id)
        {
            ResponsiblePerson responsiblePerson = db.ResponsiblePersons.Find(id);

            responsiblePerson.Deleted         = true;
            db.Entry(responsiblePerson).State = EntityState.Modified;
            //   db.ResponsiblePersons.Remove(responsiblePerson);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ResponsiblePersonKey,FirstName,LastName,Patronymic,ClientKey,PhoneNumber,Email,AdditionalInfo,Deleted")] ResponsiblePerson responsiblePerson)
 {
     if (ModelState.IsValid)
     {
         db.Entry(responsiblePerson).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ClientKey = new SelectList(db.Clients, "ClientKey", "OrganisationName", responsiblePerson.ClientKey);
     return(View(responsiblePerson));
 }
        public ActionResult Create([Bind(Include = "RespPersID,DeviceID,SurnameRespPers,NameRespPers,PatronymicRespPers,PersonNumberRespPers,PositionRespPers,DepartmentRespPers,CorpRespPers,FloorRespPers,RoomRespPers,PhoneRespPers,InternalPnoneRespPers,MobilePhoneRespPers,EmailRespPers,CreateDateTime,ChangeDateTime")] ResponsiblePerson responsiblePerson)
        {
            if (ModelState.IsValid)
            {
                db.ResponsiblePersons.Add(responsiblePerson);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DeviceID = new SelectList(db.Devices, "DeviceID", "InventoryNumber", responsiblePerson.DeviceID);
            return(View(responsiblePerson));
        }
        public ActionResult Create([Bind(Include = "ResponsiblePersonKey,FirstName,LastName,Patronymic,ClientKey,PhoneNumber,Email,AdditionalInfo,Deleted")] ResponsiblePerson responsiblePerson)
        {
            if (ModelState.IsValid && !IfExists(responsiblePerson))
            {
                responsiblePerson.ResponsiblePersonKey = Guid.NewGuid();
                db.ResponsiblePersons.Add(responsiblePerson);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ClientKey = new SelectList(db.Clients, "ClientKey", "OrganisationName", responsiblePerson.ClientKey);
            return(View(responsiblePerson));
        }
示例#10
0
        static void Main(string[] args)
        {
            var rp = new ResponsiblePerson(new Person()
            {
                Age = 13
            });

            WriteLine(rp.Drink());
            WriteLine(rp.Drive());
            rp.Age = 18;
            WriteLine(rp.Drink());
            WriteLine(rp.Drive());
            WriteLine(rp.DrinkAndDrive());
        }
        // GET: ResponsiblePersons/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ResponsiblePerson responsiblePerson = db.ResponsiblePersons.Find(id);

            if (responsiblePerson == null)
            {
                return(HttpNotFound());
            }
            return(View(responsiblePerson));
        }
 private bool IfExists(ResponsiblePerson responsiblePerson)
 {
     if (db.ResponsiblePersons.Any(a => a.FirstName == responsiblePerson.FirstName &&
                                   a.LastName == responsiblePerson.LastName &&
                                   a.Patronymic == responsiblePerson.Patronymic &&
                                   a.Email == responsiblePerson.Email &&
                                   a.PhoneNumber == responsiblePerson.PhoneNumber &&
                                   a.ClientKey == responsiblePerson.ClientKey &&
                                   a.AdditionalInfo == responsiblePerson.AdditionalInfo &&
                                   a.Deleted == responsiblePerson.Deleted))
     {
         return(true);
     }
     return(false);
 }
        // GET: ResponsiblePersons/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ResponsiblePerson responsiblePerson = db.ResponsiblePersons.Find(id);

            if (responsiblePerson == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ClientKey = new SelectList(db.Clients, "ClientKey", "OrganisationName", responsiblePerson.ClientKey);
            return(View(responsiblePerson));
        }
        // GET: ResponsiblePersons/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ResponsiblePerson _model = db.ResponsiblePersons.Find(id);
            var _viewModel           = ResponsiblePersonViewModel.GetViewModelDatas(_model);

            if (_model == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DeviceID = new SelectList(db.Devices, "DeviceID", "InventoryNumber", _model.DeviceID);
            return(View(_viewModel));
        }
示例#15
0
        public void Test()
        {
            var p = new Person {
                Age = 10
            };
            var rp = new ResponsiblePerson(p);

            Assert.That(rp.Drive(), Is.EqualTo("too young"));
            Assert.That(rp.Drink(), Is.EqualTo("too young"));
            Assert.That(rp.DrinkAndDrive(), Is.EqualTo("dead"));

            rp.Age = 20;

            Assert.That(rp.Drive(), Is.EqualTo("driving"));
            Assert.That(rp.Drink(), Is.EqualTo("drinking"));
            Assert.That(rp.DrinkAndDrive(), Is.EqualTo("dead"));
        }
示例#16
0
        public IList <ResponsiblePerson> GetResponsiblePersonAutocomplete(string query, int count)
        {
            ResponsiblePerson responsibleAlias = null;

            query = query.Replace(" ", $"{WildcardAny} ");

            return(GetSession().QueryOver(() => responsibleAlias)
                   .Where(Restrictions.Or(
                              Restrictions.Like(Projections.SqlFunction("concat", NHibernateUtil.String, Projections.Property(() => responsibleAlias.LastName),
                                                                        Projections.Constant(" "), Projections.Property(() => responsibleAlias.FirstName)), query, MatchMode.Start),
                              Restrictions.Like(Projections.Property(() => responsibleAlias.FirstName), query, MatchMode.Start)
                              ))
                   .OrderBy(x => x.LastName).Asc
                   .ThenBy(x => x.FirstName).Asc
                   .Take(count)
                   .List());
        }
示例#17
0
        public static void InsertResponsiblePerson(ResponsiblePerson responsiblePerson)
        {
            var query   = @"INSERT INTO ResponsiblePerson(Organization_ID, Proxy_ID, Post, Lastname, 
                                                        Name, Patronymic, Proxy_received_date, Proxy_expired_date) 
                          VALUES (@organizationId, @proxyId, @post, @lastname, @name, @patronymic, @proxyReceivedDate, @proxyExpiredDate);";
            var command = new SQLiteCommand(query, _connection);

            command.Parameters.AddWithValue("@organizationId", responsiblePerson.OrganizationId);
            command.Parameters.AddWithValue("@proxyId", responsiblePerson.ProxyId);
            command.Parameters.AddWithValue("@post", responsiblePerson.Post);
            command.Parameters.AddWithValue("@lastname", responsiblePerson.Lastname);
            command.Parameters.AddWithValue("@name", responsiblePerson.Name);
            command.Parameters.AddWithValue("@patronymic", responsiblePerson.Patronymic);
            command.Parameters.AddWithValue("@proxyReceivedDate", responsiblePerson.ProxyReceivedDate.ToString("yyyy-MM-dd"));
            command.Parameters.AddWithValue("@proxyExpiredDate", responsiblePerson.ProxyExpiredDate.ToString("yyyy-MM-dd"));
            command.ExecuteNonQuery();
        }
示例#18
0
 public void SelectPerson(object o)
 {
     try
     {
         ResponsiblePerson p = SelectedPerson.Last <ResponsiblePerson>();
         PersonID               = p.PersonID;
         Name                   = p.Name;
         OfficeNumber           = p.OfficeNumber;
         Department             = p.Department;
         ChangeButton           = true;
         RechnungsNummerTextBox = true;
     }
     catch (System.ArgumentNullException)
     {
         MessageBox.Show("No responsible Person selected");
     }
 }
        private ResponsiblePerson GetOrCreateResponsiblePerson(string responsiblePersonName)
        {
            var personData  = PersonHelper.ConvertToEntity(responsiblePersonName);
            var responsible = m_personRepository.GetResponsiblePersonByName(personData.FirstName, personData.LastName);

            if (responsible != null)
            {
                return(responsible);
            }

            responsible = new ResponsiblePerson
            {
                FirstName = personData.FirstName,
                LastName  = personData.LastName
            };
            m_projectRepository.Create(responsible);
            return(responsible);
        }
示例#20
0
        protected override int ExecuteWorkImplementation()
        {
            var responsibleTypes = new List <ResponsibleType>();

            foreach (var responsibleTypeId in m_data.ResponsibleTypeIdList)
            {
                var responsibleType = m_personRepository.Load <ResponsibleType>(responsibleTypeId);
                responsibleTypes.Add(responsibleType);
            }

            var responsiblePerson = new ResponsiblePerson
            {
                FirstName        = m_data.FirstName,
                LastName         = m_data.LastName,
                ResponsibleTypes = responsibleTypes
            };

            return((int)m_personRepository.Create(responsiblePerson));
        }
示例#21
0
        public static void UpdateResponsiblePerson(long id, ResponsiblePerson responsiblePerson)
        {
            var query   = @"UPDATE ResponsiblePerson 
                        SET Organization_ID = @organizationId, Proxy_ID = @proxyId, Post = @post,
                            Lastname = @lastname, Name = @name, Patronymic = @patronymic,
                            Proxy_received_date = @proxyReceivedDate, Proxy_expired_date = @proxyExpiredDate
                        WHERE Responsible_person_ID = @id;";
            var command = new SQLiteCommand(query, _connection);

            command.Parameters.AddWithValue("@organizationId", responsiblePerson.OrganizationId);
            command.Parameters.AddWithValue("@proxyId", responsiblePerson.ProxyId);
            command.Parameters.AddWithValue("@post", responsiblePerson.Post);
            command.Parameters.AddWithValue("@lastname", responsiblePerson.Lastname);
            command.Parameters.AddWithValue("@name", responsiblePerson.Name);
            command.Parameters.AddWithValue("@patronymic", responsiblePerson.Patronymic);
            command.Parameters.AddWithValue("@proxyReceivedDate", responsiblePerson.ProxyReceivedDate.ToString("yyyy-MM-dd"));
            command.Parameters.AddWithValue("@proxyExpiredDate", responsiblePerson.ProxyExpiredDate.ToString("yyyy-MM-dd"));
            command.Parameters.AddWithValue("@id", id);

            command.ExecuteNonQuery();
        }
示例#22
0
        public override string GetStepParameters()
        {
            var parameters = new List <string>();

            parameters.Add(GlobalId != null ? GlobalId.ToStepValue() : "$");
            parameters.Add(OwnerHistory != null ? OwnerHistory.ToStepValue() : "$");
            parameters.Add(Name != null ? Name.ToStepValue() : "$");
            parameters.Add(Description != null ? Description.ToStepValue() : "$");
            parameters.Add(ObjectType != null ? ObjectType.ToStepValue() : "$");
            parameters.Add(Identification != null ? Identification.ToStepValue() : "$");
            parameters.Add(OriginalValue != null ? OriginalValue.ToStepValue() : "$");
            parameters.Add(CurrentValue != null ? CurrentValue.ToStepValue() : "$");
            parameters.Add(TotalReplacementCost != null ? TotalReplacementCost.ToStepValue() : "$");
            parameters.Add(Owner != null ? Owner.ToStepValue() : "$");
            parameters.Add(User != null ? User.ToStepValue() : "$");
            parameters.Add(ResponsiblePerson != null ? ResponsiblePerson.ToStepValue() : "$");
            parameters.Add(IncorporationDate != null ? IncorporationDate.ToStepValue() : "$");
            parameters.Add(DepreciatedValue != null ? DepreciatedValue.ToStepValue() : "$");

            return(string.Join(", ", parameters.ToArray()));
        }
示例#23
0
        protected override void onOkButtonClick(object sender, EventArgs e)
        {
            var responsiblePerson = new ResponsiblePerson()
            {
                OrganizationId    = _organization.OrganizationId,
                ProxyId           = long.Parse(numberProxyTextBox.Text),
                Lastname          = lastnameTextBox.Text,
                Name              = nameTextBox.Text,
                Patronymic        = patronymicTextBox.Text,
                Post              = postTextBox.Text,
                ProxyReceivedDate = proxyReceivedDatePicker.Value,
                ProxyExpiredDate  = proxyExpiredDatePicker.Value
            };

            if (DialogState == DialogState.Add)
            {
                EntityManager.InsertResponsiblePerson(responsiblePerson);
            }
            else if (DialogState == DialogState.Edit)
            {
                EntityManager.UpdateResponsiblePerson(Id.Value, responsiblePerson);
            }
            this.Close();
        }
示例#24
0
        public static ResponsiblePerson GetResponsiblePerson(long id)
        {
            var qery    = @"SELECT * FROM ResponsiblePerson WHERE Responsible_person_ID = @id;";
            var command = new SQLiteCommand(qery, _connection);

            command.Parameters.AddWithValue("@id", id);
            var reader = command.ExecuteReader();

            reader.Read();
            var responsilePerson = new ResponsiblePerson()
            {
                ResponsiblePersonId = reader.GetInt64(0),
                OrganizationId      = reader.GetInt64(1),
                ProxyId             = reader.GetInt64(2),
                Post              = reader.GetString(3),
                Lastname          = reader.GetString(4),
                Name              = reader.GetString(5),
                Patronymic        = reader.GetString(6),
                ProxyReceivedDate = DateTime.Parse(reader.GetString(7)),
                ProxyExpiredDate  = DateTime.Parse(reader.GetString(8))
            };

            return(responsilePerson);
        }
示例#25
0
 public static EmailTemplate GetTemplateForResponsiblePersonTopManagment(this IService <EmailTemplate> service, ResponsiblePerson item, string MilestoneTitle, string Division, string createdBy)
 {
     return(new EmailTemplate("Initiative Hub : Task Assigned")
     {
         TemplateBody = "Dear " + item.ResponsiblePersonName.Title + ", <br/>  The below Milestones has been commented by  " + createdBy + ".  <br/> " +
                        "This is for your information." +
                        "Milestone Title : " + MilestoneTitle + " <br/>" +
                        "Division : " + Division + " <br/> " +
                        "Status : " + item.Status.StatusDesc + "  <br/>" +
                        "Milestone Owner : " + item.ResponsiblePersonName.Title + " <br/>" +
                        "Milestone Start Date :" + item.StartDate + " <br/>" +
                        "Milestone End Date :" + item.EndDate + " <br/>" +
                        "<a href='http://192.168.1.52:6090'>Click here</a> to login to Initiative Hub. <br/>" +
                        "This is auto generated mail, please do not reply. <br/>" +
                        "Pidilite Team"
     });
 }
示例#26
0
 public static EmailTemplate GetTemplateForResponsiblePerson(this IService <EmailTemplate> service, ResponsiblePerson item, string MilestoneTitle, string Division, string createdBy)
 {
     return(new EmailTemplate("Initiative Hub : Task Assigned")
     {
         TemplateBody = "Dear " + item.ResponsiblePersonName.Title + ", <br/> Initiative Hub : Task has been assigned with Below Details <br/> " +
                        "Milestone Title : " + MilestoneTitle + " <br/>" +
                        "Division : " + Division + " <br/> " +
                        "Created By : " + createdBy + "   <br/>" +
                        "Status : " + item.Status.StatusDesc + "  <br/>" +
                        "<a href='http://192.168.1.52:6090'>Click here</a> to login to Initiative Hub. <br/>" +
                        "This is auto generated mail, please do not reply. <br/>" +
                        "Pidilite Team"
     });
 }
示例#27
0
        public virtual MetadataResource GetMetadataWithDetail(long projectId)
        {
            Resource resourceAlias = null;
            Project  projectAlias  = null;
            Snapshot snapshotAlias = null;
            BookType bookTypeAlias = null;
            ProjectOriginalAuthor    projectOriginalAuthorAlias    = null;
            OriginalAuthor           originalAuthorAlias           = null;
            ProjectResponsiblePerson projectResponsiblePersonAlias = null;
            ResponsiblePerson        responsiblePersonAlias        = null;
            ResponsibleType          responsibleTypeAlias          = null;

            var session = GetSession();

            var result = session.QueryOver <MetadataResource>()
                         .JoinAlias(x => x.Resource, () => resourceAlias)
                         .JoinAlias(() => resourceAlias.Project, () => projectAlias)
                         .JoinAlias(() => projectAlias.LatestPublishedSnapshot, () => snapshotAlias, JoinType.LeftOuterJoin)
                         .JoinAlias(() => snapshotAlias.DefaultBookType, () => bookTypeAlias, JoinType.LeftOuterJoin)
                         .Where(x => x.Id == resourceAlias.LatestVersion.Id && !resourceAlias.IsRemoved && resourceAlias.Project.Id == projectId && projectAlias.IsRemoved == false)
                         .FutureValue();

            session.QueryOver <Project>()
            .Where(x => x.Id == projectId)
            .Fetch(SelectMode.Fetch, x => x.Keywords)
            .Future();

            session.QueryOver <Project>()
            .Where(x => x.Id == projectId)
            .Fetch(SelectMode.Fetch, x => x.LiteraryGenres)
            .Future();

            session.QueryOver <Project>()
            .Where(x => x.Id == projectId)
            .Fetch(SelectMode.Fetch, x => x.LiteraryKinds)
            .Future();

            session.QueryOver <Project>()
            .Where(x => x.Id == projectId)
            .Fetch(SelectMode.Fetch, x => x.LiteraryOriginals)
            .Future();

            session.QueryOver <Project>()
            .Where(x => x.Id == projectId)
            .JoinAlias(x => x.Authors, () => projectOriginalAuthorAlias, JoinType.LeftOuterJoin)
            .JoinAlias(() => projectOriginalAuthorAlias.OriginalAuthor, () => originalAuthorAlias, JoinType.LeftOuterJoin)
            .Fetch(SelectMode.Fetch, x => x.Authors)
            .Fetch(SelectMode.Fetch, x => x.Authors[0].OriginalAuthor)
            .OrderBy(() => projectOriginalAuthorAlias.Sequence).Asc
            .Future();

            session.QueryOver <Project>()
            .Where(x => x.Id == projectId)
            .JoinAlias(x => x.ResponsiblePersons, () => projectResponsiblePersonAlias, JoinType.LeftOuterJoin)
            .JoinAlias(() => projectResponsiblePersonAlias.ResponsiblePerson, () => responsiblePersonAlias, JoinType.LeftOuterJoin)
            .JoinAlias(() => projectResponsiblePersonAlias.ResponsibleType, () => responsibleTypeAlias, JoinType.LeftOuterJoin)
            .Fetch(SelectMode.Fetch, x => x.ResponsiblePersons)
            .Fetch(SelectMode.Fetch, x => x.ResponsiblePersons[0].ResponsiblePerson)
            .Fetch(SelectMode.Fetch, x => x.ResponsiblePersons[0].ResponsibleType)
            .OrderBy(() => projectResponsiblePersonAlias.Sequence).Asc
            .Future();

            return(result.Value);
        }
示例#28
0
        private void BtnConfirm_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TxtFirstName.Text) || string.IsNullOrWhiteSpace(TxtLastName.Text))
            {
                MessageBox.Show("Write  Name", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            else
            {
                if (string.IsNullOrWhiteSpace(TxtPhone.Text))
                {
                    MessageBox.Show("Write Phone", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                else
                {
                    if (CmbGender.SelectedItem == null)
                    {
                        MessageBox.Show("Choose gender", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    else
                    {
                        if (CmbPlayer.SelectedItem == null)
                        {
                            MessageBox.Show("Choose player", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }
                        else
                        {
                            if (TxtPhone.Text.Length > 11 || TxtPhone.Text.Length < 10)
                            {
                                MessageBox.Show("Phone must have  10 characters ", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                                return;
                            }
                            else
                            {
                                try
                                {
                                    if (VarIdPlayer != 0)

                                    {
                                        Random random      = new Random();
                                        var    resultClick = MessageBox.Show("Do you want to edit the information?", "Adding new player", MessageBoxButton.YesNo, MessageBoxImage.Question);
                                        if (resultClick == MessageBoxResult.Yes)
                                        {
                                            var PersonVar = context.ResponsiblePerson.Where(i => i.IdRespPerson == VarIdPlayer).FirstOrDefault();

                                            PersonVar.FirstName   = TxtFirstName.Text;
                                            PersonVar.LastName    = TxtLastName.Text;
                                            PersonVar.MiddleName  = TxtMiddleName.Text;
                                            PersonVar.PhoneNumber = TxtPhone.Text;
                                            PersonVar.IdGender    = (byte)(CmbGender.SelectedIndex + 1);

                                            //context.Player.Remove(context.Player.Where(i => i.IdPlayer == player.IdPlayer).FirstOrDefault());

                                            context.PlayerToRespReson.Remove(context.PlayerToRespReson.Where(i => i.IdRespPers == PersonVar.IdRespPerson).FirstOrDefault());

                                            context.PlayerToRespReson.Add(new PlayerToRespReson
                                            {
                                                IdPlayer   = CmbPlayer.SelectedIndex + 1,
                                                IdRespPers = PersonVar.IdRespPerson
                                            });


                                            context.SaveChanges();
                                            MessageBox.Show("Information was successfully changed", "Success", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                            VarIdPlayer = 0;
                                            Close();
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    else

                                    {
                                        ResponsiblePerson addResp = new ResponsiblePerson();
                                        addResp.FirstName   = TxtFirstName.Text;
                                        addResp.LastName    = TxtLastName.Text;
                                        addResp.MiddleName  = TxtMiddleName.Text;
                                        addResp.PhoneNumber = TxtPhone.Text;
                                        addResp.IdGender    = (byte)(CmbGender.SelectedIndex + 1);



                                        context.ResponsiblePerson.Add(addResp);
                                        context.SaveChanges();


                                        context.PlayerToRespReson.Add(new PlayerToRespReson
                                        {
                                            IdPlayer   = CmbPlayer.SelectedIndex + 1,
                                            IdRespPers = addResp.IdRespPerson
                                        });
                                        context.SaveChanges();
                                        MessageBox.Show("Person was successfully added", "Success", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                        Close();
                                    }
                                }
                                catch
                                {
                                    MessageBox.Show("Error", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#29
0
        public NewPersonVM()
        {
            Persons = new ObservableCollection <ResponsiblePerson>(ResponsiblePersonHandler.Instance.GetResponsiblePerson().OrderBy(p => p.Name));

            SaveCommand = new RelayCommand((o) =>
            {
                ResponsiblePerson vorhanden = ResponsiblePersonHandler.Instance.GetResponsiblePerson().Find(r => r.Name == Name && r.OfficeNumber == OfficeNumber && r.Department == Department);
                if (vorhanden == null && Name != null && OfficeNumber != null && Department != null)
                {
                    ResponsiblePerson r = new ResponsiblePerson()
                    {
                        Name         = Name,
                        OfficeNumber = OfficeNumber,
                        Department   = Department
                    };
                    ResponsiblePersonHandler.Instance.AddResponsiblePerson(r);
                    Persons.Add(r);
                    ResponsiblePersonHandler.Instance.Save(r);
                    Cancel(o);
                }
                else if (vorhanden != null)
                {
                    MessageBox.Show("This person already exists");
                }
                else if (Name == null)
                {
                    MessageBox.Show("Enter a name");
                }
                else if (OfficeNumber == null)
                {
                    MessageBox.Show("Enter the office Number");
                }
                else if (Department == null)
                {
                    MessageBox.Show($"Enter the department");
                }
            });

            CancelCommand = new RelayCommand(Cancel);

            ExitCommand = new RelayCommand(Exit);

            SearchCommand = new RelayCommand((o) =>
            {
                Persons = new ObservableCollection <ResponsiblePerson>(ResponsiblePersonHandler.Instance.GetResponsiblePerson().FindAll(r => r.Name.ToLower().Contains(SearchPerson.ToLower())));
            });

            SortCommand = new RelayCommand((o) =>
            {
                if (Sort == "Sort")
                {
                    Persons = new ObservableCollection <ResponsiblePerson>(ResponsiblePersonHandler.Instance.GetResponsiblePerson().OrderBy(r => r.Name));
                    Sort    = "Sort";
                }
                else if (Sort == "Kunden sortieren")
                {
                    //Rechnungen = new ObservableCollection<Rechnung>(Buchhaltung.Instance.GetRechnungen().OrderBy(r => r.KundenNummer));
                    //Sortieren = "Rechnung sortieren";
                }
            });

            SelectCommand = new RelayCommand(SelectPerson);

            ChangeCommand = new RelayCommand((o) =>
            {
                bool[] geandert = new bool[3] {
                    false, false, false
                };
                ResponsiblePerson vorhanden = ResponsiblePersonHandler.Instance.GetResponsiblePerson().Find(r => r.PersonID == PersonID);
                if (Name != null && OfficeNumber != null && Department != null)
                {
                    ResponsiblePerson r = new ResponsiblePerson()
                    {
                        PersonID     = vorhanden.PersonID,
                        Name         = Name,
                        OfficeNumber = OfficeNumber,
                        Department   = Department
                    };
                    if (vorhanden != null)
                    {
                        if (vorhanden.Name == null || r.Name != vorhanden.Name)
                        {
                            geandert[0] = true;
                        }
                        if (vorhanden.OfficeNumber == null || r.OfficeNumber != vorhanden.OfficeNumber)
                        {
                            geandert[1] = true;
                        }
                        if (vorhanden.Department == null || r.Department != vorhanden.Department)
                        {
                            geandert[2] = true;
                        }
                    }
                    else
                    {
                        geandert[0] = true;
                        geandert[1] = true;
                        geandert[2] = true;
                    }

                    ResponsiblePersonHandler.Instance.RemoveResponsiblePerson(vorhanden);
                    ResponsiblePersonHandler.Instance.AddResponsiblePerson(r);
                    ResponsiblePersonHandler.Instance.Change(r, geandert);
                    Persons = new ObservableCollection <ResponsiblePerson>(ResponsiblePersonHandler.Instance.GetResponsiblePerson().OrderBy(re => re.Name));
                    Cancel(o);
                }
                else if (vorhanden == null)
                {
                    MessageBox.Show("This person does not exists");
                }
                else if (Name == null)
                {
                    MessageBox.Show("Enter a name");
                }
                else if (OfficeNumber == null)
                {
                    MessageBox.Show("Enter the office Number");
                }
                else if (Department == null)
                {
                    MessageBox.Show($"Enter the department");
                }
            });
        }
示例#30
0
        public MainVM()
        {
            StorageLocationHandler.Instance.Load();
            locationsView = new ObservableCollection <StorageLocation>(StorageLocationHandler.Instance.GetStorageLocations());
            ResponsiblePersonHandler.Instance.Load();
            DocumentHandler.Instance.Load();
            documentsView = new ObservableCollection <Document>(DocumentHandler.Instance.GetDocument().OrderBy(r => r.DocumentNumber));

            foreach (var item in StorageLocationHandler.Instance.GetStorageLocations())
            {
                FloorSelect.Add(item.Floor);
            }

            foreach (var item in ResponsiblePersonHandler.Instance.GetResponsiblePerson())
            {
                NameSelect.Add(item.Name);
            }

            NewLocation = new RelayCommand((o) =>
            {
                Window start = new NewLocationView();
                start.ShowDialog();

                foreach (var item in StorageLocationHandler.Instance.GetStorageLocations())
                {
                    FloorSelect.Add(item.Floor);
                }
            });

            NewPerson = new RelayCommand((o) =>
            {
                Window start = new NewPersonView();
                start.ShowDialog();

                foreach (var item in ResponsiblePersonHandler.Instance.GetResponsiblePerson())
                {
                    NameSelect.Add(item.Name);
                }
            });

            SaveCommand = new RelayCommand((o) =>
            {
                Document vorhanden = DocumentHandler.Instance.GetDocument().Find(r => r.DocumentNumber == documentNumber);
                if (vorhanden == null && documentNumber > 0 && Location != null && StorageLocationHandler.Instance.GetStorageLocations().Find(l => l == Location) != null &&
                    Person != null && ResponsiblePersonHandler.Instance.GetResponsiblePerson().Find(p => p == Person) != null)
                {
                    StorageLocation l = new StorageLocation()
                    {
                        Floor       = Floor,
                        RoomNumber  = RoomNumber,
                        ShelfNumber = ShelfNumber,
                        Shelf       = Shelf
                    };

                    ResponsiblePerson p = new ResponsiblePerson()
                    {
                        Name         = Name,
                        OfficeNumber = OfficeNumber,
                        Department   = Department
                    };

                    Document d = new Document()
                    {
                        DocumentNumber   = DocumentNumber,
                        CreationDate     = DateTime.Parse(CreationDate),
                        Location         = l,
                        Person           = p,
                        BriefDescription = BriefDescription
                    };
                    DocumentHandler.Instance.AddDocument(d);
                    documentsView.Add(d);
                    DocumentHandler.Instance.Save(d);
                    Cancel(o);
                }
                else if (vorhanden != null)
                {
                    MessageBox.Show("Document already exists!");
                }
                else if (documentNumber <= 0)
                {
                    MessageBox.Show("Document number can not be under 0!");
                }
                else if (Location == null)
                {
                    MessageBox.Show("Location missing!");
                }
                else if (StorageLocationHandler.Instance.GetStorageLocations().Find(l => l == Location) == null)
                {
                    MessageBox.Show($"There is no {Location}");
                }
                else if (ResponsiblePersonHandler.Instance.GetResponsiblePerson().Find(l => l == Person) == null)
                {
                    MessageBox.Show($"There is no {Person}");
                }
            });

            CancelCommand = new RelayCommand(Cancel);

            ExitCommand = new RelayCommand(Exit);

            SearchCommand = new RelayCommand((o) =>
            {
                DocumentView = new ObservableCollection <Document>(DocumentHandler.Instance.GetDocument().FindAll(d => d.DocumentNumber.Equals(DocumentSearch)));
            });

            SortCommand = new RelayCommand((o) =>
            {
                if (Sortieren == "Rechnung sortieren")
                {
                    DocumentView = new ObservableCollection <Document>(DocumentHandler.Instance.GetDocument().OrderBy(r => r.DocumentNumber));
                    Sortieren    = "Kunden sortieren";
                }
                else if (Sortieren == "Kunden sortieren")
                {
                    DocumentView = new ObservableCollection <Document>(DocumentHandler.Instance.GetDocument().OrderBy(r => r.DocumentNumber));
                    Sortieren    = "Rechnung sortieren";
                }
            });

            SelectCommand = new RelayCommand(SelectDocument);

            ChangeCommand = new RelayCommand((o) =>
            {
                Document vorhanden = DocumentHandler.Instance.GetDocument().Find(r => r.DocumentNumber == DocumentNumber);
                bool[] geandert    = new bool[4] {
                    false, false, false, false
                };
                if (vorhanden == null && documentNumber > 0 && Location != null && StorageLocationHandler.Instance.GetStorageLocations().Find(l => l == Location) != null &&
                    Person != null && ResponsiblePersonHandler.Instance.GetResponsiblePerson().Find(p => p == Person) != null)
                {
                    StorageLocation l = new StorageLocation()
                    {
                        Floor       = Floor,
                        RoomNumber  = RoomNumber,
                        ShelfNumber = ShelfNumber,
                        Shelf       = Shelf
                    };

                    ResponsiblePerson p = new ResponsiblePerson()
                    {
                        Name         = Name,
                        OfficeNumber = OfficeNumber,
                        Department   = Department
                    };

                    Document d = new Document()
                    {
                        DocumentNumber   = DocumentNumber,
                        CreationDate     = DateTime.Parse(CreationDate),
                        Location         = l,
                        Person           = p,
                        BriefDescription = BriefDescription
                    };
                    if (d.CreationDate != vorhanden.CreationDate)
                    {
                        geandert[0] = true;
                    }
                    if (d.Location != vorhanden.Location)
                    {
                        geandert[1] = true;
                    }
                    if (d.Person != vorhanden.Person)
                    {
                        geandert[2] = true;
                    }
                    if (d.BriefDescription != vorhanden.BriefDescription)
                    {
                        geandert[3] = true;
                    }
                    DocumentHandler.Instance.RemoveDocument(vorhanden);
                    DocumentHandler.Instance.AddDocument(d);
                    documentsView.Add(d);
                    DocumentHandler.Instance.Change(d, geandert);
                    Cancel(o);
                    DocumentView = new ObservableCollection <Document>(DocumentHandler.Instance.GetDocument().OrderBy(docu => docu.DocumentNumber));
                }
                else if (vorhanden != null)
                {
                    MessageBox.Show("Document already exists!");
                }
                else if (documentNumber <= 0)
                {
                    MessageBox.Show("Document number can not be under 0!");
                }
                else if (Location == null)
                {
                    MessageBox.Show("Location missing!");
                }
                else if (StorageLocationHandler.Instance.GetStorageLocations().Find(l => l == Location) == null)
                {
                    MessageBox.Show($"There is no {Location}");
                }
            });
        }