예제 #1
0
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            ispaging           = false;
            dialog.Filter      = "MS csv Files|*.csv";
            dialog.FilterIndex = 1;
            result             = dialog.ShowDialog();
            loadbar.Start();
            int    pageCount = 0;
            string filter    = "";

            System.Collections.ObjectModel.ObservableCollection <object> paras = new System.Collections.ObjectModel.ObservableCollection <object>();

            string month = months.Value.ToString();
            string year  = years.Value.ToString();

            if (!string.IsNullOrEmpty(year))
            {
                filter = " salaryyear==@" + paras.Count.ToString();
                paras.Add(year);
            }

            if (!string.IsNullOrEmpty(month))
            {
                if (!string.IsNullOrEmpty(filter))
                {
                    filter += " and ";
                }
                filter += " salarymonth==@" + paras.Count.ToString();
                paras.Add(month);
            }
            salaryClient.ExportSalarySummaryAsync(dataPager.PageIndex, dataPager.PageSize, "EMPLOYEENAME",
                                                  filter, paras, pageCount, SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID, year, month, false);
        }
예제 #2
0
        /// <summary>
        /// 导出所有数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            ispaging           = false;
            dialog.Filter      = "MS csv Files|*.csv";
            dialog.FilterIndex = 1;
            result             = dialog.ShowDialog();
            loadbar.Start();
            string filter = "";

            System.Collections.ObjectModel.ObservableCollection <object> paras = new System.Collections.ObjectModel.ObservableCollection <object>();


            int    year         = Convert.ToInt32(this.years.Value);
            int    month        = Convert.ToInt32(this.months.Value);
            string employeeName = this.txtName.Text;
            int    endYear      = Convert.ToInt32(this.endyears.Value);
            int    endMonth     = Convert.ToInt32(this.endmonths.Value);

            DateTime startDate = DateTime.Parse(year + "-" + month);
            DateTime endDate   = DateTime.Parse(endYear + "-" + endMonth);

            if (startDate > endDate)
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("CAUTION"), Utility.GetResourceStr("结束时间要大于开始时间"), Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
                return;
            }
            for (int j = year; j <= endYear; j++)
            {
                int tempMonth = endMonth;//如果跨年查询,则最大为12月
                if (j != endYear)
                {
                    tempMonth = 12;
                }
                for (int i = month; i <= tempMonth; i++)
                {
                    if (!string.IsNullOrEmpty(filter))
                    {
                        filter += " or ";//&&操作优先级大于||,不用括号
                    }
                    else
                    {
                        filter += " ( ";//括号包含薪资年月
                    }
                    filter += " salaryyear==@" + paras.Count.ToString();
                    paras.Add(j.ToString());

                    if (!string.IsNullOrEmpty(filter))
                    {
                        filter += " and ";
                    }
                    filter += " salarymonth==@" + paras.Count.ToString();
                    paras.Add(i.ToString());
                }
            }
            filter += " ) ";                         //括号包含薪资年月
            if (!string.IsNullOrEmpty(employeeName)) //员工姓名
            {
                if (!string.IsNullOrEmpty(filter))
                {
                    filter += " and ";
                }
                filter += " EmployeeName==@" + paras.Count.ToString();
                paras.Add(employeeName);
            }

            int pageIndex = 0, pageSize = 0, pageCount = 0;

            pageIndex = 1;
            pageSize  = 1000000;//导出所有
            salaryClient.ExportSalarySummaryAsync(pageIndex, pageSize, "EMPLOYEENAME",
                                                  filter, paras, pageCount, SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID, year.ToString(), month.ToString(), false);
            loadbar.Start();
        }