Exemplo n.º 1
0
 private void show_chart_Click(object sender, EventArgs e)
 {
     try
     {
         profServ = new ProfitService();
         List <Profit> profits = profServ.Show(fromDate.Text, toDate.Text);
         foreach (var item in profits)
         {
             weekly_profit.Series["Income"].Points.AddXY(item.Date, item.Income);
         }
     }
     catch (Exception ex) { MessageBox.Show(ex.StackTrace); }
 }
Exemplo n.º 2
0
        public string getProfitList(string financePageJson)
        {
            try
            {
                FinancePage <Profit> financePage = FinanceJson.getFinanceJson().toObject <FinancePage <Profit> >(financePageJson);
                profitService = new ProfitService();

                financePage = profitService.getProfitList(financePage);
                return(FinanceResultData.getFinanceResultData().success(200, financePage, "成功"));
            }
            catch (InvalidOperationException ex)
            {
                //身份验证不通过
                return(FinanceResultData.getFinanceResultData().fail(401, null, ex.Message));
            }
            catch (Exception ex)
            {
                //未知的错误
                return(FinanceResultData.getFinanceResultData().fail(500, null, "未知的错误"));
            }
        }
        public void When_Has_Employees_Calculate_Profit()
        {
            string id1             = "1234";
            string occupationArea1 = "Diretoria";
            string name1           = "Joao";
            string position1       = "Diretor";
            string admissionDate1  = "2020-10-20";
            string salary1         = "R$ 10.000,00";

            Employee employee1 = new Employee(id1, occupationArea1, name1, position1, admissionDate1, salary1);

            string id2             = "12345";
            string occupationArea2 = "Contabilidade";
            string name2           = "Victor";
            string position2       = "Auxiliar";
            string admissionDate2  = "2019-05-25";
            string salary2         = "R$ 2.000,00";

            Employee employee2 = new Employee(id2, occupationArea2, name2, position2, admissionDate2, salary2);

            string id3             = "23241";
            string occupationArea3 = "Serviços Gerais";
            string name3           = "Julia";
            string position3       = "Arquiteta";
            string admissionDate3  = "2017-05-25";
            string salary3         = "R$ 3.500,00";

            Employee employee3 = new Employee(id3, occupationArea3, name3, position3, admissionDate3, salary3);

            string id4             = "15949";
            string occupationArea4 = "Relacionamento com o Cliente";
            string name4           = "Joana";
            string position4       = "Supervisora";
            string admissionDate4  = "2010-04-20";
            string salary4         = "R$ 6.000,00";

            Employee employee4 = new Employee(id4, occupationArea4, name4, position4, admissionDate4, salary4);

            string id5             = "33221";
            string occupationArea5 = "Contabilidade";
            string name5           = "Joana";
            string position5       = "Estagiário";
            string admissionDate5  = "2019-10-06";
            string salary5         = "R$ 2.000,00";

            Employee employee5 = new Employee(id5, occupationArea5, name5, position5, admissionDate5, salary5);

            List <Employee> employeeList = new List <Employee>();

            employeeList.Add(employee1);
            employeeList.Add(employee2);
            employeeList.Add(employee3);
            employeeList.Add(employee4);
            employeeList.Add(employee5);

            _configuration.Setup(x => x["MinimumSalary"]).Returns("1088");

            _employeeRepository.Setup(x => x.GetEmployees()).Returns(employeeList);

            OccupationAreaService.Setup(x => x.GetWeightList()).Returns(GenerateStarterOccupationAreaWeightList());

            SalaryWeightService.Setup(x => x.GetWeightList()).Returns(GenerateStarterSalaryWeightList());

            WorkYearsWeightService.Setup(x => x.GetWeightList()).Returns(GenerateStarterWorkYearsWeightList());

            ProfitService = new ProfitService(
                _employeeRepository.Object,
                _configuration.Object,
                _logger,
                OccupationAreaService.Object,
                SalaryWeightService.Object,
                WorkYearsWeightService.Object
                );

            double expectedProfit = 10000;

            Profit profit = ProfitService.GetProfit(expectedProfit);

            profit.EmployeesTotal.Should().Be("5");

            profit.Participations.Find(x => x.Id.Equals(employee1.Id)).ValorParticipacao.Should().Be("R$ 48.000,00");
            profit.Participations.Find(x => x.Id.Equals(employee2.Id)).ValorParticipacao.Should().Be("R$ 96.000,00");
            profit.Participations.Find(x => x.Id.Equals(employee3.Id)).ValorParticipacao.Should().Be("R$ 126.000,00");
            profit.Participations.Find(x => x.Id.Equals(employee4.Id)).ValorParticipacao.Should().Be("R$ 240.000,00");
            profit.Participations.Find(x => x.Id.Equals(employee5.Id)).ValorParticipacao.Should().Be("R$ 96.000,00");

            profit.CalculatedProfit.Should().Be("R$ 606.000,00");
            profit.ExpectedProfit.Should().Be("R$ 10.000,00");
            profit.BalanceProfit.Should().Be("-R$ 596.000,00");
        }
Exemplo n.º 4
0
        private void checkout_bt_Click(object sender, EventArgs e)
        {
            try
            {
                if (cust_contact_tb.Text == "" || cashPaid_tb.Text == "" || total_tb.Text == "" || change_tb.Text == "")
                {
                    MessageBox.Show("Textbox Empty!");
                }
                else
                {//////////pdf
                    Document  doc      = new Document(iTextSharp.text.PageSize.A4);
                    string    fileName = "D:\\Dropbox\\Project\\Project 5.1\\Medical Store\\receipts\\" + saleId_tb.Text + ".pdf";
                    PdfWriter pd       = PdfWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create));
                    doc.Open();
                    Paragraph para;

                    para           = new Paragraph("****Medical Store****");
                    para.Alignment = 1;
                    doc.Add(para);

                    para           = new Paragraph("Date: " + date.Text);
                    para.Alignment = 0;
                    doc.Add(para);

                    para           = new Paragraph("Time: " + DateTime.Now.TimeOfDay);
                    para.Alignment = 2;
                    doc.Add(para);

                    para           = new Paragraph("SaleId: " + saleId_tb.Text);
                    para.Alignment = 2;
                    doc.Add(para);

                    para           = new Paragraph("Customer Contact: " + cust_contact_tb.Text);
                    para.Alignment = 2;
                    doc.Add(para);
                    para           = new Paragraph("Salesman: " + user.UserId + "\n\n");
                    para.Alignment = 2;
                    doc.Add(para);

                    PdfPTable table = new PdfPTable(4);


                    PdfPCell cell = new PdfPCell(new Phrase("Medicine Name"));
                    cell.HorizontalAlignment = 1;

                    table.AddCell(cell);

                    cell = new PdfPCell(new Phrase("Quantity"));
                    cell.HorizontalAlignment = 1;

                    table.AddCell(cell);

                    cell = new PdfPCell(new Phrase("Unit Price"));
                    cell.HorizontalAlignment = 1;

                    table.AddCell(cell);

                    cell = new PdfPCell(new Phrase("Amount"));
                    cell.HorizontalAlignment = 1;

                    table.AddCell(cell);

                    pursServ = new PurchaseService();

                    List <Purchase> purc = pursServ.GetAll(pur.SaleId);


                    foreach (var item in purc)
                    {
                        table.AddCell(item.MedName);
                        table.AddCell(item.Quantity.ToString());
                        table.AddCell(item.UnitPrice.ToString());
                        table.AddCell(item.Amount.ToString());
                    }
                    doc.Add(table);

                    para           = new Paragraph("Total: " + total_tb.Text + "\nCash Paid: " + cashPaid_tb.Text + "\nChange: " + change_tb.Text + "\n");
                    para.Alignment = 2;
                    doc.Add(para);

                    doc.Close();

                    ///// Profit
                    pursServ = new PurchaseService();
                    List <Purchase> purs2 = pursServ.GetAll(pur.SaleId);

                    foreach (var item in purs2)
                    {
                        Medicine med = new Medicine();
                        medServ      = new MedicineService();
                        med          = medServ.GetMed(item.MedId);
                        med.Quantity = med.Quantity - item.Quantity;
                        medServ      = new MedicineService();
                        int res = medServ.UpdateMed(med);

                        prof = new Profit();

                        prof.SaleId = item.SaleId;
                        prof.MedId  = item.MedId;
                        prof.Date   = Convert.ToDateTime(date.Text);
                        prof.Income = item.Amount - (med.BuyingPrice * item.Quantity);

                        profServ = new ProfitService();

                        int rsl = profServ.Insert(prof);
                    }
                    //// History
                    HistoryService hisServ;
                    CustHistory    custHis;
                    pursServ = new PurchaseService();
                    List <Purchase>    purs      = pursServ.GetAll(pur.SaleId);
                    List <CustHistory> histories = new List <CustHistory>();
                    foreach (var item in purs)
                    {
                        custHis          = new CustHistory();
                        custHis.Date     = Convert.ToDateTime(date.Text);
                        custHis.Contact  = Convert.ToInt32(cust_contact_tb.Text);
                        custHis.SaleId   = Convert.ToInt32(item.SaleId);
                        custHis.MedName  = item.MedName;
                        custHis.Quantity = item.Quantity;

                        hisServ = new HistoryService();
                        int rst = hisServ.Insert(custHis);
                    }

                    //////Sale
                    pursServ = new PurchaseService();
                    List <Purchase> purs1 = pursServ.GetAll(pur.SaleId);
                    List <Sale>     sales = new List <Sale>();
                    foreach (var item in purs1)
                    {
                        sal          = new Sale();
                        sal.Date     = Convert.ToDateTime(date.Text);
                        sal.SaleId   = item.SaleId;
                        sal.MedName  = item.MedName;
                        sal.Quantity = item.Quantity;

                        salServ = new SaleService();
                        int rlt = salServ.Insert(sal);
                    }

                    new Home(user).Show();
                    this.Hide();
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.StackTrace); }
        }