public void saveAccountReport(string outfile, int year, int month)
        {
            int lines = 0;

            TB_User[] sales = UserBusiness.getAllSalersAndWrite();
            if (sales != null)
            {
                AccountSheet.Cells[2, 4].PutValue(year.ToString() + "年" + month + "月度");
                string   str       = year.ToString() + "-" + month.ToString() + "-01";
                DateTime startdate = DateTime.Parse(str);
                DateTime enddate   = DateTime.Parse(str).AddMonths(1).AddSeconds(-1);
                for (int i = 0; i < sales.Length; i++)
                {
                    lines = lines + 1;
                    decimal totalScore = ScoreBusiness.AccountSummaryReport(startdate, enddate, sales[i].Id, startdate.Month, startdate.Year);
                    writeAccountReport(sales[i], year, month, i, totalScore);
                }
                try
                {
                    AccountSheet.Cells[1, 0].Style = AccountSheet.Cells[1, 1].Style;
                    AccountSheet.Cells[ACCOUNTDATA_STARTLINE_INDEX + lines + 2, 4].PutValue("合计:");
                    AccountSheet.Cells[ACCOUNTDATA_STARTLINE_INDEX + lines + 2, 4].PutValue(Math.Round(Total, 2));
                    book.Password = DES.Decode(Global.g_password, Global.DB_PWDKEY);
                    book.Save(outfile);
                    MessageHelper.ShowMessage("I007");
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);
                    MessageHelper.ShowMessage("E999", "财务清单导出失败。");
                }
            }
        }
Beispiel #2
0
        public void saveReport(string savePath, int year, int month)
        {
            Workbook wk = new Workbook();

            TB_User[] sales = UserBusiness.getAllSalersAndWrite();  //获取所有销售渠道和完工录入信息
            if (Global.g_usergroupid != (int)EnmUserRole.财务 && Global.g_usergroupid != (int)EnmUserRole.全部 && Global.g_usergroupid != (int)EnmUserRole.销售总监)
            {
                TB_User        u    = UserBusiness.findUserById(Global.g_userid);
                List <TB_User> list = new List <TB_User>();
                list.Add(u);
                sales = list.ToArray();
            }
            string   str       = year.ToString() + "-" + month.ToString() + "-01";
            DateTime startdate = DateTime.Parse(str).Date;
            DateTime enddate   = DateTime.Parse(str).AddMonths(1).AddDays(-1).Date;

            for (int i = 0; i < sales.Length; i++)
            {
                DataTable salesData = ScoreBusiness.makeActualScore(startdate, enddate, "", sales[i].Id, "");
                if (salesData.Rows.Count > 0)
                {
                    writeSalesReport(wk, i, salesData, year, month, sales[i].USER_NAME);
                    try
                    {
                        wk.Password = DES.Decode(sales[i].PASSWORD, Global.DB_PWDKEY);
                        wk.Save(savePath + "//" + sales[i].USER_NAME + " " + year + "-" + month + "月度提成清单1.xls");
                    }
                    catch (Exception ex)
                    {
                        MessageHelper.ShowMessage("E999", "错误" + ex.Message + "\n此文件导出失败,其他文件仍将被导出到所选目录。");
                    }
                }
            }
            MessageHelper.ShowMessage("I007");
        }
Beispiel #3
0
        /// <summary>
        /// Méthode à éxécuter pour initialiser le controleur
        /// </summary>
        /// <returns></returns>
        private async Task InitializeAsync()
        {
            _scoreBusiness = new ScoreBusiness();
            await _scoreBusiness.Initialization;

            _utilisateurBusiness = new UtilisateurBusiness();
            await _utilisateurBusiness.Initialization;

            TempsPasse = 0;
        }
Beispiel #4
0
        /// <summary>
        /// Charge les stats à afficher
        /// </summary>
        public async Task ChargerResultats(Resultats resultats)
        {
            _isEval = false;
            if (_scoreBusiness == null)
            {
                _scoreBusiness = new ScoreBusiness();
                await _scoreBusiness.Initialization;
            }
            _exercice = resultats.Exercice;

            //pense à retrouvé le résultat tout juste ajouter, et à vérifier le nouveau record

            //partie résultats
            var listePerso = await _scoreBusiness.GetListeTopScorePerso(resultats.Exercice.Id, ContextAppli.ContextUtilisateur.EnCoursUser.Id);

            if (listePerso.Count >= 1)
            {
                RecordPerso1.Text = listePerso[0].Resultat.ToString();
            }
            if (listePerso.Count >= 2)
            {
                RecordPerso2.Text = listePerso[1].Resultat.ToString();
            }

            if (listePerso.Count >= 3)
            {
                RecordPerso3.Text = listePerso[2].Resultat.ToString();
            }
            var listeGlobal = await _scoreBusiness.GetListeTopScoreGlobal(resultats.Exercice.Id);

            if (listeGlobal.Count >= 1)
            {
                RecordGlob1.Text = listeGlobal[0].Resultat + " - " + await _scoreBusiness.GetNomUtilisateur(listeGlobal[0].IdUtilisateur);
            }

            if (listeGlobal.Count >= 2)
            {
                RecordGlob2.Text = listeGlobal[1].Resultat + " - " + await _scoreBusiness.GetNomUtilisateur(listeGlobal[1].IdUtilisateur);
            }

            if (listeGlobal.Count >= 3)
            {
                RecordGlob3.Text = listeGlobal[2].Resultat + " - " + await _scoreBusiness.GetNomUtilisateur(listeGlobal[2].IdUtilisateur);
            }

            ScoreTextBlock.Text  = resultats.ScoreExercice.Resultat + " / 100";
            TempsTextBlock.Text  = DateUtils.ConvertNbMilisecondesString(resultats.ScoreExercice.NbSecondes);
            ErreurTextBlock.Text = resultats.Erreurs.ToString();
            if (listePerso[0].Equals(resultats.ScoreExercice) || listeGlobal[0].Equals(resultats.ScoreExercice))
            {
                NewRecordText.Visibility = Visibility.Visible;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Calcul une moyenne du score de l'évaluation et la sauvegarde en base
        /// </summary>
        /// <returns>le résultat moyen de l'évaluation</returns>
        public async Task <Resultats> GetResultats()
        {
            //préparation des objets et calcul du résultat final
            var resultatFinal = new Resultats
            {
                Erreurs       = 0,
                Exercice      = null,
                ScoreExercice = null
            };

            var scoreFinal = new Score
            {
                IdExercice    = 0,
                IdUtilisateur = ContextAppli.ContextUtilisateur.EnCoursUser.Id,
                NbSecondes    = 0,
                Resultat      = 0
            };

            var pointTot = 0;

            foreach (var results in _listeResultat)
            {
                resultatFinal.Erreurs += results.Erreurs;
                scoreFinal.NbSecondes += results.ScoreExercice.NbSecondes;
                pointTot += results.ScoreExercice.Resultat;
            }
            scoreFinal.Resultat         = pointTot / NbMiniJeu;
            resultatFinal.ScoreExercice = scoreFinal;

            //sauvegarde en base
            if (_scoreBusiness == null)
            {
                _scoreBusiness = new ScoreBusiness();
                await _scoreBusiness.Initialization;
            }
            await _scoreBusiness.SaveScore(scoreFinal.IdExercice, scoreFinal.Resultat, scoreFinal.NbSecondes);

            return(resultatFinal);
        }
Beispiel #6
0
        public DataTable saveExcel(int StartYear, int EndYear, int StartMonth, int EndMonth, int salerId, string salerName, string savePath)
        {
            try
            {
                string   tmpstartDate = StartYear.ToString() + "-" + StartMonth.ToString() + "-01";
                DateTime startDate    = DateTime.Parse(tmpstartDate);
                string   tmpendDate   = EndYear.ToString() + "-" + EndMonth.ToString() + "-01";
                DateTime endDate      = DateTime.Parse(tmpendDate).AddMonths(1).AddDays(-1); //查询结束月最后一天

                DataTable salesTrendcy = ScoreBusiness.makeActualScore(startDate, endDate, "", salerId, "");
                DataTable tb           = createCol();
                for (DateTime date = startDate; date < endDate; date = date.AddMonths(1))
                {
                    int     tmpyear   = date.Year;
                    int     tmpmonth  = date.Month;
                    decimal amount    = 0;
                    string  yearmonth = tmpyear.ToString() + "年" + tmpmonth + "月";

                    DataRow[] rows = salesTrendcy.Select("年度=" + tmpyear + " and 月度=" + tmpmonth + "");
                    for (int i = 0; i < rows.Length; i++)
                    {
                        amount += Utils.NvDecimal(rows[i]["应收月租费"]);
                    }
                    DataRow r = tb.NewRow();
                    r["yearmonth"] = yearmonth;
                    r["amount"]    = amount;
                    tb.Rows.Add(r);
                }
                return(tb);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                return(new DataTable());

                MessageHelper.ShowMessage("E999", "销售业绩走势导出失败。");
            }
        }
Beispiel #7
0
 /// <summary>
 /// Méthode d'initialisation
 /// </summary>
 /// <returns>la task</returns>
 public override async Task InitializeAsync()
 {
     _scoreBusiness = new ScoreBusiness();
     await _scoreBusiness.Initialization;
 }
Beispiel #8
0
        public void exportProfitReport(string outfile, int year, int month, float ptax)
        {
            try
            {
                int        line          = 0;
                decimal    totalreceive  = 0;
                decimal    totalcost     = 0;
                decimal    totalprofit   = 0;
                decimal    totalafterTax = 0;
                float      tax           = float.Parse(ptax.ToString()) / 100; //税率
                string     str           = year.ToString() + "-" + month.ToString() + "-01";
                DateTime   startdate     = DateTime.Parse(str);
                DateTime   enddate       = DateTime.Parse(str).AddMonths(1).AddDays(-1).Date;
                Customer[] customers     = CustomerBusiness.getAllCustomers();
                if (customers.Length > 0)
                {
                    for (int i = 0; i < customers.Length; i++)
                    {
                        //string condition = " and b.year=" + year + " and b.month=" + month + " and cu.customername='" + customers[i].Customername + "'";
                        DataTable tb       = ScoreBusiness.makeActualScore(startdate, enddate, "", 0, customers[i].Customername); //.getActual(condition, enddate);
                        decimal   tmptotal = 0;                                                                                   //电路金额合计
                        decimal   profit   = 0;
                        if (tb.Rows.Count > 0)
                        {
                            for (int j = 0; j < tb.Rows.Count; j++)
                            {
                                tmptotal += Utils.NvDecimal(tb.Rows[j]["提成金额"].ToString()); //渠道提成金额
                            }
                        }
                        else
                        {
                            continue;
                        }
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 1].PutValue(customers[i].Customername);
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 1].Style.Copy(cellstyle);
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 2].PutValue(tb.Rows[0]["电路代码"].ToString());
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 2].Style.Copy(cellstyle);
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 3].PutValue(DateTime.Parse(tb.Rows[0]["结算起始日期"].ToString()).ToString("yyyy-MM-dd"));
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 3].Style.Copy(cellstyle);
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 4].PutValue(DateTime.Parse(tb.Rows[0]["结算截止日期"].ToString()).ToString("yyyy-MM-dd"));
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 4].Style.Copy(cellstyle);
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 5].PutValue(Utils.NvDecimal(tb.Rows[0]["销账金额"].ToString()));
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 5].Style.Copy(cellstyle);
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 6].PutValue(Utils.NvDecimal(tb.Rows[0]["代理费"].ToString()));
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 6].Style.Copy(cellstyle);
                        totalreceive += Utils.NvDecimal(tb.Rows[0]["代理费"].ToString());
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 7].PutValue(ptax + "%");
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 7].Style.Copy(cellstyle);
                        decimal afterTaxAmoun = Utils.NvDecimal(tb.Rows[0]["代理费"].ToString()) * (1 - Utils.NvDecimal(ptax) / 100);
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 8].PutValue(Math.Round(afterTaxAmoun, 2));
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 8].Style.Copy(this.cellstyle);
                        totalafterTax += afterTaxAmoun;
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 9].PutValue(Math.Round(tmptotal, 2));
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 9].Style.Copy(this.cellstyle);
                        totalcost += tmptotal;
                        profit     = afterTaxAmoun - tmptotal;
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 10].PutValue(Math.Round(profit, 2));
                        profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line, 10].Style.Copy(this.cellstyle);
                        totalprofit = totalprofit + profit;
                        line++;
                    }
                    profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line + 2, 1].PutValue("合计:");

                    profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line + 2, 6].PutValue(Math.Round(totalreceive, 2));
                    profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line + 2, 8].PutValue(Math.Round(totalafterTax, 2));
                    profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line + 2, 9].PutValue(Math.Round(totalcost, 2));
                    profitSheet.Cells[PROFITDATA_STARTLINE_INDEX + line + 2, 10].PutValue(Math.Round(totalprofit, 2));
                    profitSheet.Cells[1, 0].Style = profitSheet.Cells[1, 1].Style;

                    book.Password = DES.Decode(Global.g_password, Global.DB_PWDKEY);
                    book.Save(outfile);
                    MessageHelper.ShowMessage("I007");
                }
                else
                {
                    MessageHelper.ShowMessage("I014");
                }
            }

            catch (Exception ex)
            {
                Log.Error(ex.Message);
                MessageHelper.ShowMessage("I008");
            }
        }
Beispiel #9
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (!GlobalBusiness.isConnServer())
            {
                MessageHelper.ShowMessage("E034");
                return;
            }
            resultGrid.Rows.Clear();
            Hashtable hs = new Hashtable();

            //查询条件

            if (!string.IsNullOrEmpty(txtCusName.Text.Trim()))
            {
                hs.Add("客户", txtCusName.Text.Trim());
            }
            DateTime Start = completeStart.Value.Date; //完工起始日期
            DateTime End   = completeEnd.Value.Date;   //完工结束日期

            if (chkIsEnable.Checked)
            {
                if (Start.CompareTo(End) > 1)
                {
                    MessageHelper.ShowMessage("W010");
                    return;
                }
                hs.Add("完工起始", Start);
                hs.Add("完工截止", End);
            }
            if (cmbStatus.SelectedIndex < 3)
            {
                hs.Add("结算方式", cmbStatus.SelectedIndex);
            }
            int imYearstart  = Utils.NvInt(numStartYear.Value); //导入起始年度
            int imMonthstart = Utils.NvInt(numStartMonth.Value);
            int imYearend    = Utils.NvInt(numEndYear.Value);
            int imMonthend   = Utils.NvInt(numEndMonth.Value);

            if (imYearstart > imYearend)
            {
                MessageHelper.ShowMessage("E022");
                return;
            }
            else if (imYearstart == imYearend)
            {
                if (imMonthstart > imMonthend)
                {
                    MessageHelper.ShowMessage("E022");
                    return;
                }
            }
            hs.Add("导入起始年度", imYearstart);
            hs.Add("导入起始月度", imMonthstart);
            hs.Add("导入截止年度", imYearend);
            hs.Add("导入截止月度", imMonthend);
            if (hs.Count > 0)
            {
                DataTable tb = ScoreBusiness.getScoreByCondition(hs);
                if (tb != null)
                {
                    if (tb.Rows.Count > 0)
                    {
                        for (int i = 0; i < tb.Rows.Count; i++)
                        {
                            resultGrid.Rows.Add();
                            resultGrid.Rows[i].Cells["No"].Value           = i + 1;
                            resultGrid.Rows[i].Cells["customer"].Value     = Utils.NvStr(tb.Rows[i]["客户名称"].ToString());
                            resultGrid.Rows[i].Cells["cablenumber"].Value  = Utils.NvStr(tb.Rows[i]["电路代码"].ToString());
                            resultGrid.Rows[i].Cells["saler"].Value        = Utils.NvStr(tb.Rows[i]["主销售渠道"].ToString());
                            resultGrid.Rows[i].Cells["complete"].Value     = DateTime.Parse(tb.Rows[i]["完工日期"].ToString());
                            resultGrid.Rows[i].Cells["startdate"].Value    = DateTime.Parse(tb.Rows[i]["结算起始日期"].ToString()).ToString("yyyy-MM-dd");
                            resultGrid.Rows[i].Cells["enddate"].Value      = DateTime.Parse(tb.Rows[i]["结算截止日期"].ToString()).ToString("yyyy-MM-dd");
                            resultGrid.Rows[i].Cells["money"].Value        = Utils.NvStr(tb.Rows[i]["合同金额"].ToString());
                            resultGrid.Rows[i].Cells["paytype"].Value      = Utils.NvStr(tb.Rows[i]["付款类型"].ToString());
                            resultGrid.Rows[i].Cells["receivable"].Value   = Utils.NvStr(tb.Rows[i]["销账金额"].ToString());
                            resultGrid.Rows[i].Cells["inputdata"].Value    = Utils.NvStr(tb.Rows[i]["年度"].ToString()) + "-" + Utils.NvStr(tb.Rows[i]["月度"].ToString());
                            resultGrid.Rows[i].Cells["remove"].Value       = Utils.NvStr(tb.Rows[i]["拆机日期"].ToString());
                            resultGrid.Rows[i].Cells["contractType"].Value = Utils.NvStr(tb.Rows[i]["电路类型"].ToString());
                        }
                    }
                    else
                    {
                        MessageHelper.ShowMessage("I005");
                    }
                }
            }
        }