public void Load(WageDto wage)
        {
            if (wage == null)
            {
                return;
            }

            this._id          = wage.Manager.IDManager;
            tbCurrentSum.Text = wage.CurrentSum.ToString();
            tbSumOrders.Text  = wage.SumOrders.ToString();
            tbPaid.Text       = wage.Paid.ToString();
            tbRest.Text       = wage.Rest.ToString();


            foreach (ManagersDto m in managerGet)
            {
                if (m.IDManager == wage.Manager.IDManager)
                {
                    this.cbManager.SelectedItem = m;
                    break;
                }
            }


            if ((wage.Rest == 0) && wage.Paid != 0)
            {
                tbPaid.IsEnabled = false;
            }

            cbManager.IsEnabled = false;
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (tbPaid.Text == null)
            {
                tbPaid.BorderBrush = Brushes.Red;
            }
            if (cbManager.Text == null)
            {
                cbManager.BorderBrush = Brushes.Red;
            }
            try
            {
                if (((float)Convert.ToDouble(tbCurrentSum.Text) - (float)Convert.ToDouble(tbPaid.Text)) < 0)
                {
                    MessageBox.Show("Сумма для выплаты не может составлять более " + tbCurrentSum.Text + " рyблей.");
                    return;
                }
            }
            catch
            {
                return;
            }
            try

            {
                WageDto man = new WageDto();
                man.Manager    = cbManager.SelectedItem as ManagersDto;
                man.Paid       = (float)Convert.ToDouble(tbPaid.Text);
                man.Rest       = (float)Convert.ToDouble(tbCurrentSum.Text) - (float)Convert.ToDouble(tbPaid.Text);
                man.SumOrders  = Convert.ToInt32(tbSumOrders.Text);
                man.CurrentSum = (float)Math.Round(Convert.ToDouble(tbCurrentSum.Text), 0);

                IWageProcessDb w = ProcessFactory.GetWageProcess();

                if (_id == 0)
                {
                    w.Add(man);
                }
                else
                {
                    if (man.Rest == 0)
                    {
                        man.Paid       = 0;
                        man.CurrentSum = 0;
                    }
                    man.Manager.IDManager = _id;
                    w.Update(man);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
                return;
            }
            Close();
        }
Example #3
0
        public static WageDto Convert(Wage country)
        {
            if (country == null)
            {
                return(null);
            }
            WageDto countryDto = new WageDto();

            countryDto.CurrentSum = country.CurrentSum;
            countryDto.IDWage     = country.IDWage;
            countryDto.Manager    = Convert(DaoFactory.GetManagersDao().Get(country.Manager));
            countryDto.Paid       = country.Paid;
            countryDto.Rest       = country.Rest;
            countryDto.SumOrders  = country.SumOrders;
            return(countryDto);
        }
Example #4
0
        public static Wage Convert(WageDto wageDto)
        {
            if (wageDto == null)
            {
                return(null);
            }
            Wage country = new Wage();

            country.CurrentSum = wageDto.CurrentSum;
            country.IDWage     = wageDto.IDWage;
            country.Manager    = wageDto.Manager.IDManager;
            country.Paid       = wageDto.Paid;
            country.Rest       = wageDto.Rest;
            country.SumOrders  = wageDto.SumOrders;
            return(country);
        }
Example #5
0
        private void btnEditW_Click(object sender, RoutedEventArgs e)
        {
            WageDto item = dgWage.SelectedItem as WageDto;

            if (item == null)
            {
                MessageBox.Show("Выберите запись для редактирования", "Редактирование");
                return;
            }

            AddWageManager window = new AddWageManager();

            window.Load(item);
            window.ShowDialog();
            btnUpdateW_Click(sender, e);
        }
Example #6
0
        private void btnDeleteW_Click(object sender, RoutedEventArgs e)
        {
            WageDto item = dgWage.SelectedItem as WageDto;

            if (item == null)
            {
                MessageBox.Show("Выберите запись для удаления", "Удаление информации о з/п");
                return;
            }

            MessageBoxResult result = MessageBox.Show("Удалить информации о з/п для менеджера " + item.Manager.FullName + " ?", "Удаление информации о з/п", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }

            ProcessFactory.GetWageProcess().Delete(item.Manager.IDManager);

            btnUpdateW_Click(sender, e);
        }
        public string genHtmlRating()
        {
            List <object> works    = ProcessFactory.GetWageProcess().GetList().Cast <object>().ToList();
            string        res_html = "[";

            try
            {
                foreach (var work in works)
                {
                    WageDto WorkItem = (WageDto)work;
                    res_html += "{x: '" + WorkItem.Manager.FullName + "', y: " + WorkItem.SumOrders + "},";
                }
                res_html  = res_html.Remove(res_html.LastIndexOf(','), 1);
                res_html += "]";
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Ошибка");
            }

            return(res_html);
        }
Example #8
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (tbPaid.Text == "")
            {
                tbPaid.BorderBrush = Brushes.Red;
            }
            if (tbSum.Text == "")
            {
                tbSum.BorderBrush = Brushes.Red;
            }
            if (dpFinallyDate.Text == "")
            {
                dpFinallyDate.BorderBrush = Brushes.Red;
            }
            if (dpStartDate.Text == "")
            {
                dpStartDate.BorderBrush = Brushes.Red;
            }
            if (cbEnterprise.Text == "")
            {
                cbEnterprise.BorderBrush = Brushes.Red;
            }
            if (cbManager.Text == "")
            {
                cbManager.BorderBrush = Brushes.Red;
            }
            if (cbReklama.Text == "")
            {
                cbReklama.BorderBrush = Brushes.Red;
            }
            try
            {
                if ((Convert.ToDouble(tbAllSum.Text) - Convert.ToDouble(tbPaid.Text) < 0))
                {
                    MessageBox.Show("Цена превышает размер " + tbAllSum.Text + " рублей.");
                    return;
                }
            }
            catch
            {
            }
            try
            {
                if (Convert.ToDateTime(dpStartDate.Text) > Convert.ToDateTime(dpFinallyDate.Text))
                {
                    MessageBox.Show("Дата начала размещения рекламы не должна быть позже даты окончания рекламы.");
                    return;
                }
            }
            catch
            {
            }

            try
            {
                OrdersDto or = new OrdersDto();
                or.Cost = (float)Convert.ToDouble(this.tbSum.Text);
                if (tbPaid.Text == "")
                {
                    or.Paid = 0;
                }
                else
                {
                    or.Paid = (float)Convert.ToDouble(this.tbPaid.Text);
                }
                or.FinallyDate     = Convert.ToDateTime(this.dpFinallyDate.Text);
                or.FullNameManager = this.cbManager.SelectedItem as ManagersDto;
                or.NameEnterprise  = this.cbEnterprise.SelectedItem as EnterprisesDto;
                or.StartDate       = Convert.ToDateTime(this.dpStartDate.Text);
                or.TypeReklama     = this.cbReklama.SelectedItem as TypeReklamaDto;

                int d1   = IntFromDMY(or.StartDate.Day, or.StartDate.Month, or.StartDate.Year);
                int d2   = IntFromDMY(or.FinallyDate.Day, or.FinallyDate.Month, or.FinallyDate.Year);
                int ddif = d2 - d1;

                if (or.TypeReklama.CarrierForReklama.TimeCarrier == "День")
                {
                    int t = 0;
                    if ((ddif / 30) == 0)
                    {
                        t = 1;
                    }
                    or.AllSum = (float)Math.Round(or.Cost * (ddif / 1), 0);
                }
                else if (or.TypeReklama.CarrierForReklama.TimeCarrier == "Неделя")
                {
                    int t = 0;
                    if ((ddif / 30) == 0)
                    {
                        t = 1;
                    }
                    or.AllSum = (float)Math.Round(or.Cost * (ddif / 7));
                }
                else
                {
                    int t = 0;
                    if ((ddif / 30) == 0)
                    {
                        t = 1;
                    }
                    or.AllSum = (float)Math.Round(or.Cost * t);
                }

                or.Debt = (float)Convert.ToDouble(or.AllSum) - (float)Convert.ToDouble(this.tbPaid.Text);

                IOrdersProcessDb orProcess   = ProcessFactory.GetOrdersProcess();
                IWageProcessDb   wageProcess = ProcessFactory.GetWageProcess();

                if (wageProcess.Get(or.FullNameManager.IDManager) == null)
                {
                    WageDto            wage    = new WageDto();
                    IManagersProcessDb mp      = ProcessFactory.GetManagersProcess();
                    ManagersDto        manager = mp.Get(or.FullNameManager.IDManager);
                    wage.CurrentSum = or.Cost * manager.PercentOnSale / 100;
                    wage.Manager    = or.FullNameManager;
                    wage.Paid       = 0;
                    wage.Rest       = (float)Math.Abs(Convert.ToDouble(wage.Paid - wage.CurrentSum));
                    wage.SumOrders  = 1;

                    wageProcess.Add(wage);
                }
                else
                {
                    IManagersProcessDb mp       = ProcessFactory.GetManagersProcess();
                    ManagersDto        manager  = mp.Get(or.FullNameManager.IDManager);
                    IWageProcessDb     wProcess = ProcessFactory.GetWageProcess();

                    WageDto wage = wProcess.Get(or.FullNameManager.IDManager);
                    wage.CurrentSum += or.Cost * manager.PercentOnSale / 100;
                    wage.Rest        = (float)Math.Abs(Convert.ToDouble(wage.Paid - wage.CurrentSum));
                    wage.SumOrders  += 1;

                    wageProcess.Update(wage);
                }

                if (_id == 0)
                {
                    orProcess.Add(or);
                }
                else
                {
                    or.IDOrder = _id;
                    orProcess.Update(or);
                }
            }
            catch (Exception exc)
            {
                return;
            }

            this.Close();
        }
 public void Update(WageDto wage)
 {
     _wageDao.Update(DtoConvert.Convert(wage));
 }
 public void Add(WageDto wage)
 {
     _wageDao.Add(DtoConvert.Convert(wage));
 }
        public void fillExcelTableByType(IEnumerable <object> grid, string status, FileInfo xlsxFile)
        {
            try
            {
                if (grid != null)
                {
                    ExcelPackage pck   = new ExcelPackage(xlsxFile);
                    var          excel = pck.Workbook.Worksheets.Add(status);
                    int          x     = 1;
                    int          y     = 1;

                    CultureInfo cultureInfo = new CultureInfo(Thread.CurrentThread.CurrentCulture.Name);
                    Thread.CurrentThread.CurrentCulture             = cultureInfo;
                    cultureInfo.NumberFormat.NumberDecimalSeparator = ".";
                    excel.Cells["A1:Z1"].Style.Font.Bold            = true;
                    excel.Cells.Style.HorizontalAlignment           = ExcelHorizontalAlignment.Left;
                    excel.Cells.Style.Numberformat.Format           = "General";

                    Object dtObj = new Object();

                    switch (status)
                    {
                    case "Managers": dtObj = new ManagersDto(); break;

                    case "Enterprises": dtObj = new EnterprisesDto(); break;

                    case "TypeReklama": dtObj = new TypeReklamaDto(); break;

                    case "Orders": dtObj = new OrdersDto(); break;

                    case "Carrier": dtObj = new CarrierDto(); break;

                    case "Wage": dtObj = new WageDto(); break;
                    }
                    foreach (var prop in dtObj.GetType().GetProperties())
                    {
                        excel.Cells[y, x].Value = prop.Name.Trim();
                        x++;
                    }
                    foreach (var item in grid)
                    {
                        y++;
                        Object itemObj = item;
                        x = 1;
                        foreach (var prop in itemObj.GetType().GetProperties())
                        {
                            object t = prop.GetValue(itemObj, null);
                            object val;

                            if (t == null)
                            {
                                val = "";
                            }
                            else
                            {
                                val = t.ToString();
                                if (t is ManagersDto)
                                {
                                    val = ((ManagersDto)t).FullName;
                                }

                                if (t is EnterprisesDto)
                                {
                                    val = ((EnterprisesDto)t).NameEnterprise;
                                }

                                if (t is CarrierDto)
                                {
                                    val = ((CarrierDto)t).NameCarrier;
                                }

                                if (t is TypeReklamaDto)
                                {
                                    val = ((TypeReklamaDto)t).NameReklama;
                                }
                            }
                            excel.Cells[y, x].Value = val;
                            x++;
                        }
                    }
                    excel.Cells.AutoFitColumns();
                    pck.Save();
                }
                else
                {
                    MessageBox.Show("Данные не загружены!");
                }
            }
            catch (Exception exc)
            {
                // MessageBox.Show(exc.Message, "Ошибка");
            }
        }