Beispiel #1
0
        public OrderAndTable(orders order)
        {
            this.order = order;
            worksId    = new List <int>();

            using (var dc = new MySQLEntities())
            {
                works = dc.works.ToList();

                for (int i = 0; i <= works.Count - 1; i++)
                {
                    works[i].index = i;
                    worksId.Add(i);
                }

                worksorder = (from item in dc.worksorders
                              where item.order == order.idOrders
                              select item).ToList();

                foreach (var item in worksorder)
                {
                    item.index = works.Where(c => c.idWorks == item.work).First().index;
                }
            }
        }
Beispiel #2
0
        public MasterAndTable(masters master)
        {
            this.master = master;
            districtsId = new List <int>();
            worktypesId = new List <int>();

            using (var dc = new MySQLEntities())
            {
                districts = dc.districts.ToList();

                for (int i = 0; i <= districts.Count - 1; i++)
                {
                    districts[i].index = i;
                    districtsId.Add(i);
                }

                worktypes = dc.worktypes.ToList();
                for (int i = 0; i <= worktypes.Count - 1; i++)
                {
                    worktypes[i].index = i;
                    worktypesId.Add(i);
                }

                districtsmaster = (from item in dc.districtsmasters
                                   where item.master == master.idMasters
                                   select item).ToList();

                foreach (var item in districtsmaster)
                {
                    item.index = districts.Where(c => c.iddistricts == item.district).First().index;
                }

                worktypesmaster = (from item in dc.worktypesmasters
                                   where item.master == master.idMasters
                                   select item).ToList();

                foreach (var item in worktypesmaster)
                {
                    item.index = worktypes.Where(c => c.idWorkTypes == item.worktype).First().index;
                }
            }
        }
Beispiel #3
0
        public void SaveTable()
        {
            try
            {
                using (var dc = new MySQLEntities())
                {
                    //работы
                    var result = (from c in dc.worksorders
                                  where c.order == order.idOrders
                                  select c);

                    if (result.Count() != 0)
                    {
                        foreach (var item in result)
                        {
                            dc.worksorders.Remove(item);
                        }
                    }

                    if (worksorder != null && worksorder.Count() != 0)
                    {
                        foreach (var item in worksorder)
                        {
                            //if (item.index == )
                            item.order = order.idOrders;
                            item.work  = works[(int)item.index].idWorks;
                            dc.worksorders.Add(item);
                        }
                    }

                    dc.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #4
0
        public void Save()
        {
            try
            {
                using (var dc = new MySQLEntities())
                {
                    if (master.idMasters == Guid.Empty || dc.masters.Find(master.idMasters) == null)
                    {
                        master.idMasters = Guid.NewGuid();
                        dc.masters.Add(master);
                    }
                    else
                    {
                        dc.Entry(master).State = EntityState.Modified;
                    }

                    //районы
                    var result = (from c in dc.districtsmasters
                                  where c.master == master.idMasters
                                  select c);

                    if (result.Count() != 0)
                    {
                        foreach (districtsmasters item in result)
                        {
                            dc.districtsmasters.Remove(item);
                        }
                    }

                    if (districtsmaster != null && districtsmaster.Count() != 0)
                    {
                        foreach (var item in districtsmaster)
                        {
                            //if (item.index == )
                            item.master   = master.idMasters;
                            item.district = districts[(int)item.index].iddistricts;
                            dc.districtsmasters.Add(item);
                        }
                    }

                    //виды деятельности
                    var result2 = (from c in dc.worktypesmasters
                                   where c.master == master.idMasters
                                   select c);

                    if (result.Count() != 0)
                    {
                        foreach (worktypesmasters item in result2)
                        {
                            dc.worktypesmasters.Remove(item);
                        }
                    }

                    if (worktypesmaster != null && worktypesmaster.Count() != 0)
                    {
                        foreach (var item in worktypesmaster)
                        {
                            //if (item.index == )
                            item.master   = master.idMasters;
                            item.worktype = worktypes[(int)item.index].idWorkTypes;
                            dc.worktypesmasters.Add(item);
                        }
                    }
                    //-

                    dc.SaveChanges();

                    //foreach (var item in worktypesmasters)
                    //{
                    //	item.master = master.idMasters;
                    //	dc.districtsmasters.Add(item);
                    //	dc.SaveChanges();
                    //}
                }
            }
            catch (Exception ex)
            {
            }
        }