Esempio n. 1
0
        public void btnAddVacation(object sender, EventArgs e)
        {
            Vacation holydayn = new Vacation();

            int Daysu;


            Guid id = SearcId();

            if (id == IdError)
            {
                return;
            }
            db.Workers.AsNoTracking();
            // db.Workers.Load();

            Person person = db.Workers.FirstOrDefault(i => i.Id == id);

            if (person == null)
            {
                return;
            }
            db.Entry(person).Reload();
            db.Entry(person).State = EntityState.Modified;
            // holydayn.People = db.Peoples.AsNoTracking().ToList().FirstOrDefault(i=>i.Id==id);
            holydayn.Peopleid = person.Id;
            AddHol   addHolForm = new AddHol(person.Day);
            DateTime date       = new DateTime(person.Year, 1, 1);

            if (person.Day < 1)
            {
                MessageBox.Show("don`t have weekend!!!");
                return;
            }
            addHolForm.dateTimePicker1.Value   = date;
            addHolForm.dateTimePicker2.MaxDate = addHolForm.dateTimePicker1.Value.AddDays(person.Day);
            addHolForm.dateTimePicker2.MinDate = addHolForm.dateTimePicker1.Value;
            DialogResult result = addHolForm.ShowDialog(this);

            holydayn.Id        = Guid.NewGuid();
            holydayn.FirstDate = addHolForm.dateTimePicker1.Value;

            holydayn.IndexDate = false;
            addHolForm.dateTimePicker2.MaxDate = addHolForm.dateTimePicker1.Value.AddDays(person.Day);
            holydayn.SecontDate = addHolForm.dateTimePicker2.Value;
            if (result == DialogResult.Cancel)
            {
                return;
            }
            Daysu         = person.Day - holydayn.SecontDate.Subtract(holydayn.FirstDate).Days;
            person.Day    = Daysu;
            holydayn.Days = holydayn.SecontDate.Subtract(holydayn.FirstDate).Days;
            db.Vacations.Add(holydayn);
            addHolForm.Close();
            db.SaveChanges();
            evenstb();
        }
Esempio n. 2
0
        public void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                HolyDay holydayn = new HolyDay();
                People  person   = new People();
                int     Daysu;
                int     Dayx;
                int     index     = dataGridView1.SelectedRows[0].Index;
                int     id        = 0;
                bool    converted = Int32.TryParse(dataGridView1[0, index].Value.ToString(), out id);
                if (converted == false)
                {
                    return;
                }
                db.Peoples.AsNoTracking().ToList();
                db.Peoples.Load();

                person = db.Peoples.ToList().FirstOrDefault(i => i.Id == id);
                db.Entry(person).Reload();
                db.Entry(person).State = EntityState.Modified;
                // holydayn.People = db.Peoples.AsNoTracking().ToList().FirstOrDefault(i=>i.Id==id);
                holydayn.Peopleid = person.Id;
                AddHol   addHolForm = new AddHol(person.Day);
                DateTime date       = new DateTime(person.Year, 1, 1);
                if (person.Day < 1)
                {
                    MessageBox.Show("don`t have weekend!!!");
                    return;
                }
                addHolForm.dateTimePicker1.Value   = date;
                addHolForm.dateTimePicker2.MaxDate = addHolForm.dateTimePicker1.Value.AddDays(person.Day);
                addHolForm.dateTimePicker2.MinDate = addHolForm.dateTimePicker1.Value;
                DialogResult result = addHolForm.ShowDialog(this);

                holydayn.FirstDate = addHolForm.dateTimePicker1.Value;

                holydayn.IndexDate = false;
                addHolForm.dateTimePicker2.MaxDate = addHolForm.dateTimePicker1.Value.AddDays(person.Day);
                holydayn.SecontDate = addHolForm.dateTimePicker2.Value;
                if (result == DialogResult.Cancel)
                {
                    return;
                }
                Daysu         = person.Day - holydayn.SecontDate.Subtract(holydayn.FirstDate).Days;
                person.Day    = Daysu;
                holydayn.Days = holydayn.SecontDate.Subtract(holydayn.FirstDate).Days;
                db.HolyDays.Add(holydayn);
                db.SaveChanges();
                dataGridView1.DataSource = null;
                dataGridView1.Update();
                db.Peoples.Load();
                dataGridView1.DataSource = db.Peoples.AsNoTracking().ToList();
                dataGridView1.Refresh();
            }
        }
Esempio n. 3
0
        public void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                HolyDay holydayn = new HolyDay();

                int Daysu;

                int  index     = dataGridView1.SelectedRows[0].Index;
                int  id        = 0;
                bool converted = Int32.TryParse(dataGridView1[0, index].Value.ToString(), out id);
                if (converted == false)
                {
                    return;
                }


                holydayn.People = db.Peoples.Find(id);
                AddHol addHolForm = new AddHol(holydayn.People.Day);

                if (holydayn.People.Day < 1)
                {
                    MessageBox.Show("don`t have weekend!!!");
                    return;
                }

                DialogResult result = addHolForm.ShowDialog(this);
                holydayn.FirstDate = addHolForm.dateTimePicker1.Value;


                holydayn.IndexDate = false;
                addHolForm.dateTimePicker2.MaxDate = addHolForm.dateTimePicker1.Value.AddDays(holydayn.People.Day);
                holydayn.SecontDate = addHolForm.dateTimePicker2.Value;
                if (result == DialogResult.Cancel)
                {
                    return;
                }
                Daysu = holydayn.People.Day - holydayn.SecontDate.Subtract(holydayn.FirstDate).Days;
                holydayn.People.Day = Daysu;
                holydayn.Days       = holydayn.SecontDate.Subtract(holydayn.FirstDate).Days;
                db.HolyDays.Add(holydayn);
                db.SaveChanges();
                dataGridView1.DataSource = null;
                dataGridView1.Update();
                db.Peoples.Load();
                dataGridView1.DataSource = db.Peoples.AsNoTracking().ToList();
                dataGridView1.Refresh();
            }
        }
Esempio n. 4
0
        public void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                HolyDay holydayn = new HolyDay();


                int  index     = dataGridView1.SelectedRows[0].Index;
                int  id        = 0;
                bool converted = Int32.TryParse(dataGridView1[0, index].Value.ToString(), out id);
                if (converted == false)
                {
                    return;
                }


                holydayn.People = db.Peoples.Find(id);
                AddHol addHolForm = new AddHol(holydayn.People.Day);


                DialogResult result = addHolForm.ShowDialog(this);
                holydayn.FirstDate = addHolForm.dateTimePicker1.Value;


                holydayn.IndexDate = false;
                addHolForm.dateTimePicker2.MaxDate = addHolForm.dateTimePicker1.Value.AddDays(holydayn.People.Day);
                holydayn.SecontDate = addHolForm.dateTimePicker2.Value;
                db.HolyDays.Add(holydayn);
                db.SaveChanges();
                if (result == DialogResult.Cancel)
                {
                    return;
                }
                MessageBox.Show("New date add");
            }
        }