示例#1
0
        protected override async Task QueryInfo()
        {
            try
            {
                using (var context = new DbSSContext())
                {
                    var result = await context.Nomenclature.Where(n => n.Number == (int)Identifier).Select(n => new
                    {
                        n.Number,
                        n.ShortName,
                        n.FullName,
                        n.Type,
                        n.Code_unit,
                        NameUnit  = n.Unit.Name,
                        ShortUnit = n.Unit.ShortName,
                        n.VendorCode,
                        n.Price,
                        n.Descriprion
                    }).FirstAsync();

                    View.Title = string.Format("Редактирование номенклатуры №{0}", result.Number);
                    _codeUnit  = result.Code_unit;
                    string unit = GetUnitText(result.NameUnit, result.ShortUnit);
                    View.SetNomenclatureInfo(result.Number, result.ShortName, result.FullName, result.Type, unit, result.VendorCode, result.Price, result.Descriprion);
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
示例#2
0
        internal override async Task DeleteRecord()
        {
            try
            {
                if (ExistsRecord && ShowConfirmation("Вы подтверждаете удаление контактного лица?"))
                {
                    using (var context = new DbSSContext())
                    {
                        var id = Item.ID;

                        List<Guid?> powerOfAttorneyListID = context.PowerOfAttorney.Where(p => p.ID_contactPerson == id).Select(p => (Guid?)p.ID).ToList();


                        int verificationExistsInApplication = context.Application.Where(a => powerOfAttorneyListID.Contains(a.ID_powerOfAttorney)).Count();


                        if (verificationExistsInApplication > 0)
                            throw new AggregateException();


                        await context.ContactPerson.Where(cn => cn.ID == id).DeleteAsync();
                    }

                    await Update();
                }
            }
            catch (AggregateException)
            {
                ShowError("Нельзя удалить контактное лицо, поскольку он содержится в одной или нескольких заявках!");
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task QueryInfo()
        {
            try
            {
                using (var context = new DbSSContext())
                {
                    var result = await context.ReasonCustomer.Where(rc => rc.ID == (Guid)Identifier).Select(rc => new
                    {
                        rc.ID_reason,
                        rc.Reason.ShortName,
                        //rc.Reason.FullName,
                        rc.Reason.Type,
                    }).FirstAsync();

                    _reasonID = result.ID_reason;

                    View.Reason = GetReasonText(result.ShortName, result.Type);


                    await CalculateSum();
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
示例#4
0
        protected override async Task QueryInfo()
        {
            try
            {
                using (var context = new DbSSContext())
                {
                    var result = await context.Material.Where(m => m.ID == (Guid)Identifier).Select(m => new
                    {
                        m.ID_reasonCustomer,
                        m.Number_nomenclature,
                        Material = m.Nomenclature.ShortName,
                        m.Amount,
                        m.Price,
                        m.Customer
                    }).FirstAsync();

                    _customer           = result.Customer;
                    _reasonCustomerID   = result.ID_reasonCustomer;
                    _numberNomenclature = result.Number_nomenclature;

                    View.SetMaterialInfo(result.Material, result.Amount, result.Price);

                    CalculateSum();
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        internal override async Task <object> GetInfo()
        {
            NomenclatureModel nomenclature = null;

            try
            {
                using (var context = new DbSSContext())
                {
                    var result = await context.Nomenclature.Where(n => n.Number == Item.Number).Select(n => new { n.Number, n.ShortName, n.Price }).FirstAsync();

                    nomenclature = new NomenclatureModel
                    {
                        Number    = result.Number,
                        ShortName = result.ShortName,
                        Price     = result.Price
                    };
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }

            return(nomenclature);
        }
示例#6
0
        protected override async Task QueryInfo()
        {
            try
            {
                using (var context = new DbSSContext())
                {
                    var result = await context.Contractor.Where(c => c.ID == (Guid)Identifier)
                                 .Select(c => new
                    {
                        c.View,
                        c.ShortName,
                        c.FullName,
                        c.INN,
                        c.KPP,
                        c.OKPO,
                        c.Email,
                        c.Phone,
                        c.Address,
                        c.Additionally
                    }).FirstAsync();


                    View.SetСontractorInfo(result.View, result.ShortName, result.FullName, result.INN.TrimEnd(' '),
                                           result.KPP, result.OKPO, result.Phone, result.Email, result.Address, result.Additionally);
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        private async Task View_Login()
        {
            try
            {
                var username = View.Username;
                var password = View.Password;

                using (var context = new DbSSContext())
                {
                    string hash   = SHA256.Hash(password);
                    var    result = await context.User.Where(u => u.Name == username && u.Password == hash).Select(u => u.Administrator).ToListAsync();

                    if (result?.Count > 0)
                    {
                        View.Hide();
                        _main      = new MainForm();
                        _presenter = new MainPresenter(_main, result.First());
                        _main.ShowDialog();
                        Application.Exit();
                    }
                    else
                    {
                        ShowError("Вы не верно ввели имя пользователя или пароль!");
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task <IEnumerable <Nomenclature> > QueryData()
        {
            IEnumerable <Nomenclature> result = null;

            using (var context = new DbSSContext())
            {
                if (string.IsNullOrEmpty(Type))
                {
                    result = await context.Nomenclature.Select(n => new Nomenclature
                    {
                        Number     = n.Number,
                        ShortName  = n.ShortName,
                        FullName   = n.FullName,
                        VendorCode = n.VendorCode,
                        Unit       = n.Unit.Name,
                        Type       = n.Type
                    }).OrderBy(n => new { n.ShortName, n.FullName, n.VendorCode, n.Unit }).ToListAsync();
                }
                else
                {
                    result = await context.Nomenclature.Where(n => n.Type == this.Type).Select(n => new Nomenclature
                    {
                        Number     = n.Number,
                        ShortName  = n.ShortName,
                        FullName   = n.FullName,
                        VendorCode = n.VendorCode,
                        Unit       = n.Unit.Name,
                        Type       = n.Type
                    }).OrderBy(n => new { n.ShortName, n.FullName, n.VendorCode, n.Unit }).ToListAsync();
                }
            }

            return(result);
        }
        internal async Task CalculateSum()
        {
            try
            {
                using (var context = new DbSSContext())
                {
                    var sum = await context.ReasonCustomer.Where(rc => rc.ID == (Guid)Identifier).Select(rc =>

                                                                                                         new
                    {
                        Price = ((rc.Material.Where(m => m.Customer == false).Sum(m => (m.Amount == null ? 0 : m.Amount) * (m.Price == null ? 0 : (decimal?)m.Price)) == null ? 0

                        : rc.Material.Where(m => m.Customer == false).Sum(m => (m.Amount == null ? 0 : m.Amount) * (m.Price == null ? 0 : (decimal?)m.Price)))

                                 +

                                 (rc.Work.Sum(w => (w.Amount == null ? 0 : (int?)w.Amount) * (w.NormOfTime == null ? 0 : w.NormOfTime) * (w.WorkingHour.Price == null ? 0 : w.WorkingHour.Price)) == null ? 0


                        : rc.Work.Sum(w => (w.Amount == null ? 0 : (int?)w.Amount) * (w.NormOfTime == null ? 0 : w.NormOfTime) * (w.WorkingHour.Price == null ? 0 : w.WorkingHour.Price))))
                    }).FirstAsync();

                    View.Sum = sum.Price?.ToString();
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        private async Task <int> GetGenerateNumber()
        {
            int number = 111111;

            try
            {
                using (var context = new DbSSContext())
                {
                    while (true)
                    {
                        Random generate = new Random();
                        number = generate.Next(111111, 999999);

                        int verificationNumber = await context.Application.Where(n => n.Number.Equals(number)).CountAsync();

                        if (verificationNumber == 0)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }

            return(number);
        }
        private async Task CalculateSum()
        {
            try
            {
                using (var context = new DbSSContext())
                {
                    decimal?sum = await context.ReasonCustomer.SumAsync(rc =>


                                                                        (rc.Material.Where(m => m.Customer == false).Sum(m => (m.Amount == null ? 0 : m.Amount) * (m.Price == null ? 0 : (decimal?)m.Price)) == null ? 0

                        : rc.Material.Where(m => m.Customer == false).Sum(m => (m.Amount == null ? 0 : m.Amount) * (m.Price == null ? 0 : (decimal?)m.Price)))


                                                                        +


                                                                        (rc.Work.Sum(w => (w.Amount == null ? 0 : (int?)w.Amount) * (w.NormOfTime == null ? 0 : w.NormOfTime) * (w.WorkingHour.Price == null ? 0 : w.WorkingHour.Price)) == null ? 0


                        : rc.Work.Sum(w => (w.Amount == null ? 0 : (int?)w.Amount) * (w.NormOfTime == null ? 0 : w.NormOfTime) * (w.WorkingHour.Price == null ? 0 : w.WorkingHour.Price)))

                                                                        );

                    View.Sum = sum?.ToString();
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
示例#12
0
        protected override async Task QueryInfo()
        {
            try
            {
                using (var context = new DbSSContext())
                {
                    var result = await context.Employee.Where(e => e.ID == (Guid)Identifier).Select(e => new
                    {
                        e.FFP,
                        e.ID_post,
                        Post = e.Post.Name
                    }).FirstAsync();

                    _postID = result.ID_post;
                    View.SetEmployeeInfo(result.FFP, result.Post);

                    if (View.EditingUser.Visible)
                    {
                        await GetUser((Guid)Identifier);
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task QueryInfo()
        {
            try
            {
                using (var context = new DbSSContext())
                {
                    var result = await context.Application.Where(a => a.Number == Identifier).Select(a => new
                    {
                        a.Number,
                        a.Date,
                        Contractor = a.Car.Contractor.ShortName,
                        Model      = a.Car.Model.Name,
                        a.Car.VIN,
                        ID_contactPerson      = a.PowerOfAttorney.ID_contactPerson == null ? null : (Guid?)a.PowerOfAttorney.ID_contactPerson,
                        ContactPerson         = a.PowerOfAttorney.ContactPerson.FFP == null ? null : a.PowerOfAttorney.ContactPerson.FFP,
                        ID_contractor         = a.Car.Contractor.ID,
                        PowerOfAttorneyNumber = a.PowerOfAttorney.Number == null ? null : a.PowerOfAttorney.Number,
                        PowerOfAttorneyDate   = a.PowerOfAttorney.Date == null ? null : (DateTime?)a.PowerOfAttorney.Date,
                        Employee = a.Employee.FFP,
                        a.FirstControlTime,
                        a.SecondControlTime,
                        a.Type,
                        a.Readiness,
                        a.Extradition,
                        a.Revealed,
                        a.Recommendations,
                        a.ID_powerOfAttorney,
                        a.ID_car,
                        a.ID_employee
                    }).FirstAsync();

                    await CalculateSum();

                    _contractorID  = result.ID_contractor;
                    _carID         = result.ID_car;
                    _responsibleID = result.ID_employee;
                    View.Number    = result.Number;
                    string car = GetCarText(result.Model, result.VIN);

                    View.SetApplicationInfo(result.Contractor, car, result.Date, result.FirstControlTime, result.SecondControlTime, result.Readiness, result.Extradition, result.Type, result.Revealed, result.Recommendations, result.Employee);

                    View.EnabledContactPerson = true;

                    if (result.ID_powerOfAttorney != null)
                    {
                        _contractPersonID  = result.ID_contactPerson;
                        _powerOfAttorneyID = result.ID_powerOfAttorney;

                        string powerOfAttorneyText = GetPowerOfAttorneyText(result.PowerOfAttorneyNumber, (DateTime)result.PowerOfAttorneyDate);

                        View.SetContactPersonInfo(result.ContactPerson, powerOfAttorneyText);
                        View.EnabledPowerOfAttorney = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
示例#14
0
        protected override async Task QueryInfo()
        {
            try
            {
                using (var context = new DbSSContext())
                {
                    var result = await context.Car.Where(c => c.ID == (Guid)Identifier).Select(c => new
                    {
                        c.ID,
                        c.ID_model,
                        c.Color,
                        c.ID_contractor,
                        Model = c.Model.Name,
                        c.VIN,
                        c.Mileage,
                        c.LicensePlate,
                        c.NumberEngine,
                        c.NumberChassis,
                        c.NumberBody,
                        c.Year,
                        c.Price
                    }).FirstAsync();


                    _modelID      = result.ID_model;
                    _contractorID = result.ID_contractor;

                    View.SetCarInfo(result.Model, result.VIN, result.Mileage, result.LicensePlate, result.NumberEngine, result.NumberChassis, result.NumberBody, result.Year, result.Color, result.Price);
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
示例#15
0
        protected override async Task QueryInfo()
        {
            try
            {
                using (var context = new DbSSContext())
                {
                    var result = await context.Work.Where(w => w.ID == (Guid)Identifier).Select(w => new
                    {
                        w.ID_workingHour,
                        w.Number_nomenclature,
                        w.Nomenclature.ShortName,
                        w.WorkingHour.Name,
                        w.WorkingHour.Price,
                        w.Amount,
                        w.NormOfTime
                    }).FirstAsync();

                    _workingHourID      = result.ID_workingHour;
                    _numberNomenclature = result.Number_nomenclature;

                    _price = result.Price;
                    string priceText = GetPriceText(result.Price);

                    View.SetWorkInfo(result.ShortName, result.Amount, result.Name, priceText, result.NormOfTime);


                    CalculateSum();
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
示例#16
0
        protected override async Task SaveAsync()
        {
            try
            {
                var typeManifestation = View.TypeManifestation;
                var shortName         = View.ShortName;
                var fullName          = View.FullName;
                var additionally      = View.Additionally;


                if (string.IsNullOrWhiteSpace(shortName))
                {
                    throw new ArgumentNullException(null, "Вы не ввели краткое наименование причины обращения заказчика!");
                }
                if (string.IsNullOrWhiteSpace(typeManifestation))
                {
                    throw new ArgumentNullException(null, "Вы не выбрали тип проявления!");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Reason.Where(r => r.ID == (Guid)Identifier).UpdateAsync(r => new ReasonModel
                        {
                            Type         = typeManifestation,
                            ShortName    = shortName,
                            FullName     = GetNullValue(fullName),
                            Additionally = GetNullValue(additionally)
                        });
                    }
                    else
                    {
                        ReasonModel insertReasonInfo = new ReasonModel
                        {
                            ID           = ConsistentGuid.CreateGuid(),
                            Type         = typeManifestation,
                            ShortName    = shortName,
                            FullName     = GetNullValue(fullName),
                            Additionally = GetNullValue(additionally)
                        };

                        context.Reason.Add(insertReasonInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertReasonInfo.ID;
                    }
                }

                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
示例#17
0
        protected override async Task SaveAsync()
        {
            try
            {
                if (_numberNomenclature == null)
                {
                    throw new ArgumentNullException("_numberNomenclature", "Вы не выбрали работу!");
                }
                if (_workingHourID == null)
                {
                    throw new ArgumentNullException("_workingHourID", "Вы не выбрали нормочас!");
                }


                var amount     = View.Amount;
                var normOfTime = View.NormOfTime;


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Work.Where(w => w.ID == Identifier).UpdateAsync(w => new WorkModel
                        {
                            ID_workingHour      = (Guid)_workingHourID,
                            Number_nomenclature = (int)_numberNomenclature,
                            Amount     = amount,
                            NormOfTime = normOfTime
                        });
                    }
                    else
                    {
                        WorkModel insertWorkInfo = new WorkModel
                        {
                            ID = ConsistentGuid.CreateGuid(),
                            ID_reasonCustomer   = _reasonCustomerID,
                            ID_workingHour      = (Guid)_workingHourID,
                            Number_nomenclature = (int)_numberNomenclature,
                            Amount     = amount,
                            NormOfTime = normOfTime
                        };

                        context.Work.Add(insertWorkInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertWorkInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
示例#18
0
        protected override async Task <IEnumerable <Post> > QueryData()
        {
            IEnumerable <Post> result = null;

            using (var context = new DbSSContext())
            {
                result = await context.Post.Select(p => new Post {
                    ID = p.ID, Name = p.Name
                }).OrderBy(p => new { p.Name }).ToListAsync();
            }

            return(result);
        }
示例#19
0
        protected override async Task <IEnumerable <Unit> > QueryData()
        {
            IEnumerable <Unit> result = null;

            using (var context = new DbSSContext())
            {
                result = await context.Unit.Select(u => new Unit {
                    Code = u.Code, Name = u.Name, ShortName = u.ShortName
                }).OrderBy(u => new { u.Name, u.ShortName }).ToListAsync();
            }

            return(result);
        }
示例#20
0
        protected override async Task SaveAsync()
        {
            try
            {
                if (_numberNomenclature == null)
                {
                    throw new ArgumentNullException(null, "Вы не выбрали материал!");
                }


                var amount = View.Amount;
                var price  = View.Price;


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Material.Where(w => w.ID == (Guid)Identifier).UpdateAsync(w => new MaterialModel
                        {
                            Number_nomenclature = (int)_numberNomenclature,
                            Amount = amount,
                            Price  = price
                        });
                    }
                    else
                    {
                        MaterialModel insertMaterialInfo = new MaterialModel
                        {
                            ID = ConsistentGuid.CreateGuid(),
                            ID_reasonCustomer   = _reasonCustomerID,
                            Number_nomenclature = (int)_numberNomenclature,
                            Amount   = amount,
                            Customer = _customer,
                            Price    = price
                        };

                        context.Material.Add(insertMaterialInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertMaterialInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task SaveAsync()
        {
            try
            {
                if (_reasonID == null)
                {
                    throw new ArgumentNullException(null, "Вы не выбрали причину обращения заказчика!");
                }

                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        Guid id = (Guid)_reasonID;
                        await context.ReasonCustomer.Where(rc => rc.ID == _reasonID).UpdateAsync(rc => new ReasonCustomerModel
                        {
                            ID_reason = id
                        });
                    }
                    else
                    {
                        ReasonCustomerModel insertReasonCustomerInfo = new ReasonCustomerModel
                        {
                            ID        = ConsistentGuid.CreateGuid(),
                            ID_reason = (Guid)_reasonID,
                            Number    = _numberApplication
                        };

                        context.ReasonCustomer.Add(insertReasonCustomerInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertReasonCustomerInfo.ID;

                        _workJournal.ReasonCustomerID             = Identifier;
                        _materialJournal.ReasonCustomerID         = Identifier;
                        _materialCustomerJournal.ReasonCustomerID = Identifier;
                    }
                }
                if (!openView)
                {
                    View.Close();
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
示例#22
0
        protected override async Task SaveAsync()
        {
            try
            {
                var name = View.NameModel;

                if (_markID == null)
                {
                    throw new ArgumentNullException(null, "Вы не выбрали модель");
                }
                if (string.IsNullOrWhiteSpace(name))
                {
                    throw new ArgumentNullException(null, "Вы не ввели имя модели");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Model.Where(m => m.ID == Identifier).UpdateAsync(m => new ModelModel
                        {
                            ID_mark = (Guid)_markID,
                            Name    = name
                        });
                    }
                    else
                    {
                        ModelModel insertModelInfo = new ModelModel
                        {
                            ID      = ConsistentGuid.CreateGuid(),
                            ID_mark = (Guid)_markID,
                            Name    = name
                        };

                        context.Model.Add(insertModelInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertModelInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task <IEnumerable <ReasonCustomer> > QueryData()
        {
            IEnumerable <ReasonCustomer> result = null;

            using (var context = new DbSSContext())
            {
                result = await context.ReasonCustomer.Where(rc => rc.Number == NumberApplication).Select(rc => new ReasonCustomer
                {
                    ID        = rc.ID,
                    ShortName = rc.Reason.ShortName,
                    FullName  = rc.Reason.FullName,
                    Type      = rc.Reason.Type,

                    // расчет суммы материалов
                    //PriceMaterial = (rc.Material == null ? 0 : rc.Material.Sum(m => m.Amount * m.Price)),


                    //PriceMaterial = (rc.Material.Sum(m => (m.Amount == null ? 0 : m.Amount) * (m.Price == null ? 0 : (decimal?)m.Price)) == null ? 0

                    //: rc.Material.Sum(m => (m.Amount == null ? 0 : m.Amount) * (m.Price == null ? 0 : (decimal?)m.Price))),

                    // расчет суммы работ
                    //PriceWork = (rc.Work.Sum(w => (w.Amount == null ? 0 : (int?)w.Amount) * (w.NormOfTime == null ? 0 : w.NormOfTime) * (w.WorkingHour.Price == null ? 0 : w.WorkingHour.Price)) == null ? 0


                    //: rc.Work.Sum(w => (w.Amount == null ? 0 : (int?)w.Amount) * (w.NormOfTime == null ? 0 : w.NormOfTime) * (w.WorkingHour.Price == null ? 0 : w.WorkingHour.Price))),


                    //расчет цены услуги
                    Price =

                        (rc.Material.Where(m => m.Customer == false).Sum(m => (m.Amount == null ? 0 : m.Amount) * (m.Price == null ? 0 : (decimal?)m.Price)) == null ? 0

                    : rc.Material.Where(m => m.Customer == false).Sum(m => (m.Amount == null ? 0 : m.Amount) * (m.Price == null ? 0 : (decimal?)m.Price)))


                        +


                        (rc.Work.Sum(w => (w.Amount == null ? 0 : (int?)w.Amount) * (w.NormOfTime == null ? 0 : w.NormOfTime) * (w.WorkingHour.Price == null ? 0 : w.WorkingHour.Price)) == null ? 0


                    : rc.Work.Sum(w => (w.Amount == null ? 0 : (int?)w.Amount) * (w.NormOfTime == null ? 0 : w.NormOfTime) * (w.WorkingHour.Price == null ? 0 : w.WorkingHour.Price)))
                }).OrderBy(rc => new { rc.ShortName, rc.FullName, rc.Type }).ToListAsync();
            }

            return(result);
        }
示例#24
0
        protected override async Task SaveAsync()
        {
            try
            {
                var number = View.Number;
                var date   = View.Date;


                if (string.IsNullOrWhiteSpace(number))
                {
                    throw new ArgumentNullException(null, "Введите номер доверености");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.PowerOfAttorney.Where(pa => pa.ID == (Guid)Identifier).UpdateAsync(pa => new PowerOfAttorneyModel
                        {
                            Number = number,
                            Date   = date
                        });
                    }
                    else
                    {
                        PowerOfAttorneyModel insertPowerOfAttorneyInfo = new PowerOfAttorneyModel
                        {
                            ID               = ConsistentGuid.CreateGuid(),
                            Number           = number,
                            Date             = date,
                            ID_contactPerson = _contactPersonID
                        };

                        context.PowerOfAttorney.Add(insertPowerOfAttorneyInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertPowerOfAttorneyInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task <IEnumerable <Employee> > QueryData()
        {
            IEnumerable <Employee> result = null;

            using (var context = new DbSSContext())
            {
                result = await context.Employee.Select(e => new Employee
                {
                    ID   = e.ID,
                    FFP  = e.FFP,
                    Post = e.Post.Name
                }).OrderBy(e => new { e.FFP, e.Post }).ToListAsync();
            }

            return(result);
        }
        protected override async Task <IEnumerable <WorkingHour> > QueryData()
        {
            IEnumerable <WorkingHour> result = null;

            using (var context = new DbSSContext())
            {
                result = await context.WorkingHour.Select(w => new WorkingHour
                {
                    ID    = w.ID,
                    Name  = w.Name,
                    Price = w.Price
                }).ToListAsync();
            }

            return(result);
        }
示例#27
0
        protected override async Task <IEnumerable <PowerOfAttorney> > QueryData()
        {
            IEnumerable <PowerOfAttorney> result = null;

            using (var context = new DbSSContext())
            {
                result = await context.PowerOfAttorney.Where(p => p.ID_contactPerson == ContactPersonID).Select(p => new PowerOfAttorney
                {
                    ID     = p.ID,
                    Number = p.Number,
                    Date   = p.Date
                }).OrderBy(p => new { p.Number, p.Date }).ToListAsync();
            }

            return(result);
        }
示例#28
0
        protected override async Task <IEnumerable <Option> > QueryData()
        {
            IEnumerable <Option> result = null;

            using (var context = new DbSSContext())
            {
                result = await context.Option.Select(o => new Option
                {
                    ID        = o.ID,
                    ShortName = o.ShortName,
                    FullName  = o.FullName
                }).OrderBy(o => new { o.ShortName, o.FullName }).ToListAsync();
            }

            return(result);
        }
示例#29
0
        protected override async Task QueryInfo()
        {
            try
            {
                using (var context = new DbSSContext())
                {
                    var result = await context.Post.Where(p => p.ID == (Guid)Identifier).FirstAsync();

                    View.Post = result.Name;
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task SaveAsync()
        {
            try
            {
                var name  = View.NameWorkingHour;
                var price = View.Price;


                if (string.IsNullOrWhiteSpace(name))
                {
                    throw new ArgumentNullException(null, "Вы не ввели наименование нормочаса!");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.WorkingHour.Where(w => w.ID == Identifier).UpdateAsync(w => new WorkingHourModel
                        {
                            Name  = name,
                            Price = price
                        });
                    }
                    else
                    {
                        WorkingHourModel insertWorkingHourInfo = new WorkingHourModel
                        {
                            ID    = ConsistentGuid.CreateGuid(),
                            Name  = name,
                            Price = price
                        };

                        context.WorkingHour.Add(insertWorkingHourInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertWorkingHourInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }