private void loadAllInformation()
        {
            //Generate Field
            var listInput           = productInputBO.GetData(u => u.isDelete == false && u.Date.Value.Month == Month && u.Date.Value.Year == Year, u => u.PaymentInputs);
            var listOutput          = productOutputBO.GetData(u => u.isDelete == false && u.Date.Value.Month == Month && u.Date.Value.Year == Year, u => u.PaymentOutputs);
            var listEmployeePayment = employeePaymentBO.GetData((u => u.isDelete == false && u.DATE.Value.Month == Month && u.DATE.Value.Year == Year));
            var listTimekeeping     = timekeepingBO.GetData((u => u.isDelete == false));

            // Weight
            txtProductInputWeight.Text  = listInput.Sum(u => u.ProductWeight) != 0? listInput.Sum(u => u.ProductWeight).ToString("#,###"):"0";
            txtProductOutputWeight.Text = listOutput.Sum(u => u.ProductWeight) != 0? listOutput.Sum(u => u.ProductWeight).ToString("#,###"):"0";
            //Amount
            txtProductInputAmount.Text  = listInput.Sum(u => u.TotalAmount) != 0? listInput.Sum(u => u.TotalAmount).ToString("#,###"):"0";
            txtProductOutputAmount.Text = listOutput.Sum(u => u.TotalAmount) != 0? listOutput.Sum(u => u.TotalAmount).ToString("#,###"):"0";
            //Payed
            txtInputPay.Text    = listInput.Sum(u => u.Payed) != 0? listInput.Sum(u => u.Payed).ToString("#,###"):"0";
            txtOutputPayed.Text = listOutput.Sum(u => u.Payed) != 0? listOutput.Sum(u => u.Payed).ToString("#,###"):"0";
            //Residue
            txtInputResidue.Text  = (listInput.Sum(u => u.TotalAmount) - listInput.Sum(u => u.Payed)) != 0? (listInput.Sum(u => u.TotalAmount) - listInput.Sum(u => u.Payed)).ToString("#,###"):"0";
            txtOutputResidue.Text = (listOutput.Sum(u => u.TotalAmount) - listOutput.Sum(u => u.Payed)) != 0? (listOutput.Sum(u => u.TotalAmount) - listOutput.Sum(u => u.Payed)).ToString("#,###"):"0";
            //Wage
            txtWage.Text = listEmployeePayment.Sum(u => u.PAY) != 0? listEmployeePayment.Sum(u => u.PAY).ToString("#,###"):"0";
            //Profitable
            txtProfitable.Text      = (listOutput.Sum(u => u.Payed) - listInput.Sum(u => u.Payed) - listEmployeePayment.Sum(u => u.PAY)) != 0 ? (listOutput.Sum(u => u.Payed) - listInput.Sum(u => u.Payed) - listEmployeePayment.Sum(u => u.PAY)).ToString("#,###") : "0";
            txtProfitableTotal.Text = (listOutput.Sum(u => u.TotalAmount) - listInput.Sum(u => u.TotalAmount) - listEmployeePayment.Sum(u => u.PAY)) != 0 ? (listOutput.Sum(u => u.Payed) - listInput.Sum(u => u.Payed) - listEmployeePayment.Sum(u => u.PAY)).ToString("#,###") : "0";
            //percent
            var listInputMonthAgo  = productInputBO.GetData(u => u.isDelete == false && u.Date.Value.Month == Month - 1 && u.Date.Value.Year == Year);
            var listOutputMonthAgo = productOutputBO.GetData(u => u.isDelete == false && u.Date.Value.Month == Month - 1 && u.Date.Value.Year == Year);

            if (Month == 1)
            {
                listInputMonthAgo  = productInputBO.GetData(u => u.isDelete == false && u.Date.Value.Month == 12 && u.Date.Value.Year == Year - 1);
                listOutputMonthAgo = productOutputBO.GetData(u => u.isDelete == false && u.Date.Value.Month == 12 && u.Date.Value.Year == Year - 1);
            }
            double TotalInput    = productInputBO.GetData(u => u.isDelete == false && u.Date.Value.Year == Year).Sum(u => u.TotalWeight);
            double TotalOutput   = productOutputBO.GetData(u => u.isDelete == false && u.Date.Value.Year == Year).Sum(u => u.TotalWeight);
            float  InputPercent  = ((float)((listInput.Sum(u => u.TotalWeight) * 100) / (float)TotalInput) - ((float)(listInputMonthAgo.Sum(u => u.TotalWeight) * 100) / (float)TotalInput));
            float  OutputPercent = ((float)listOutput.Sum(u => u.TotalWeight) * 100 / (float)TotalOutput - (float)listOutputMonthAgo.Sum(u => u.TotalWeight) * 100 / (float)TotalOutput);

            if (InputPercent >= 0)
            {
                txtInputPercent.Text      = InputPercent.ToString("0.0") + "%";
                pictureInputPercent.Image = Properties.Resources.arrow_up_icon;
            }
            if (InputPercent < 0)
            {
                txtInputPercent.Text      = (InputPercent * (-1)).ToString("0.0") + "%";
                pictureInputPercent.Image = Properties.Resources.arrow_down_icon;
            }
            if (OutputPercent >= 0)
            {
                txtOutputPercent.Text      = OutputPercent.ToString("0.0") + "%";
                pictureOutputPercent.Image = Properties.Resources.arrow_up_icon;
            }
            if (OutputPercent < 0)
            {
                txtOutputPercent.Text      = (OutputPercent * (-1)).ToString("0.0") + "%";
                pictureOutputPercent.Image = Properties.Resources.arrow_down_icon;
            }
        }
Exemple #2
0
        private void frmPrint_Load(object sender, EventArgs e)
        {
            var    listTT  = _list;
            var    _detail = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == _msnv && u.MonthOfPay == _month && u.YearOfPay == _year).First();
            double debtAgo = 0;

            if (_month == 1)
            {
                int count = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == _msnv).Where(u => u.MonthOfPay == 12 && u.YearOfPay == _year - 1).Count();
                if (count != 0)
                {
                    debtAgo = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == _msnv).Where(u => u.MonthOfPay == 12 && u.YearOfPay == _year - 1).First().NEBT;
                }
            }
            else
            {
                int count = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == _msnv).Where(u => u.DATE.Value.Month == _month - 1 && u.DATE.Value.Year == _year).Count();
                if (count != 0)
                {
                    debtAgo = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == _msnv).Where(u => u.MonthOfPay == _month - 1 && u.YearOfPay == _year).First().NEBT;
                }
            }
            printEmployee1.SetDataSource(_list);
            printEmployee1.SetParameterValue("pEmployeeName", EmployeeBO.GetData(u => u.isDelete == false && u.MSNV == _msnv).First().Hoten);
            printEmployee1.SetParameterValue("pMSTT", "TT" + _detail.ID.ToString("d6"));
            printEmployee1.SetParameterValue("pDate", _detail.DATE);
            printEmployee1.SetParameterValue("pTimekeeping", _detail.MonthOfPay + "/" + _detail.YearOfPay);
            printEmployee1.SetParameterValue("pWage", _detail.Wage);
            printEmployee1.SetParameterValue("pCash", _detail.Cash);
            printEmployee1.SetParameterValue("pFood", _list.Sum(u => u.Food));
            printEmployee1.SetParameterValue("pBonus", _list.Sum(u => u.Bunus));
            printEmployee1.SetParameterValue("pPunish", _list.Sum(u => u.Punish));
            printEmployee1.SetParameterValue("pPayment", _detail.PAY);
            printEmployee1.SetParameterValue("pDept", debtAgo);
            printEmployee1.SetParameterValue("pMSNV", _msnv);
            crystalReportViewer.ReportSource = printEmployee1;
        }
Exemple #3
0
 private void loadPrice()
 {
     if (txtMSNV.Text == string.Empty)
     {
         txtMoneyOfProduct.Text = preferceProductPriceBO.GetData(u => u.Name.Trim() == "Sản phẩm").First().Price.ToString();
         txtMoneyOfTime.Text    = preferceProductPriceBO.GetData(u => u.Name.Trim() == "Thời gian").First().Price.ToString();
     }
     else
     {
         var listP = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == txtMSNV.Text
                                               & u.MonthOfPay == int.Parse(txtMonth.Text) && u.YearOfPay == int.Parse(txtYear.Text));
         if (listP.Count == 0)
         {
             txtMoneyOfProduct.Text = preferceProductPriceBO.GetData(u => u.Name.Trim() == "Sản phẩm").First().Price.ToString();
             txtMoneyOfTime.Text    = preferceProductPriceBO.GetData(u => u.Name.Trim() == "Thời gian").First().Price.ToString();
         }
         else
         {
             txtMoneyOfProduct.Text = listP.First().ProductPrice.ToString();
             txtMoneyOfTime.Text    = listP.First().TimePrice.ToString();
         }
     }
 }
Exemple #4
0
        private void loadDG()
        {
            ResetForm();
            dataDS.Rows.Clear();
            if (txtMSNV.Text == "All")
            {
                dataDS.Columns.Clear();
                #region Columns DataGridView
                dataDS.ColumnCount     = 4;
                dataDS.Columns[0].Name = "MSNV";
                dataDS.Columns[1].Name = "Họ và tên";
                dataDS.Columns[2].Name = "Tiền đã thanh toán";
                dataDS.Columns[3].Name = "Chấm công";

                dataDS.Columns[0].Width = 100;
                dataDS.Columns[1].Width = 150;
                dataDS.Columns[2].Width = 900;
                dataDS.Columns[3].Width = 100;
                #endregion
                var listEmployee = employeeBO.GetData(u => u.isDelete == false);
                int i            = 0;
                foreach (var item in listEmployee)
                {
                    dataDS.Rows.Add();
                    if (i % 2 == 0)
                    {
                        dataDS.Rows[i].Cells[0].Style.BackColor = Color.Gainsboro;
                        dataDS.Rows[i].Cells[1].Style.BackColor = Color.Gainsboro;
                        dataDS.Rows[i].Cells[2].Style.BackColor = Color.Gainsboro;
                        dataDS.Rows[i].Cells[3].Style.BackColor = Color.Gainsboro;
                    }
                    else
                    {
                        dataDS.Rows[i].Cells[0].Style.BackColor = Color.WhiteSmoke;
                        dataDS.Rows[i].Cells[1].Style.BackColor = Color.WhiteSmoke;
                        dataDS.Rows[i].Cells[2].Style.BackColor = Color.WhiteSmoke;
                        dataDS.Rows[i].Cells[3].Style.BackColor = Color.WhiteSmoke;
                    }
                    var ListDB = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == item.MSNV && u.DATE.Value.Month == int.Parse(txtMonth.Text) && u.DATE.Value.Year == int.Parse(txtYear.Text));
                    dataDS.Rows[i].Cells[0].Value = item.MSNV;
                    dataDS.Rows[i].Cells[1].Value = item.Hoten;
                    dataDS.Rows[i].Cells[2].Value = ListDB.Sum(u => u.PAY) != 0? ListDB.Sum(u => u.PAY).ToString("#,###"):"0";
                    string timekeeping = "";
                    int    t           = 0;
                    foreach (var itemTime in employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == item.MSNV).Select(u => u.MonthOfPay).Distinct())
                    {
                        if (t == 0)
                        {
                            timekeeping = itemTime.ToString();
                        }
                        if (t > 0)
                        {
                            timekeeping += "+" + itemTime.ToString();
                        }
                        t++;
                    }
                    dataDS.Rows[i].Cells[3].Value           = timekeeping;
                    dataDS.Rows[i].Cells[3].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    i++;
                }
                var listAllPayment = employeePaymentBO.GetData(u => u.isDelete == false && u.DATE.Value.Month == Month && u.DATE.Value.Year == Year);
                txtPayed.Text = listAllPayment.Sum(u => u.PAY) != 0 ? listAllPayment.Sum(u => u.PAY).ToString("#,###") : "0";
            }
            else
            {
                dataDS.Columns.Clear();
                #region Columns DataGridView
                dataDS.ColumnCount      = 13;
                dataDS.Columns[0].Name  = "MSTT";
                dataDS.Columns[1].Name  = "Ngày lập";
                dataDS.Columns[2].Name  = "MSNV";
                dataDS.Columns[3].Name  = "Họ và tên";
                dataDS.Columns[4].Name  = "Thời gian";
                dataDS.Columns[5].Name  = "Sản phẩm";
                dataDS.Columns[6].Name  = "Tiền nợ trước";
                dataDS.Columns[7].Name  = "Tiền ứng";
                dataDS.Columns[8].Name  = "Tiền cơm";
                dataDS.Columns[9].Name  = "Tiền thưởng";
                dataDS.Columns[10].Name = "Tiền phạt";
                dataDS.Columns[11].Name = "Tiền đã thanh toán";
                dataDS.Columns[12].Name = "Chấm công";

                dataDS.Columns[0].Width  = 100;
                dataDS.Columns[1].Width  = 150;
                dataDS.Columns[2].Width  = 100;
                dataDS.Columns[3].Width  = 150;
                dataDS.Columns[4].Width  = 100;
                dataDS.Columns[5].Width  = 100;
                dataDS.Columns[6].Width  = 150;
                dataDS.Columns[7].Width  = 150;
                dataDS.Columns[8].Width  = 100;
                dataDS.Columns[9].Width  = 100;
                dataDS.Columns[10].Width = 100;
                dataDS.Columns[11].Width = 150;
                dataDS.Columns[12].Width = 100;
                #endregion
                payment = new Payment();
                double debtAgo      = 0;
                int    Time         = (int)listTime.Sum(u => u.Time);
                int    Product      = (int)listTime.Sum(u => long.Parse(u.TotalWeight.ToString()));
                int    ProductPrice = 0;
                int    TimePrice    = 0;
                int    priceCount   = listEpay.Where(u => u.DATE.Value.Month == Month && u.DATE.Value.Year == Year).Count();
                if (priceCount != 0)
                {
                    ProductPrice = listEpay.Where(u => u.DATE.Value.Month == Month && u.DATE.Value.Year == Year).First().ProductPrice;
                    TimePrice    = listEpay.Where(u => u.DATE.Value.Month == Month && u.DATE.Value.Year == Year).First().TimePrice;
                }
                payment.cash  = (double)listTime.Sum(u => u.AdvancePayment);
                payment.payed = listEpay.Where(u => u.DATE.Value.Month == Month && u.DATE.Value.Year == Year).Sum(u => u.PAY);
                //GetTime month ago =>Debt
                if (Month == 1)
                {
                    int count = listEpay.Where(u => u.DATE.Value.Month == 12 && u.DATE.Value.Year == Year - 1).Count();
                    if (count != 0)
                    {
                        payment.debtAgo = listEpay.Where(u => u.DATE.Value.Month == 12 && u.DATE.Value.Year == Year - 1).First().NEBT;
                    }
                }
                else
                {
                    int count = listEpay.Where(u => u.DATE.Value.Month == Month - 1 && u.DATE.Value.Year == Year).Count();
                    if (count != 0)
                    {
                        payment.debtAgo = listEpay.Where(u => u.DATE.Value.Month == Month - 1 && u.DATE.Value.Year == Year).First().NEBT;
                    }
                }
                payment.pay = Time * TimePrice + Product * ProductPrice - payment.cash - payment.debtAgo - payment.payed;
                var listDB = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == msnv && u.DATE.Value.Month == Month && u.DATE.Value.Year == Year).ToList();
                int i      = 0;
                foreach (var item in listDB)
                {
                    dataDS.Rows.Add();
                    var ListDB = timekeepingBO.GetData(u => u.isDelete == false && u.MSNV == item.MSNV && u.Date.Value.Month == item.MonthOfPay && u.Date.Value.Year == item.YearOfPay);
                    dataDS.Rows[i].Cells[0].Value = "TT" + item.ID.ToString("D6");
                    dataDS.Rows[i].Cells[1].Value = item.DATE.Value.ToShortDateString();
                    dataDS.Rows[i].Cells[2].Value = item.MSNV;
                    dataDS.Rows[i].Cells[3].Value = employeeBO.GetNameByID(item.MSNV);
                    dataDS.Rows[i].Cells[4].Value = Math.Round(ListDB.Sum(u => u.Time), 1);
                    dataDS.Rows[i].Cells[5].Value = ListDB.Sum(u => u.TotalWeight);
                    //GetTime month ago =>Debt
                    if (Month == 1)
                    {
                        int count = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == item.MSNV).Where(u => u.DATE.Value.Month == 12 && u.DATE.Value.Year == Year - 1).Count();
                        if (count != 0)
                        {
                            debtAgo = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == item.MSNV).Where(u => u.DATE.Value.Month == 12 && u.DATE.Value.Year == Year - 1).First().NEBT;
                        }
                    }
                    else
                    {
                        int count = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == item.MSNV).Where(u => u.DATE.Value.Month == Month - 1 && u.DATE.Value.Year == Year).Count();
                        if (count != 0)
                        {
                            debtAgo = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == item.MSNV).Where(u => u.DATE.Value.Month == Month - 1 && u.DATE.Value.Year == Year).First().NEBT;
                        }
                    }
                    dataDS.Rows[i].Cells[6].Value  = debtAgo;
                    dataDS.Rows[i].Cells[7].Value  = item.Cash != 0? item.Cash.ToString("#,###"):"0";
                    dataDS.Rows[i].Cells[8].Value  = ListDB.Sum(u => u.Food) != 0? ListDB.Sum(u => u.Food).ToString("#,###"):"0";
                    dataDS.Rows[i].Cells[9].Value  = ListDB.Sum(u => u.Bunus) != 0? ListDB.Sum(u => u.Bunus).ToString("#,###"):"0";
                    dataDS.Rows[i].Cells[10].Value = ListDB.Sum(u => u.Punish) != 0? ListDB.Sum(u => u.Punish).ToString("#,###"):"0";
                    dataDS.Rows[i].Cells[11].Value = item.PAY != 0? item.PAY.ToString("#,###"):"0";
                    dataDS.Rows[i].Cells[12].Value = item.MonthOfPay + "/" + item.YearOfPay;
                    i++;
                }
                var listAllPayment = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == txtMSNV.Text && u.DATE.Value.Month == Month && u.DATE.Value.Year == Year);
                txtPayed.Text = listAllPayment.Sum(u => u.PAY) != 0 ? listAllPayment.Sum(u => u.PAY).ToString("#,###") : "0";
            }
        }
        private void frmPrintTimekeeping_Load(object sender, EventArgs e)
        {
            try
            {
                var listTT       = _list;
                int month        = listTT.First().Date.Month;
                int year         = listTT.First().Date.Year;
                int Moneyproduct = 0;
                int Moneytime    = 0;
                var listPay      = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == _msnv && u.MonthOfPay == month && u.YearOfPay == year);
                if (listPay.Count != 0)
                {
                    Moneyproduct = listPay.First().ProductPrice;
                    Moneytime    = listPay.First().TimePrice;
                }
                else
                {
                    Moneyproduct = preferceProductPriceBO.GetData(u => u.isDelete == false && u.ID == 1).First().Price.Value;
                    Moneytime    = preferceProductPriceBO.GetData(u => u.isDelete == false && u.ID == 2).First().Price.Value;
                }
                double Debt = 0;
                if (month != 1)
                {
                    int count = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == _msnv && u.MonthOfPay == month - 1 && u.YearOfPay == year).Count();
                    if (count != 0)
                    {
                        Debt = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == _msnv && u.MonthOfPay == month - 1 && u.YearOfPay == year).First().NEBT;
                    }
                }
                if (month == 1)
                {
                    int count = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == _msnv && u.MonthOfPay == 12 && u.YearOfPay == year - 1).Count;
                    if (count != 0)
                    {
                        Debt = employeePaymentBO.GetData(u => u.isDelete == false && u.MSNV == _msnv && u.MonthOfPay == 12 && u.YearOfPay == year - 1).First().NEBT;
                    }
                }
                Double Pay = 0;
                printTimekeeping1.SetDataSource(_list);
                int Countwork = _list.Count() - _list.Where(u => u.isRest == "Yes").Count();
                printTimekeeping1.SetParameterValue("pCountWork", Countwork);
                printTimekeeping1.SetParameterValue("pEmployeeName", EmployeeBO.GetData(u => u.isDelete == false && u.MSNV == _msnv).First().Hoten);
                printTimekeeping1.SetParameterValue("pTimekeeping", listTT.First().Date.Month + "/" + listTT.First().Date.Year);
                printTimekeeping1.SetParameterValue("pCash", listTT.Sum(u => u.AdvancePayment));
                printTimekeeping1.SetParameterValue("pFood", listTT.Sum(u => u.Food));
                printTimekeeping1.SetParameterValue("pBonus", _list.Sum(u => u.Bunus));
                printTimekeeping1.SetParameterValue("pPunish", _list.Sum(u => u.Punish));
                printTimekeeping1.SetParameterValue("pProduct", _list.Sum(u => u.TotalWeight));
                printTimekeeping1.SetParameterValue("pTime", _list.Sum(u => u.Time));
                printTimekeeping1.SetParameterValue("pMSNV", _msnv);
                printTimekeeping1.SetParameterValue("pDebt", Debt);
                printTimekeeping1.SetParameterValue("pMoneyProduct", Moneyproduct);
                printTimekeeping1.SetParameterValue("pMoneyTime", Moneytime);
                Pay = _list.Sum(u => u.TotalWeight) * Moneyproduct + _list.Sum(u => u.Time) * Moneytime + _list.Sum(u => u.Bunus)
                      - _list.Sum(u => u.Punish) - listTT.Sum(u => u.Food) - listTT.Sum(u => u.AdvancePayment) - Debt;
                printTimekeeping1.SetParameterValue("pWage", Pay);
                crystalReportViewer.ReportSource = printTimekeeping1;
            }

            catch { }
        }