Exemplo n.º 1
0
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            // ispaging = false;

            dialog.DefaultExt = ".xls";
            dialog.Filter     = "MS Excel Files|*.xls";

            dialog.FilterIndex = 1;

            result = dialog.ShowDialog();
            if (result.Value == true)
            {
                string filter = "";
                System.Collections.ObjectModel.ObservableCollection <object> paras = new System.Collections.ObjectModel.ObservableCollection <object>();

                if (StrCompanyIDsList.Count() > 0)
                {
                    StrCompanyIDsList.ForEach(item =>
                    {
                        if (!string.IsNullOrEmpty(filter))
                        {
                            filter += " or ";
                            filter += " OWNERCOMPANYID==@" + paras.Count().ToString();
                            paras.Add(item);
                        }
                        else
                        {
                            filter += " OWNERCOMPANYID==@" + paras.Count().ToString();
                            paras.Add(item);
                        }
                    });
                }
                DateTime dtLandStart = new DateTime();
                DateTime dtLandEnd   = new DateTime();

                DateTime.TryParse(nuYear.Value.ToString() + "-" + nuMonth.Value.ToString() + "-1", out dtLandStart);
                DateTime.TryParse(nuYear.Value.ToString() + "-" + nuMonth.Value.ToString() + "-1", out dtLandEnd);
                dtLandEnd = dtLandEnd.AddMonths(1);


                //if (string.IsNullOrEmpty(filter))
                //{
                //    filter += " CREATEDATE >= @" + paras.Count().ToString();
                //    paras.Add(dtLandStart);
                //}
                //else
                //{
                //    filter += " and CREATEDATE >= @" + paras.Count().ToString();
                //    paras.Add(dtLandStart);
                //}

                //filter += " and CREATEDATE < @" + paras.Count().ToString();
                //paras.Add(dtLandEnd);


                loadbar.Start();
                switch (ReportsType)
                {
                case "1":
                    break;

                case "2":
                    personClient.ExportEmployeeTructReportsAsync(StrCompanyIDsList, "CREATEDATE", filter, paras, SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID, sValue, dtLandStart, dtLandEnd);
                    break;

                case "3":
                    personClient.ExportEmployeeCollectsReportsAsync("", filter, paras, SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID, sValue, dtLandStart, dtLandEnd);
                    break;

                case "4":
                    sValue = StrCompanyIDsList.FirstOrDefault();
                    client.ExportEmployeePensionReportsAsync("COMPANYNAME", filter, paras, SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID, sValue, dtLandStart);
                    break;

                default:
                    //personClient.GetEmployeeBasicInfosByCompanyAsync(dataPager.PageIndex, dataPager.PageSize, "POSTNAME", filter, paras, pageCount, SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID, sType, sValue);
                    //personClient.ExportEmployeeBasicInfosByCompanyReportsAsync(StrCompanyIDsList, "CREATEDATE",filter, paras,  SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID, sType);
                    if (ListInfos != null)
                    {
                        personClient.ExportEmployeeBasicInfosNoGetReportsAsync(ListInfos, dtLandStart, StrCompanyIDsList);
                    }
                    else
                    {
                        //personClient.ExportEmployeeBasicInfosByCompanyReportsAsync(
                    }
                    break;
                }

                //personClient.ExportEmployeesIntimeAsync(dataPager.PageIndex, dataPager.PageSize, "DepartmentName",
                //    filter, paras, pageCount, sType, sValue, SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID);
            }
        }