Пример #1
0
        private void ImportPayFile()
        {
            OpenFileDialog OpenFileDialog = new OpenFileDialog();
            OpenFileDialog.Multiselect = false;
            OpenFileDialog.Filter = "Excel Files (*.xls)|*.xls;";
            NumericUpDown nuYear = Utility.FindChildControl<NumericUpDown>(expander, "years");
            NumericUpDown nuStartmounth = Utility.FindChildControl<NumericUpDown>(expander, "months");
            if (string.IsNullOrEmpty(_txtBox.Text))
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("ERROR", "发放标记不能为空"),
Utility.GetResourceStr("CONFIRM"), MessageIcon.Error);
                //Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("ERROR"), "发放标记不能为空"); //第四,五列发放标记不能为空
                return;
            }
            if (OpenFileDialog.ShowDialog() != true)
            {
                return;
            }

            if (OpenFileDialog.File == null)
                return;
            try
            {
                Stream Stream = (System.IO.Stream)OpenFileDialog.File.OpenRead();
                byte[] Buffer = new byte[Stream.Length];
                Stream.Read(Buffer, 0, (int)Stream.Length);

                Stream.Dispose();
                Stream.Close();

                SMT.Saas.Tools.SalaryWS.UploadFileModel UploadFile = new SMT.Saas.Tools.SalaryWS.UploadFileModel();
                UploadFile.FileName = OpenFileDialog.File.Name;
                UploadFile.File = Buffer;
                client.ImportExcelAsync(UploadFile,nuYear.Value.ToString(),nuStartmounth.Value.ToString(),_txtBox.Text.Trim());
            }
            catch (Exception ex)
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("ERROR"),
Utility.GetResourceStr("CONFIRM"), MessageIcon.Error);
                //Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("ERROR"), ex.Message.ToString());
            }

        }
Пример #2
0
        /// <summary>
        ///  读取员工加扣款卡的Excel文件,并导入数据库,返回导入后的结果
        /// </summary>
        private void ImportEmployeeAddSum()
        {

            string strMsg = string.Empty;
            try
            {
                //if (cbxCity.SelectedItem == null)
                //{
                //    //Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("STRINGNOTNULL", "CITY"));
                //    ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("CAUTION"), Utility.GetResourceStr("STRINGNOTNULL", "CITY"),
                //Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
                //    return;
                //}
                if (string.IsNullOrEmpty(tbFileName.Text))
                {
                    //Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("IMPORTSELECT"));
                    ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("CAUTION"), Utility.GetResourceStr("IMPORTSELECT"),
                Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
                    return;
                }
                if (OpenFileDialog == null)
                    return;

                if (OpenFileDialog.File == null)
                    return;

                RefreshUI(RefreshedTypes.ShowProgressBar);

                Stream Stream = (System.IO.Stream)OpenFileDialog.File.OpenRead();

                byte[] Buffer = new byte[Stream.Length];
                Stream.Read(Buffer, 0, (int)Stream.Length);

                Stream.Dispose();
                Stream.Close();

                SMT.Saas.Tools.SalaryWS.UploadFileModel UploadFile = new SMT.Saas.Tools.SalaryWS.UploadFileModel();
                UploadFile.FileName = OpenFileDialog.File.Name;
                UploadFile.File = Buffer;

                strMsg = string.Empty;
                Dictionary<string, string> paras = new Dictionary<string, string>();
                //paras.Add("CITY", (cbxCity.SelectedItem as T_SYS_DICTIONARY).DICTIONARYVALUE.ToString());
                paras.Add("OWNERID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID);
                paras.Add("CREATEUSERID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID);
                paras.Add("CREATECOMPANYID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID);
                paras.Add("CREATEDEPARTMENTID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID);
                paras.Add("CREATEPOSTID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID);
                paras.Add("YEAR", (Nuyear.Value).ToString());
                paras.Add("MONTH", (NuStartmounth.Value).ToString());
                salaryClient.ImportEmployeeAddSumFromExcelForShowAsync(UploadFile, paras, strMsg, true);
                //client.ImportClockInRdListFromExcelAsync(UploadFile, paras, strMsg);
                //client.ImportClockInRdListFromExcelAsync(UploadFile, SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID, strMsg);
                //clientAtt.ImportClockInRdListFromExcelAsync(UploadFile, dtStart, dtEnd, strMsg);
            }
            catch (Exception ex)
            {
                //Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr(ex.Message.ToString()));
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("ERRORINFO"), Utility.GetResourceStr("CONFIRM"), MessageIcon.Error);
                RefreshUI(RefreshedTypes.HideProgressBar);
            }
        }
Пример #3
0
        private void ImportPayFile()
        {
            OpenFileDialog OpenFileDialog = new OpenFileDialog();
            OpenFileDialog.Multiselect = false;
            OpenFileDialog.Filter = "Excel Files (*.xls)|*.xls;";

            if (OpenFileDialog.ShowDialog() != true)
            {
                return;
            }

            if (OpenFileDialog.File == null)
                return;
            try
            {
                Stream Stream = (System.IO.Stream)OpenFileDialog.File.OpenRead();
                byte[] Buffer = new byte[Stream.Length];
                Stream.Read(Buffer, 0, (int)Stream.Length);

                Stream.Dispose();
                Stream.Close();

                SMT.Saas.Tools.SalaryWS.UploadFileModel UploadFile = new SMT.Saas.Tools.SalaryWS.UploadFileModel();
                UploadFile.FileName = OpenFileDialog.File.Name;
                UploadFile.File = Buffer;
                //client.ImportExcelAsync(UploadFile);
            }
            catch (Exception ex)
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("CONFIRM"), MessageIcon.Error);
                //Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("ERROR"), ex.Message.ToString());
            }

        }
Пример #4
0
        /// <summary>
        ///  读取员工加扣款卡的Excel文件,并导入数据库,返回导入后的结果
        /// </summary>
        private void ImportEmployeeAddSum()
        {
            string strMsg = string.Empty;

            try
            {
                //if (cbxCity.SelectedItem == null)
                //{
                //    //Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("STRINGNOTNULL", "CITY"));
                //    ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("CAUTION"), Utility.GetResourceStr("STRINGNOTNULL", "CITY"),
                //Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
                //    return;
                //}
                if (string.IsNullOrEmpty(tbFileName.Text))
                {
                    //Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("IMPORTSELECT"));
                    ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("CAUTION"), Utility.GetResourceStr("IMPORTSELECT"),
                                                   Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
                    return;
                }
                if (OpenFileDialog == null)
                {
                    return;
                }

                if (OpenFileDialog.File == null)
                {
                    return;
                }

                RefreshUI(RefreshedTypes.ShowProgressBar);

                Stream Stream = (System.IO.Stream)OpenFileDialog.File.OpenRead();

                byte[] Buffer = new byte[Stream.Length];
                Stream.Read(Buffer, 0, (int)Stream.Length);

                Stream.Dispose();
                Stream.Close();

                SMT.Saas.Tools.SalaryWS.UploadFileModel UploadFile = new SMT.Saas.Tools.SalaryWS.UploadFileModel();
                UploadFile.FileName = OpenFileDialog.File.Name;
                UploadFile.File     = Buffer;

                strMsg = string.Empty;
                Dictionary <string, string> paras = new Dictionary <string, string>();
                //paras.Add("CITY", (cbxCity.SelectedItem as T_SYS_DICTIONARY).DICTIONARYVALUE.ToString());
                paras.Add("OWNERID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID);
                paras.Add("CREATEUSERID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID);
                paras.Add("CREATECOMPANYID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID);
                paras.Add("CREATEDEPARTMENTID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID);
                paras.Add("CREATEPOSTID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID);
                paras.Add("YEAR", (Nuyear.Value).ToString());
                paras.Add("MONTH", (NuStartmounth.Value).ToString());
                salaryClient.ImportEmployeeAddSumFromExcelForShowAsync(UploadFile, paras, strMsg, true);
                //client.ImportClockInRdListFromExcelAsync(UploadFile, paras, strMsg);
                //client.ImportClockInRdListFromExcelAsync(UploadFile, SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID, strMsg);
                //clientAtt.ImportClockInRdListFromExcelAsync(UploadFile, dtStart, dtEnd, strMsg);
            }
            catch (Exception ex)
            {
                //Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr(ex.Message.ToString()));
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("ERRORINFO"), Utility.GetResourceStr("CONFIRM"), MessageIcon.Error);
                RefreshUI(RefreshedTypes.HideProgressBar);
            }
        }