static void Main(string[] args)
        {
            Console.WriteLine("Enter The Number OF Bank To SetUp : ");
            int num = Int32.Parse(Console.ReadLine());

            Bank[] bankArray = new Bank[num];
            for (int i = 0; i < num; i++)
            {
                Console.WriteLine("Enter " + _8th(i + 1) + " Bank Name : ");
                string name = Console.ReadLine().ToUpper();
                bankArray[i] = new Bank(name);
            }
            while (true)
            {
                Console.WriteLine("There Are Following Bank That Exists : ");
                for (int i = 0; i < num; i++)
                {
                    Console.WriteLine(_8th(i + 1) + " Bank : " + bankArray[i].name);
                }
                Console.WriteLine("Please Enter Bank Name You Are Associated With : ");
                string name     = Console.ReadLine().ToUpper();
                Bank   userBank = null;
                for (int i = 0; i < num; i++)
                {
                    if (name.Equals(bankArray[i].name))
                    {
                        userBank = bankArray[i];
                        break;
                    }
                }
                if (userBank == null)
                {
                    Console.WriteLine("Please, Enter A Valid Bank Name . . .");
                    continue;
                }
                //Enter In A Bank
                while (true)
                {
                    Console.WriteLine("<<< Welcome, To " + userBank.name + " Bank >>>");
                    Console.WriteLine("1. Staff\n2. Customer\nEnter(1/2) : ");
                    char choice = Console.ReadLine()[0];
                    if (choice == '1')
                    {
                        Console.WriteLine("Hello Staff, Enter Your User Id ");
                        string stfId = Console.ReadLine();
                        Console.WriteLine("Enter Your LogIn Password ");
                        string pword = Console.ReadLine();
                        Staff  staff = (new BankService()).StaffExistsOrNot(userBank, stfId, pword);
                        if (staff == null)
                        {
                            Console.WriteLine("Please Enter Valid Credentials . . .");
                            continue;
                        }
                        bool staffWish = true;
                        while (staffWish)
                        {
                            Console.WriteLine("1.Add Account\n2.DeleteAccount\n3.Update Account\n4.ChangeCurrency\n5.ChangeServiceCharge\n6.View Transaction History\n7.Revert A Transaction\nE. Exit\nYour Choice . . . ");
                            char options = Console.ReadLine()[0];
                            switch (options)
                            {
                            case '1':
                                Console.WriteLine("Enter Customer Name : ");
                                string ename = Console.ReadLine();
                                Console.WriteLine("Enter Password : "******"The User Id is : " + customer.UserId);
                                    Console.WriteLine("The Account Id Is : " + customer.GetAccount().AccountId);
                                }
                                else
                                {
                                    Console.WriteLine("Account Already Exists . . .");
                                }
                                break;

                            case '2':
                                Console.WriteLine("Enter Account Id To Delete ->> ");
                                string accId     = Console.ReadLine();
                                bool   doneOrNot = (new StaffService().DeleteAccount(userBank, accId));
                                if (doneOrNot)
                                {
                                    Console.WriteLine("Account Successfully Deleted");
                                }
                                else
                                {
                                    Console.WriteLine("Account Do Not Exists");
                                }
                                break;

                            case '3':
                                Console.WriteLine("Enter The UserId To Update : ");
                                string UserId = Console.ReadLine();
                                Console.WriteLine("Enter The New Password : "******"<<<-- Password Updated -->>>");
                                }
                                else
                                {
                                    Console.WriteLine("No Such User Exists");
                                }
                                break;

                            case '4':
                                Console.WriteLine("Enter New Currency Name : ");
                                string currencyName = Console.ReadLine();
                                Console.WriteLine("Enter Rate : ");
                                float rate = float.Parse(Console.ReadLine());
                                new StaffService().ChangeCurrency(userBank, currencyName, rate);
                                break;

                            case '5':
                                Console.WriteLine("Enter IMPS and RTGS Rate : ");
                                int IMPS = Int32.Parse(Console.ReadLine());
                                int RTGS = Int32.Parse(Console.ReadLine());
                                Console.WriteLine("Enter Foreign IMPS and RTGS Rate : ");
                                int fIMPS = Int32.Parse(Console.ReadLine());
                                int fRTGS = Int32.Parse(Console.ReadLine());
                                new StaffService().ChangeRates(userBank, IMPS, RTGS, fIMPS, fRTGS);
                                break;

                            case '6':
                            {
                                Console.WriteLine("Enter Account Id For Which Trnsaction History To Look Up -->> ");
                                string AccountId      = Console.ReadLine();
                                bool   recieverExists = false;
                                for (int i = 0; i < bankArray.Length; i++)
                                {
                                    if ((new BankService().CustomerExistsOrNotByAccId(bankArray[i], AccountId)) != null)
                                    {
                                        recieverExists = true;
                                        break;
                                    }
                                }
                                if (!recieverExists)
                                {
                                    Console.WriteLine("Account Do Not Exists . . .");
                                }
                                else
                                {
                                    List <Transaction> transactions = new StaffService().ViewTransactionHistory(userBank, AccountId);
                                    if (transactions == null)
                                    {
                                        Console.WriteLine("No Transaction Exists . . .");
                                        break;
                                    }
                                    Console.WriteLine("There Are Following Transactions : ");
                                    for (int i = 0; i < transactions.Count; i++)
                                    {
                                        Console.WriteLine(transactions[i].ToString());
                                    }
                                }
                            }
                            break;

                            case '7':
                            {
                                Console.WriteLine("Enter Account Id For Which Trnsaction History To Look Up -->> ");
                                string AccountId = Console.ReadLine();
                                if (new BankService().CustomerExistsOrNotByAccId(userBank, AccountId) == null)
                                {
                                    Console.WriteLine("No Such Account Exists In This Bank ! ! !");
                                    break;
                                }
                                List <Transaction> transactions = new StaffService().ViewTransactionHistory(userBank, AccountId);
                                if (transactions == null)
                                {
                                    Console.WriteLine("No Transaction Exists . . .");
                                    break;
                                }
                                for (int i = 0; i < transactions.Count; i++)
                                {
                                    Console.WriteLine(transactions[i].ToString());
                                }
                                int  tchoice = 0;
                                bool eflag   = false;
                                while (true)
                                {
                                    try
                                    {
                                        Console.WriteLine("Enter Your Choice = ");
                                        tchoice = Int32.Parse(Console.ReadLine());
                                        if (tchoice > transactions.Count)
                                        {
                                            Console.WriteLine(">>-- Enter A Valid Choice --<<");
                                            continue;
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Console.WriteLine("Aborting Reverting A Transaction. . .");
                                        eflag = true;
                                        break;
                                    }
                                }
                                if (eflag)
                                {
                                    continue;
                                }
                                Transaction tType = transactions[tchoice - 1];
                                if ((tType is Deposit) || (tType is WithDraw))
                                {
                                    if (!tType.alive)
                                    {
                                        Console.WriteLine("Cannot Revert, Aborting Reverting !!!");
                                        break;
                                    }
                                    bool IsReverted = new StaffService().RevertATransaction(userBank, tType);
                                    if (IsReverted)
                                    {
                                        Console.WriteLine("SuccessFully Reverted . . .");
                                    }
                                    else
                                    {
                                        Console.WriteLine("Insufficient Balance !!!");
                                    }
                                    tType.alive = false;
                                }
                                else
                                {
                                    if (!tType.alive)
                                    {
                                        Console.WriteLine("Cannot Revert, Aborting Reverting !!!");
                                        break;
                                    }
                                    tType.alive = false;
                                    FundsTransfer fT = tType as FundsTransfer;
                                    string        sourceId = fT.SourceId;
                                    string        destId = fT.destinationAccId;
                                    string        sourceBankId = fT.SourceBankId;
                                    string        destBankId = fT.destinationBankId;
                                    Bank          bankSource = null, bankDest = null;
                                    for (int i = 0; i < bankArray.Length; i++)
                                    {
                                        if (bankArray[i].Id.Equals(destBankId))
                                        {
                                            bankDest = bankArray[i];
                                        }
                                        if (bankArray[i].Id.Equals(sourceBankId))
                                        {
                                            bankSource = bankArray[i];
                                        }
                                    }
                                    bool value = new StaffService().RevertFundsTransfer(bankSource, bankDest, tType);
                                    if (value)
                                    {
                                        Console.WriteLine("<<< Transaction Reverted SuccessFully >>>");
                                    }
                                    else
                                    {
                                        Console.WriteLine("Cannot Revert, Aborting Reverting . . .");
                                    }
                                }
                            }
                            break;

                            case 'e':
                            case 'E':
                                staffWish = false;
                                break;
                            }
                        }
                    }
                    else if (choice == '2')
                    {
                        Console.WriteLine("Enter Your Username...");
                        string username = Console.ReadLine();
                        Console.WriteLine("Enter Your Password...");
                        string pword = Console.ReadLine();

                        Customer accHolder  = new BankService().CustomerLogIn(userBank, username, pword);
                        char     choiceUser = '******';
                        bool     exitFlag   = false;
                        while (!exitFlag)
                        {
                            if (accHolder != null)
                            {
                                Console.WriteLine("Enter A Choice\n1.Deposit Amount \n2.Withdraw Amount \n3.Transfer Funds \n4.View Transaction History E.Exit . . .\n");
                                choice = Console.ReadLine()[0];
                            }
                            else
                            {
                                Console.WriteLine("Username Do Not Exists . . .");
                                choice = 'e';
                            }
                            switch (choice)
                            {
                            case '1':
                            {
                                Console.WriteLine("Enter Amount To Deposit : ");
                                float amount = float.Parse(Console.ReadLine());

                                Transaction transaction = new CustomerService().DepositMoney(userBank, accHolder, amount);

                                if (transaction != null)
                                {
                                    Console.WriteLine("SuccessFully Depoisted");
                                }
                                else
                                {
                                    Console.WriteLine("Not Deposited . . .");
                                }
                                break;
                            }

                            case '2':
                            {
                                Console.WriteLine("Enter Amount To Withdraw : ");
                                float       amtF        = float.Parse(Console.ReadLine());
                                Transaction transaction = new CustomerService().WithDrawAmount(userBank, accHolder, amtF);
                                if (transaction != null)
                                {
                                    Console.WriteLine("SuccessFully WithDrawed");
                                }
                                else
                                {
                                    Console.WriteLine("Insufficient Balance <<<< ");
                                }
                                break;
                            }

                            case '4':
                                List <Transaction> transactions = new StaffService().ViewTransactionHistory(userBank, accHolder.GetAccount().AccountId);
                                if (transactions == null)
                                {
                                    Console.WriteLine("No Transactions Exists . . .");
                                    break;
                                }
                                for (int i = 0; i < transactions.Count; i++)
                                {
                                    Console.WriteLine(transactions[i].ToString());
                                }
                                break;

                            case '3':
                                while (true)
                                {
                                    Console.WriteLine("Enter Account Id Of The Reciever : ");
                                    string destAccountId  = Console.ReadLine();
                                    bool   recieverExists = false;
                                    Bank   receiverBank   = null;
                                    Console.WriteLine("Enter Amount To Transfer -->> ");
                                    float amt = float.Parse(Console.ReadLine());

                                    Customer reciever = null;
                                    for (int i = 0; i < bankArray.Length; i++)
                                    {
                                        if ((reciever = new BankService().CustomerExistsOrNotByAccId(bankArray[i], destAccountId)) != null)
                                        {
                                            receiverBank   = bankArray[i];
                                            recieverExists = true;
                                            break;
                                        }
                                    }

                                    if (recieverExists)
                                    {
                                        if (accHolder == reciever)
                                        {
                                            Console.WriteLine("Please, Enter Others Account Id . . .");
                                            continue;
                                        }
                                        bool IsTransfer = new StaffService().FundsTransfer(userBank, receiverBank, amt, accHolder, reciever);
                                        if (IsTransfer)
                                        {
                                            Console.WriteLine("<<<< Transfer SuccessFully >>>>");
                                        }
                                        else
                                        {
                                            Console.WriteLine(">>>> InSufficient Balance <<<<");
                                        }

                                        break;
                                    }
                                    else
                                    {
                                        Console.WriteLine("Reciver Do Not Exists!!!");
                                        break;
                                    }
                                }

                                break;

                            case 'e':
                            case 'E':
                                exitFlag = true;
                                break;
                            }
                        }
                    }
                    else if (choice == 'e')
                    {
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Please Enter A Valid Choice . . .");
                        continue;
                    }
                }
            }
        }
 public StaffController(StaffService staffService)
 {
     this.staffService = staffService;
 }
Exemple #3
0
        public void Can_Succesfully_Create_Instance_Of_StaffService()
        {
            var service = new StaffService(_staffRepoMock.Object);

            Assert.IsNotNull(service);
        }
Exemple #4
0
        /// <summary>
        /// Handles the Load event of the ModifyStaff control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ModifyStaff_Load(object sender, EventArgs e)
        {
            //Bind DepartmentName
            DataSet ds  = datamanage.GetDataSet("select * from [Department]", "Department");
            DataRow row = ds.Tables[0].NewRow();

            row[0] = 0;
            row[1] = "Please Select";
            ds.Tables[0].Rows.InsertAt(row, 0);
            cbxDepartmentName.DataSource    = ds.Tables[0];
            cbxDepartmentName.SelectedIndex = 0;
            cbxDepartmentName.ValueMember   = "DepartmentId";
            cbxDepartmentName.DisplayMember = "DepartmentName";

            //Bind Gender
            cbxGender.DisplayMember = "Please Select";
            cbxGender.SelectedIndex = 0;

            //Bind database
            StaffService staffService = new StaffService();
            Staff        staff        = new Staff();

            staff.StaffId = Convert.ToInt32(staffId);
            staff         = staffService.GetStaffByStaffId(staff);
            if (staff.StaffId > 0)
            {
                lblEI.Text            = staff.EmployeeId.ToString();
                txtStaffName.Text     = staff.StaffName.ToString();
                txtChineseName.Text   = staff.ChineseName.ToString();
                txtTitle.Text         = staff.Title.ToString();
                dtpOnBoardDate.Text   = staff.OnboardDate.ToString();
                dtpStartWorkDate.Text = staff.StartWork.ToString();
                txtEmail.Text         = staff.Email.ToString();
                txtPhoneNumber.Text   = staff.PhoneNumber.ToString();
                if (Convert.ToInt32(staff.Gender) == 1)
                {
                    cbxGender.Text = "Male";
                }
                else if (Convert.ToInt32(staff.Gender) == 0)
                {
                    cbxGender.Text = "Female";
                }
                else
                {
                    cbxGender.Text = "Please select";
                }


                if (Convert.ToInt32(staff.Married) == 1)
                {
                    rbtnYes.Checked = true;
                }
                else
                {
                    rbtnNo.Checked = true;
                }

                txtLocation.Text = staff.Location.ToString();
                cbxDepartmentName.SelectedValue = staff.DepartmentId.ToString();

                if (staff.EmployeeCategory.ToString() == "LH")
                {
                    rbtnLH.Checked = true;
                }
                else
                {
                    rbtnFLH.Checked = true;
                }

                txtContractTerm.Text = staff.ContractTerm.ToString();
                txtLYB.Text          = staff.LastyearRemains.ToString();
            }
        }
 public StaffsController(StaffService staffService)
 {
     _staffService = staffService;
 }
 protected override void ExecuteTest()
 {
     var service = new StaffService(staffInformationRepository, staffEducationOrgInformationRepository, staffAreaLinksFake);
     actualModel = service.Get(StaffRequest.Create(suppliedSchoolId1));
 }
Exemple #7
0
 // GET: api/Staff
 public IEnumerable <Staff> Get()
 {
     return(StaffService.RetrieveAllStaff());
 }
Exemple #8
0
        /// <summary>
        /// 导入
        /// </summary>
        /// <returns></returns>
        public ImportMessage Import()
        {
            ImportMessage msg = new ImportMessage()
            {
                Success = true
            };

            try
            {
                FileInfo fileInfo = new FileInfo(this.FilePath);
                List <StaffExcelModel> records = new List <StaffExcelModel>();
                string sheetName = "Tmp";
                /// 读取excel文件
                using (ExcelPackage ep = new ExcelPackage(fileInfo))
                {
                    if (ep.Workbook.Worksheets.Count > 0)
                    {
                        ExcelWorksheet ws = ep.Workbook.Worksheets.First();
                        sheetName    = ws.Name;
                        BankCardName = ws.Cells[1, 34].Value == null ? string.Empty : ws.Cells[1, 34].Value.ToString();

                        for (int i = 2; i <= ws.Dimension.End.Row; i++)
                        {
                            records.Add(new StaffExcelModel()
                            {
                                NoStr       = ws.Cells[i, 1].Value == null? string.Empty:ws.Cells[i, 1].Value.ToString().Trim(),
                                Nr          = ws.Cells[i, 2].Value == null? string.Empty:ws.Cells[i, 2].Value.ToString().Trim(),
                                Name        = ws.Cells[i, 3].Value == null ? string.Empty : ws.Cells[i, 3].Value.ToString().Trim(),
                                SexStr      = ws.Cells[i, 4].Value == null ? string.Empty : ws.Cells[i, 4].Value.ToString().Trim(),
                                BirthdayStr = ws.Cells[i, 5].Value == null ? string.Empty : ws.Cells[i, 5].Value.ToString().Trim(),
                                //年龄  数据库中没有这个字段
                                AgeStr = ws.Cells[i, 6].Value == null ? string.Empty : ws.Cells[i, 6].Value.ToString().Trim(),

                                FirstCompanyEmployAtStr  = ws.Cells[i, 7].Value == null ? string.Empty : ws.Cells[i, 7].Value.ToString().Trim(),
                                TotalCompanySeniorityStr = ws.Cells[i, 8].Value == null ? string.Empty : ws.Cells[i, 8].Value.ToString().Trim(),
                                CompanyEmployAtStr       = ws.Cells[i, 9].Value == null ? string.Empty : ws.Cells[i, 9].Value.ToString().Trim(),
                                CompanySeniorityStr      = ws.Cells[i, 10].Value == null ? string.Empty : ws.Cells[i, 10].Value.ToString().Trim(),
                                //试用期到期时间, Excel没有IsOnTrial 字段
                                TrialOverAtStr  = ws.Cells[i, 11].Value == null ? string.Empty : ws.Cells[i, 11].Value.ToString().Trim(),
                                DepartmentIdStr = ws.Cells[i, 12].Value == null ? string.Empty : ws.Cells[i, 12].Value.ToString().Trim(),
                                CompanyIdStr    = ws.Cells[i, 13].Value == null ? string.Empty : ws.Cells[i, 13].Value.ToString().Trim(),
                                JobTitleIdStr   = ws.Cells[i, 14].Value == null ? string.Empty : ws.Cells[i, 14].Value.ToString().Trim(),
                                StaffTypeIdStr  = ws.Cells[i, 15].Value == null ? string.Empty : ws.Cells[i, 15].Value.ToString().Trim(),
                                DegreeTypeIdStr = ws.Cells[i, 16].Value == null ? string.Empty : ws.Cells[i, 16].Value.ToString().Trim(),
                                Speciality      = ws.Cells[i, 17].Value == null ? string.Empty : ws.Cells[i, 17].Value.ToString().Trim(),
                                //职业证书, 只有name , 没法进行添加
                                JobCertificate = ws.Cells[i, 18].Value == null ? string.Empty : ws.Cells[i, 18].Value.ToString().Trim(),

                                ResidenceAddress = ws.Cells[i, 19].Value == null ? string.Empty : ws.Cells[i, 19].Value.ToString().Trim(),
                                Address          = ws.Cells[i, 20].Value == null ? string.Empty : ws.Cells[i, 20].Value.ToString().Trim(),
                                //身份证是否验证, 默认为false Excel没有 IsIdChecked字段
                                Id                      = ws.Cells[i, 21].Value == null ? string.Empty : ws.Cells[i, 21].Value.ToString().Trim(),
                                Phone                   = ws.Cells[i, 22].Value == null ? string.Empty : ws.Cells[i, 22].Value.ToString().Trim(),
                                ContactName             = ws.Cells[i, 23].Value == null ? string.Empty : ws.Cells[i, 23].Value.ToString().Trim(),
                                ContactPhone            = ws.Cells[i, 24].Value == null ? string.Empty : ws.Cells[i, 24].Value.ToString().Trim(),
                                ContactFamilyMemberType = ws.Cells[i, 25].Value == null ? string.Empty : ws.Cells[i, 25].Value.ToString().Trim(),
                                Domicile                = ws.Cells[i, 26].Value == null ? string.Empty : ws.Cells[i, 26].Value.ToString().Trim(),
                                ResidenceTypeStr        = ws.Cells[i, 27].Value == null ? string.Empty : ws.Cells[i, 27].Value.ToString().Trim(),
                                InsureTypeIdStr         = ws.Cells[i, 28].Value == null ? string.Empty : ws.Cells[i, 28].Value.ToString().Trim(),
                                IsPayCPFStr             = ws.Cells[i, 29].Value == null ? string.Empty : ws.Cells[i, 29].Value.ToString().Trim(),
                                ContractExpireStr       = ws.Cells[i, 30].Value == null ? string.Empty : ws.Cells[i, 30].Value.ToString().Trim(),
                                ContractCountStr        = ws.Cells[i, 31].Value == null ? string.Empty : ws.Cells[i, 31].Value.ToString().Trim(),
                                //photo 字段 在Excel中, 但是无法将之转化到数据库中
                                Photo = ws.Cells[i, 32].Value == null ? string.Empty : ws.Cells[i, 32].Value.ToString().Trim(),
                                //健康证发证日期, 因为没有nr, 所以无法将之添加到证照表中
                                HealthCertificateEffectiveFromStr = ws.Cells[i, 33].Value == null ? string.Empty : ws.Cells[i, 33].Value.ToString().Trim(),
                                BankCardNrStr     = ws.Cells[i, 34].Value == null ? string.Empty : ws.Cells[i, 34].Value.ToString().Trim(),
                                WorkingYearsAtStr = ws.Cells[i, 35].Value == null ? string.Empty : ws.Cells[i, 35].Value.ToString().Trim(),
                                TotalSeniorityStr = ws.Cells[i, 36].Value == null ? string.Empty : ws.Cells[i, 36].Value.ToString().Trim(),
                                //子女信息, excel只记录了 子女的出生日期和子女年龄, 没有子女姓名, 所以没法写入数据库
                                FamilyMemberBirthdayStr = ws.Cells[i, 37].Value == null ? string.Empty : ws.Cells[i, 37].Value.ToString().Trim(),
                                FamilyMemberAgeStr      = ws.Cells[i, 38].Value == null ? string.Empty : ws.Cells[i, 38].Value.ToString().Trim(),

                                Remark        = ws.Cells[i, 39].Value == null ? string.Empty : ws.Cells[i, 39].Value.ToString().Trim(),
                                WorkStatusStr = ws.Cells[i, 40].Value == null ? string.Empty : ws.Cells[i, 40].Value.ToString().Trim()
                            });
                        }
                    }
                    else
                    {
                        msg.Success = false;
                        msg.Content = "文件不包含数据表,请检查";
                    }
                }
                if (msg.Success)
                {
                    /// 验证数据
                    if (records.Count > 0)
                    {
                        Validates(records);
                        if (records.Where(s => s.ValidateMessage.Success == false).Count() > 0)
                        {
                            /// 创建错误文件
                            msg.Success = false;
                            /// 写入文件夹,然后返回
                            string tmpFile = FileHelper.CreateFullTmpFilePath(Path.GetFileName(this.FilePath), true);
                            msg.Content       = FileHelper.GetDownloadTmpFilePath(tmpFile);
                            msg.ErrorFileFeed = true;

                            FileInfo tmpFileInfo = new FileInfo(tmpFile);
                            using (ExcelPackage ep = new ExcelPackage(tmpFileInfo))
                            {
                                ExcelWorksheet sheet = ep.Workbook.Worksheets.Add(sheetName);
                                ///写入Header
                                for (int i = 0; i < StaffExcelModel.Headers.Count(); i++)
                                {
                                    sheet.Cells[1, i + 1].Value = StaffExcelModel.Headers[i];
                                }
                                ///写入错误数据
                                for (int i = 0; i < records.Count(); i++)
                                {
                                    sheet.Cells[i + 2, 1].Value = records[i].NoStr;
                                    sheet.Cells[i + 2, 2].Value = records[i].Nr;
                                    sheet.Cells[i + 2, 3].Value = records[i].Name;
                                    sheet.Cells[i + 2, 4].Value = records[i].SexStr;
                                    sheet.Cells[i + 2, 5].Value = records[i].BirthdayStr;
                                    sheet.Cells[i + 2, 6].Value = records[i].AgeStr;
                                    //sheet.Cells[i + 2, 7].Value = records[i].Ethnic;
                                    sheet.Cells[i + 2, 7].Value  = records[i].FirstCompanyEmployAt;
                                    sheet.Cells[i + 2, 8].Value  = records[i].TotalCompanySeniorityStr;
                                    sheet.Cells[i + 2, 9].Value  = records[i].CompanyEmployAtStr;
                                    sheet.Cells[i + 2, 10].Value = records[i].CompanySeniorityStr;
                                    //sheet.Cells[i + 2, 11].Value = records[i].isOnTrial;
                                    sheet.Cells[i + 2, 11].Value = records[i].TrialOverAtStr;
                                    sheet.Cells[i + 2, 12].Value = records[i].DepartmentIdStr;
                                    sheet.Cells[i + 2, 13].Value = records[i].CompanyIdStr;
                                    sheet.Cells[i + 2, 14].Value = records[i].JobTitleIdStr;
                                    sheet.Cells[i + 2, 15].Value = records[i].StaffTypeIdStr;
                                    sheet.Cells[i + 2, 16].Value = records[i].DegreeTypeIdStr;
                                    sheet.Cells[i + 2, 17].Value = records[i].Speciality;
                                    sheet.Cells[i + 2, 18].Value = records[i].JobCertificate;
                                    sheet.Cells[i + 2, 19].Value = records[i].ResidenceAddress;
                                    sheet.Cells[i + 2, 20].Value = records[i].Address;
                                    //sheet.Cells[i + 2, 20].Value = records[i].IsIdChecked;
                                    sheet.Cells[i + 2, 21].Value = records[i].Id;
                                    sheet.Cells[i + 2, 22].Value = records[i].Phone;
                                    sheet.Cells[i + 2, 23].Value = records[i].ContactName;
                                    sheet.Cells[i + 2, 24].Value = records[i].ContactPhone;
                                    sheet.Cells[i + 2, 25].Value = records[i].ContactFamilyMemberType;
                                    sheet.Cells[i + 2, 26].Value = records[i].Domicile;
                                    sheet.Cells[i + 2, 27].Value = records[i].ResidenceTypeStr;
                                    sheet.Cells[i + 2, 28].Value = records[i].InsureTypeIdStr;
                                    sheet.Cells[i + 2, 29].Value = records[i].IsPayCPFStr;
                                    sheet.Cells[i + 2, 30].Value = records[i].ContractExpireStr;
                                    sheet.Cells[i + 2, 31].Value = records[i].ContractCountStr;
                                    sheet.Cells[i + 2, 32].Value = records[i].Photo;
                                    sheet.Cells[i + 2, 33].Value = records[i].HealthCertificateEffectiveFromStr;
                                    sheet.Cells[i + 2, 34].Value = records[i].BankCardNrStr;
                                    sheet.Cells[i + 2, 35].Value = records[i].WorkingYearsAtStr;
                                    sheet.Cells[i + 2, 36].Value = records[i].TotalSeniorityStr;
                                    sheet.Cells[i + 2, 37].Value = records[i].FamilyMemberBirthdayStr;
                                    sheet.Cells[i + 2, 38].Value = records[i].FamilyMemberAgeStr;
                                    sheet.Cells[i + 2, 39].Value = records[i].Remark;
                                    sheet.Cells[i + 2, 40].Value = records[i].WorkStatusStr;
                                    sheet.Cells[i + 2, 41].Value = records[i].ValidateMessage.ToString();
                                }

                                /// 保存
                                ep.Save();
                            }
                        }
                        else
                        {
                            /// 数据写入数据库

                            for (var i = 0; i < records.Count; i++)
                            {
                                //公司
                                if (!string.IsNullOrWhiteSpace(records[i].CompanyIdStr))
                                {
                                    try
                                    {
                                        ICompanyService cs      = new CompanyService(this.DbString);
                                        Company         company = cs.FindByName(records[i].CompanyIdStr);

                                        records[i].CompanyId = company.id;
                                    }
                                    catch (Exception e)
                                    {
                                        Console.Write(e);
                                        records[i].CompanyId = null;
                                    }
                                }

                                //部门
                                if (!string.IsNullOrWhiteSpace(records[i].DepartmentIdStr))
                                {
                                    try
                                    {
                                        IDepartmentService ds         = new DepartmentService(this.DbString);
                                        Data.Department    department = ds.FindByIdWithCompanyId(records[i].CompanyId, records[i].DepartmentIdStr);

                                        records[i].DepartmentId = department.id;
                                    }
                                    catch
                                    {
                                        records[i].DepartmentId = null;
                                    }
                                }

                                //职位
                                if (!string.IsNullOrWhiteSpace(records[i].JobTitleIdStr))
                                {
                                    try
                                    {
                                        IJobTitleService jts      = new JobTitleService(this.DbString);
                                        JobTitle         jobtitle = jts.FindByName(records[i].JobTitleIdStr);
                                        records[i].JobTitleId = jobtitle.id;
                                    }
                                    catch (Exception e)
                                    {
                                        Console.Write(e);
                                        records[i].JobTitleId = null;
                                    }
                                }

                                //人员类别
                                if (!string.IsNullOrWhiteSpace(records[i].StaffTypeIdStr))
                                {
                                    try
                                    {
                                        IStaffTypeService sts       = new StaffTypeService(this.DbString);
                                        StaffType         staffType = sts.FindByName(records[i].StaffTypeIdStr);
                                        records[i].StaffTypeId = staffType.id;
                                    }
                                    catch
                                    {
                                        records[i].StaffTypeId = null;
                                    }
                                }

                                //最高学历
                                if (!string.IsNullOrWhiteSpace(records[i].DegreeTypeIdStr))
                                {
                                    try
                                    {
                                        IDegreeTypeService dts        = new DegreeTypeService(this.DbString);
                                        DegreeType         degreeType = dts.FindByName(records[i].DegreeTypeIdStr);
                                        records[i].DegreeTypeId = degreeType.id;
                                    }
                                    catch
                                    {
                                        records[i].DegreeTypeId = null;
                                    }
                                }

                                //保险种类
                                if (!string.IsNullOrWhiteSpace(records[i].InsureTypeIdStr))
                                {
                                    try
                                    {
                                        IInSureTypeService ists       = new InSureTypeService(this.DbString);
                                        InsureType         insuretype = ists.FindByName(records[i].InsureTypeIdStr);
                                        records[i].InsureTypeId = insuretype.id;
                                    }
                                    catch
                                    {
                                        records[i].InsureTypeId = null;
                                    }
                                }
                            }
                            List <Staff> details = StaffExcelModel.Convert(records);

                            for (var i = 0; i < details.Count; i++)
                            {
                                //新增员工
                                IStaffService ss          = new StaffService(this.DbString);
                                var           StaffResult = ss.Create(details[i]);

                                //在新建 员工 成功之后, 进行银行卡添加
                                if (StaffResult)
                                {
                                    bool bankCardResult = true;
                                    //如果填写了交通银行卡 卡号, 进行添加
                                    if (!string.IsNullOrWhiteSpace(records[i].BankCardNrStr))
                                    {
                                        BankCard bankCard = new BankCard();

                                        bankCard.nr      = records[i].BankCardNrStr;
                                        bankCard.bank    = BankCardName;
                                        bankCard.staffNr = records[i].Nr;

                                        IBankCardService bcs = new BankCardService(this.DbString);
                                        bankCardResult = bcs.Create(bankCard);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        msg.Success = false;
                        msg.Content = "文件不包含数据,请检查";
                    }
                }
            }
            catch (Exception e)
            {
                msg.Success = false;
                msg.Content = "导入失败:" + e.Message + ",请联系系统管理员";
                LogUtil.Logger.Error(e.Message);
                LogUtil.Logger.Error(e.StackTrace);
            }
            return(msg);
        }
 public void TestRetrieve()
 {
     var target = new StaffService();
     Assert.IsTrue(target.Retrieve());
 }
 public void TestUpdate()
 {
     var target = new StaffService();
     Assert.IsTrue(target.Update());
 }
 public void TestDelete()
 {
     var target = new StaffService();
     Assert.IsTrue(target.Delete());
 }
        /// <summary>
        /// Constructs the Freshbooks API authentication and wrapper class
        /// </summary>
        /// <param name="accountName">The account name for which you are trying to access</param>
        /// <param name="consumerKey">The developer's freshbooks account name</param>
        /// <param name="oauthSecret">The developer's oauth-secret provided by freshbooks</param>
        public FreshbooksApi(string accountName, string consumerKey, string oauthSecret)
        {
            _accountName = accountName;
            _consumerKey = consumerKey;
            _oauthSecret = oauthSecret ?? String.Empty;

            _baseUri = new UriBuilder { Scheme = "https", Host = accountName + ".freshbooks.com" }.Uri;
            _serviceUri = new Uri(_baseUri, "/api/2.1/xml-in");
            Clear();

            UserAgent = String.Format("{0}/{1} ({2})", 
                GetType().Name,
                GetType().Assembly.GetName().Version.ToString(2), 
                GetType().Assembly.FullName);

            Callback = new CallbackService(new ServiceProxy(this, "callback"));
            Category = new CategoryService(new ServiceProxy(this, "category"));
            Client = new ClientService(new ServiceProxy(this, "client"));
            Estimate = new EstimateService(new ServiceProxy(this, "estimate"));
            Expense = new ExpenseService(new ServiceProxy(this, "expense"));
            Gateway = new GatewayService(new ServiceProxy(this, "gateway"));
            Invoice = new InvoiceService(new ServiceProxy(this, "invoice"));
            Item = new ItemService(new ServiceProxy(this, "item"));
            Language = new LanguageService(new ServiceProxy(this, "language"));
            Payment = new PaymentService(new ServiceProxy(this, "payment"));
            Project = new ProjectService(new ServiceProxy(this, "project"));
            Recurring = new RecurringService(new ServiceProxy(this, "recurring"));
            System = new SystemService(new ServiceProxy(this, "system"));
            Staff = new StaffService(new ServiceProxy(this, "staff"));
            Task = new TaskService(new ServiceProxy(this, "task"));
            Tax = new TaxService(new ServiceProxy(this, "tax"));
            TimeEntry = new TimeEntryService(new ServiceProxy(this, "time_entry"));
        }
Exemple #13
0
 public StaffsController(SmoothContext context)
 {
     _context      = context;
     _staffService = new StaffService(_context);
 }
        /// <summary>
        /// 验证
        /// </summary>
        /// <param name="model"></param>
        /// <param name="dbString"></param>
        public void Validate(string dbString)
        {
            ValidateMessage msg = new ValidateMessage();

            if (string.IsNullOrEmpty(this.AbsenceDateStr))
            {
                msg.Contents.Add("日期不可空");
            }
            else
            {
                DateTime dt = DateTime.Now;
                if (DateTime.TryParse(this.AbsenceDateStr, out dt))
                {
                    //this.RecordAtDate = dt;
                }
                else
                {
                    msg.Contents.Add("日期格式错误");
                }
            }

            if (string.IsNullOrEmpty(this.StaffNr))
            {
                msg.Contents.Add("工号");
            }
            else
            {
                Staff staff = new StaffService(dbString).FindByNr(this.StaffNr);
                if (staff == null)
                {
                    msg.Contents.Add("人员编号不存在");
                }
            }
            if (string.IsNullOrEmpty(this.StartHourStr))
            {
                msg.Contents.Add("开始时间不可空");
            }
            else
            {
                TimeSpan ts = DateTime.Now.TimeOfDay;
                if (TimeSpan.TryParse(this.StartHourStr, out ts))
                {
                    //this.RecordAtDate = dt;
                }
                else
                {
                    msg.Contents.Add("开始时间格式错误");
                }
            }

            if (string.IsNullOrEmpty(this.EndHourStr))
            {
                msg.Contents.Add("结束时间不可空");
            }
            else
            {
                TimeSpan ts = DateTime.Now.TimeOfDay;
                if (TimeSpan.TryParse(this.EndHourStr, out ts))
                {
                    //this.RecordAtDate = dt;
                }
                else
                {
                    msg.Contents.Add("结束时间格式错误");
                }
            }
            if (string.IsNullOrEmpty(this.AbsenceTypeStr))
            {
                msg.Contents.Add("缺勤类型不可空");
            }
            else
            {
                IAbsenceTypeService si    = new AbsenceTypeService(dbString);
                List <AbsenceType>  absTs = si.GetAll();

                bool hasExists = absTs.Where(p => p.name.Equals(this.AbsenceTypeStr)).ToList().Count() > 0;

                if (!hasExists)
                {
                    msg.Contents.Add("缺勤类型不存在");
                }
                else
                {
                    AbsenceType abs = absTs.Where(p => p.name.Equals(this.AbsenceTypeStr)).FirstOrDefault();
                    this.AbsenceTypeId = abs.id;
                }
            }

            //if (string.IsNullOrEmpty(this.DurationTypeStr))
            //{
            //    msg.Contents.Add("时间单位不可空");
            //}
            //else
            //{
            //    bool isVal = DurationTypeStr != "Hour" || DurationTypeStr != "Day";

            //    if (!isVal)
            //    {
            //        msg.Contents.Add("时间单位不存在");
            //    }
            //    else
            //    {
            //        if (DurationTypeStr == "天" || DurationTypeStr == "Day")
            //        {
            //            DurationType = (int)BlueHrLib.Data.Enum.DurationType.Day;
            //        }

            //        if (DurationTypeStr == "小时" || DurationTypeStr == "Hour")
            //        {
            //            DurationType = (int)BlueHrLib.Data.Enum.DurationType.Hour;
            //        }
            //    }
            //}

            //if (string.IsNullOrEmpty(Remark))
            //{
            //    msg.Contents.Add("缺勤原因不可空");
            //}

            if (string.IsNullOrEmpty(this.Duration))
            {
                msg.Contents.Add("缺勤小时不可空");
            }

            //if (msg.Contents.Count == 0)
            //{
            //    if (this.ScheduleAt.HasValue)
            //    {
            //        IShiftScheduleService ss = new ShiftSheduleService(dbString);

            //        if (ss.IsDup(new ShiftSchedule() { id = 0, scheduleAt = this.ScheduleAt.Value, shiftId = this.Shift.id, staffNr = this.StaffNr }))
            //        {
            //            msg.Contents.Add("排班记录已存在,不可重复导入");
            //        }
            //    }
            //}

            msg.Success = msg.Contents.Count == 0;

            this.ValidateMessage = msg;
        }
Exemple #15
0
 // GET: api/Staff/5
 public Staff Get(int id)
 {
     return(StaffService.RetrieveSingleStaff(id));
 }
Exemple #16
0
        private void SearchStaffcomboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            StaffService staffService = new StaffService();

            StaffwiseEmployeelistdataGridView.DataSource = staffService.GetEmployeeListByStaff(SearchStaffcomboBox.Text);
        }
Exemple #17
0
 // POST: api/Staff
 public void Post([FromBody] Staff value)
 {
     StaffService.CreateStaff(value);
 }
Exemple #18
0
        /// <summary>
        /// add new item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddOthers_Click(object sender, EventArgs e)
        {
            int    vacationId = 0;
            string vacationName;
            int    otherVacationId = Convert.ToInt32(this.OthersCombo.SelectedValue);
            int    commonVactionId = Convert.ToInt32(this.CommonCombo.SelectedValue);

            if ((otherVacationId >= 0 && commonVactionId < 0) || (commonVactionId >= 0 && otherVacationId < 0))
            {
                if (otherVacationId >= 0)
                {
                    vacationId   = Convert.ToInt32(this.OthersCombo.SelectedValue);
                    vacationName = this.OthersCombo.Text.ToString();
                }
                else
                {
                    vacationId   = Convert.ToInt32(this.CommonCombo.SelectedValue);
                    vacationName = this.CommonCombo.Text.ToString();
                }

                double   startCounter;
                double   endCounter;
                string   startDate = PickerforStart.Value.Date.ToShortDateString();
                string   endDate   = PickerforEnd.Value.Date.ToShortDateString();
                DateTime start     = Convert.ToDateTime((startDate + " " + StartTimeCombo.Text).ToString());
                DateTime end       = Convert.ToDateTime((endDate + " " + EndTimeCombo.Text).ToString());
                if (StartTimeCombo.SelectedIndex == 0)
                {
                    startCounter = 0;
                }
                else
                {
                    startCounter = -0.5;
                }

                if (EndTimeCombo.SelectedIndex == 0)
                {
                    endCounter = 0.5;
                }
                else
                {
                    endCounter = 1;
                }
                Single   day           = Convert.ToSingle(endCounter + startCounter);// LeaveDetails.Duration
                TimeSpan duration      = end.Date.Subtract(start.Date);
                Single   span          = 0;
                Single   totalday      = day + Convert.ToSingle(duration.TotalDays);
                Single   inputDuration = Convert.ToSingle(numericUpDownDuration.Value);
                Single   testForAnnualLeaveRemainDay = annualLeaveRemainDay;
                Single   testForSickLeaveRemainDay   = sickLeaveRemainDay;
                if (totalday > 0 || inputDuration != 0)
                {
                    switch (vacationId)
                    {
                    case 1:
                        if (inputDuration == 0)
                        {
                            testForAnnualLeaveRemainDay = annualLeaveRemainDay - totalday;
                            span = totalday;
                        }
                        else
                        {
                            testForAnnualLeaveRemainDay = annualLeaveRemainDay - inputDuration;
                            span = inputDuration;
                        }
                        break;

                    case 2:
                        if (inputDuration == 0)
                        {
                            testForSickLeaveRemainDay = sickLeaveRemainDay - totalday;
                            span = totalday;
                        }
                        else
                        {
                            testForSickLeaveRemainDay = sickLeaveRemainDay - inputDuration;
                            span = inputDuration;
                        }
                        break;

                    case 3:
                        if (inputDuration == 0)
                        {
                            span = totalday;
                        }
                        else
                        {
                            span = inputDuration;
                        }
                        showStaffInfo.Married = true;
                        StaffService staffService = new StaffService();
                        staffService.UpdateStaffInfor(showStaffInfo);
                        break;

                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                    default:
                        if (inputDuration == 0)
                        {
                            span = totalday;
                        }
                        else
                        {
                            span = inputDuration;
                        }
                        break;
                    }
                    if (testForAnnualLeaveRemainDay < -5 || testForSickLeaveRemainDay < 0)
                    {
                        MessageBox.Show("The vacation exceeds its limit", "Warning");
                    }
                    else
                    {
                        annualLeaveRemainDay = testForAnnualLeaveRemainDay;
                        sickLeaveRemainDay   = testForSickLeaveRemainDay;
                        LeaveType vacation = new LeaveType {
                            LeaveTypeId = vacationId, LeaveTypeName = vacationName
                        };
                        LeaveDetails newDetail = new LeaveDetails
                        {
                            StaffId     = showStaffInfo.StaffId,
                            LeaveTypeId = vacationId,
                            StartDate   = start,
                            EndDate     = end,
                            Duration    = span,
                            Remark      = textBoxRemark.Text.ToString(),
                            Leavings    = vacation,
                        };
                        LeaveDetailsService detailService = new LeaveDetailsService();
                        detailService.AddNewDetails(newDetail);
                        RequestHistory.DataSource = null;
                        allDetails.Clear();
                        detailsBindingList.Clear();

                        AssignDatatoList();
                        AddLeavingsAttributetoList(allDetails);
                        BindVactionDetails();
                        nCurrent    = 0;
                        pageCurrent = 0;
                        InitPagingList();
                    }
                }
                else
                {
                    MessageBox.Show("Please adjust the interval to fit with the requirement", "Error");
                }
            }
            else
            {
                MessageBox.Show("Please select a vacation type", "Warning");
            }
        }
Exemple #19
0
 // PUT: api/Staff/5
 public void Put(int id, [FromBody] Staff value)
 {
     StaffService.UpdateStaff(id, value);
 }
        static void Main(string[] args)
        {
            //iniciar datos de team
            Team t = new Team
            {
                Active       = true,
                CountryName  = "Belgica",
                Founded      = DateTime.Now,
                Name         = "Belgica",
                TournamentId = 1
            };
            List <Player> jugadores = new List <Player>();

            jugadores.Add(new Player
            {
                Active       = true,
                Name         = "Player Belgica 10",
                DateOfBirth  = DateTime.Now,
                Number       = 10,
                PersonalInfo = new PersonalInfo
                {
                    Address     = "Direccion X",
                    Height      = Convert.ToDecimal("1.70"),// new Decimal(1.70),
                    Nationality = "Belgica",
                    Photo       = "Player01.jpg"
                }
            });

            t.Players = jugadores;
            //iniciar datos staff
            Staff medico = new Medical
            {
                Name         = "Preparador Físico Francia",
                Speciality   = "Fisica",
                PersonalInfo = new PersonalInfo {
                    Address = "Direccion 01"
                }
            };

            using (var ctx = new SoccerAppContext())
            {
                using (var transaction = ctx.Database.BeginTransaction())
                {
                    //instruccion para que escriba en consola los comandos SQL
                    ctx.Database.Log = Console.Write;

                    try
                    {
                        TeamService  teamService  = new TeamService(ctx);
                        StaffService staffService = new StaffService(ctx);

                        //crear equipo
                        Console.WriteLine("Crear equipo --------------------------------");
                        teamService.Insert(t);
                        Console.WriteLine("Registro de equipo exitoso");

                        //crear staff
                        Console.WriteLine("Crear staff --------------------------------");
                        staffService.Insert(medico);
                        Console.WriteLine("Registro de equipo exitoso");
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        Console.WriteLine("Error {0}", ex);
                    }
                }
            }
            Console.ReadLine();
        }
Exemple #21
0
 // DELETE: api/Staff/5
 public void Delete(int id)
 {
     StaffService.DeleteStaff(id);
 }
 public LoginController(StaffService staffService)
 {
     _staffService = staffService;
 }
Exemple #23
0
        public LeavePageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, StaffService staffService)
        {
            this.NavigationService = navigationService;
            this.PageDialogService = pageDialogService;
            this.StaffService      = staffService;

            this.LeaveCommand = new DelegateCommand <Sheet>(async x => await this.LeaveExecuteAsync(x));
        }
 protected override void ExecuteTest()
 {
     var staffService = new StaffService(staffCohortRepository, staffInfoRepository, teacherSectionRepository, schoolInformationRepository, staffAreaLinksFake, applicationStaffCohortRepository, WatchListRepository, WatchListOptionRepository, currentUserClaimInterrogator, staffViewProvider, watchListLinkProvider);
     actualModel = staffService.Get(new StaffRequest
                                        {
                                            StaffUSI = providedStaffUSI1,
                                            SchoolId = providedSchoolId,
                                            StudentListType = suppliedStudentListType,
                                            SectionOrCohortId = suppliedSectionId,
                                            ViewType = suppliedViewType
                                        });
 }
Exemple #25
0
 public NhanVienController(StaffService staffService)
 {
     this._staffService = staffService;
 }