protected void gvwMaster_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("EditRow")) { string userName = e.CommandArgument.ToString(); ViewState["_UserName"] = userName; mvwForm.ActiveViewIndex = 1; MembershipUser user = UserManagement.GetUserDetail(userName); Employee emp = employeeProvider.Get(userName); txtUserName.Text = user.UserName; txtEmail.Text = user.Email; ddlRole.SelectedValue = UserManagement.GetRoleByUserName(userName); rqvConfirmPassword.Enabled = rqvPassword.Enabled = txtConfirmPassword.Enabled = txtPassword.Enabled = false; txtPassword.BackColor = txtConfirmPassword.BackColor = System.Drawing.Color.Gray; try { ddlHomeBranch.SelectedValue = emp.HomeBranchID.ToString(); } catch { } txtBarcode.Text = emp.Barcode; cuvPassword.Enabled = rqvConfirmPassword.Enabled = rqvPassword.Enabled = false; cuvPassword.IsValid = rqvConfirmPassword.IsValid = rqvPassword.IsValid = true; txtUserName.Focus(); } else if (e.CommandName.Equals("ResetPassword")) { mvwForm.ActiveViewIndex = 2; lblResetUserName.Text = e.CommandArgument.ToString(); ViewState["_UserName"] = lblResetUserName.Text; } }
public void Test_Get_By_Id() { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <EmployeeContext>().UseSqlite(connection).Options; using (var context = new EmployeeContext(options)) { context.Database.EnsureCreated(); } using (var context = new EmployeeContext(options)) { context.Employees.Add(new Employee { Id = 1, FirstName = "John", LastName = "Doe", Address = "123 Street", HomePhone = "111-111-1111", CellPhone = "222-222-2222" }); context.SaveChanges(); } using (var context = new EmployeeContext(options)) { var provider = new EmployeeProvider(context); var employee = provider.Get(1); Assert.AreEqual("John", employee.FirstName); } }
protected void gvwMaster_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditRow") { int id = Convert.ToInt32(e.CommandArgument); RowID = id; mvwForm.SetActiveView(viwAddEdit); Employee employee = employeeProvider.Get(id); lblUserName.Text = employee.UserName; txtBarcode.Text = employee.Barcode; txtFirstName.Text = employee.FirstName; txtLastName.Text = employee.LastName; txtPhone.Text = employee.Phone; txtEmail.Text = employee.Email; chkIsActive.Checked = employee.IsActive; ddlHomeBranch.SelectedValue = employee.HomeBranchID.ToString(); chkCanApproveDocument.Checked = employee.CanApproveDocument; chkCanEditActiveContract.Checked = employee.CanEditActiveContract; chkCanReprint.Checked = employee.CanReprint; ViewState["Photo"] = employee.Photo; if (!String.IsNullOrEmpty(employee.Photo)) { FileInfo file = new FileInfo(employee.Photo); imgPhoto.ImageUrl = ConfigurationManager.AppSettings[ApplicationSettingKeys.FolderPhotoEmployees] + @"\" + file.Name.Substring(0, file.Name.IndexOf(".")) + file.Extension + ".ashx?w=200"; } else { imgPhoto.ImageUrl = ConfigurationManager.AppSettings[ApplicationSettingKeys.FolderPhotoEmployees] + @"\default.png"; } chkDeletePhoto.Checked = false; txtBarcode.Focus(); } }
public void Get_ReturnsSpecifiedEmployee() { Mock <ISource> source = new Mock <ISource>(); source.Setup(s => s.GetById(5)).Returns(new Employee(5, "Moq")); var provider = new EmployeeProvider(source.Object); var employee = provider.Get(5); Assert.That(employee, Is.Not.Null); Assert.That(employee.Id, Is.EqualTo(5)); Assert.That(employee.Name, Is.EqualTo("Moq")); }
public void Get_ReturnsSpecifiedEmployee() { ISource source = Substitute.For <ISource>(); source.GetById(5).Returns(new Employee(5, "NSubstitute")); var provider = new EmployeeProvider(source); var employee = provider.Get(5); Assert.That(employee, Is.Not.Null); Assert.That(employee.Id, Is.EqualTo(5)); Assert.That(employee.Name, Is.EqualTo("NSubsitute")); }
protected void gvwMaster_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "EditRow") { int id = Convert.ToInt32(e.CommandArgument); RowID = id; mvwForm.SetActiveView(viwAddEdit); chkGenerateNewBarcodeCustomer.Visible = false; Contract contract = contractProvider.Get(id); chkGenerateNewBarcodeCustomer.Checked = false; lblBranch.Text = contract.Branch.Name; lblContractNo.Text = contract.ContractNo; calDate.SelectedDate = contract.Date; calDateOfBirth.SelectedDate = contract.Customer.DateOfBirth.HasValue ? contract.Customer.DateOfBirth.Value : DateTime.Today; txtCustomerBarcode.Text = contract.Customer.Barcode; txtCustomerBarcode.ReadOnly = true; lblCustomerName.Text = String.Format("{0} {1}", contract.Customer.FirstName.Trim(), contract.Customer.LastName.Trim()); ddlPackage.SelectedValue = contract.PackageID.ToString(); ddlPackage_SelectedIndexChanged(sender, null); txtHomePhone.Text = contract.Customer.HomePhone; txtCellPhone.Text = contract.Customer.CellPhone1; calEffectiveDate.SelectedDate = contract.EffectiveDate; ddlBillingType.SelectedValue = contract.BillingTypeID.ToString(); ddlBillingCardType.SelectedValue = contract.Customer.CreditCardTypeID.ToString(); ddlBillingBank.SelectedValue = contract.Customer.BankID.ToString(); txtBillingCardNo.Text = contract.Customer.CardNo; txtBillingCardHolderName.Text = contract.Customer.CardHolderName; txtBillingCardHolderID.Text = contract.Customer.CardHolderID; if (contract.Customer.ExpiredDate.HasValue) { ddlCardExpiredMonth.SelectedValue = contract.Customer.ExpiredDate.Value.Month.ToString(); ddlCardExpiredYear.SelectedValue = contract.Customer.ExpiredDate.Value.Year.ToString(); } txtMailingAddress.Text = contract.Customer.MailingAddress; txtMailingZipCode.Text = contract.Customer.MailingZipCode; txtAddress.Text = contract.Customer.Address; txtZipCode.Text = contract.Customer.ZipCode; if (ddlArea.Items.FindByValue(contract.Customer.AreaID.ToString()) != null) { ddlArea.SelectedValue = contract.Customer.AreaID.ToString(); } else { ddlArea.SelectedIndex = 0; } if (contract.Customer.SchoolID.HasValue) { txtSchoolID.Text = contract.Customer.SchoolID.Value.ToString(); txtSchoolName.Text = contract.Customer.School.Name; } else { txtSchoolID.Text = String.Empty; txtSchoolName.Text = String.Empty; } lblStatus.Text = contractProvider.DecodeStatus(Convert.ToChar(contract.Status)); txtNotes.Text = contract.Notes; lblActiveDate.Text = contract.ActiveDate.HasValue ? contract.ActiveDate.Value.ToString("dddd, dd MMMM yyyy") : "Not Active"; btnVoid.Enabled = contract.Status == "A"; if (employeeProvider.Get(User.Identity.Name).CanEditActiveContract) { btnSave.Enabled = true; } else { btnSave.Enabled = contract.Status == "P"; } lblClosedDate.Text = contract.ClosedDate.HasValue ? contract.ClosedDate.Value.ToString("dddd, dd MMMM yyyy") : "This contract has not been closed"; lblVoidDate.Text = contract.VoidDate.HasValue ? contract.VoidDate.Value.ToString("dddd, dd MMMM yyyy") : "This contract has not been void"; calExpiredDate.Enabled = true; calExpiredDate.SelectedDate = contract.ExpiredDate; ddlMonthlyDuesItem.SelectedValue = Convert.ToString(contract.BillingItemID); calNextDuesDate.SelectedDate = contract.NextDuesDate.Value; txtDuesAmount.Text = contract.DuesAmount.ToString("###,##0.00"); Person father = contract.Customer.Persons.SingleOrDefault(p => p.Connection == "F"); chkFather.Checked = father != null; if (father != null) { txtFatherName.Text = father.Name; txtFatherPhone.Text = father.Phone1; txtIDCardNoFather.Text = father.IDCardNo; txtFatherEmail.Text = father.Email; chkFatherBirthDateUnknown.Checked = !father.BirthDate.HasValue; if (father.BirthDate.HasValue) { calBirthDateFather.SelectedValue = father.BirthDate.Value; } } Person mother = contract.Customer.Persons.SingleOrDefault(p => p.Connection == "M"); chkMother.Checked = mother != null; if (mother != null) { txtMotherName.Text = mother.Name; txtMotherPhone.Text = mother.Phone1; txtIDCardNoMother.Text = mother.IDCardNo; txtMotherEmail.Text = mother.Email; chkMotherBirthDateUnknown.Checked = !mother.BirthDate.HasValue; if (mother.BirthDate.HasValue) { calBirthDateMother.SelectedValue = mother.BirthDate.Value; } } btnVoid.Enabled = !contract.VoidDate.HasValue; btnCloseContract.Enabled = !contract.VoidDate.HasValue; btnVoid.Enabled = !contract.ClosedDate.HasValue; btnCloseContract.Enabled = !contract.ClosedDate.HasValue; if (!String.IsNullOrEmpty(contract.ContractType)) { chkIsTransfer.Checked = contract.ContractType == "T"; if (contract.ContractType != "T") { ddlRenewalOrUpgrade.SelectedValue = contract.ContractType; } } ddlRenewalOrUpgrade.Enabled = false; chkIsTransfer.Enabled = false; ClientScript.RegisterStartupScript(this.GetType(), "_cust", "$(document).ready(function() { $('#customer').show(); });", true); hypLookUpCustomer.Visible = false; } } catch (Exception ex) { mvwForm.SetActiveView(viwRead); WebFormHelper.SetLabelTextWithCssClass(lblMessage, ex.Message, LabelStyleNames.ErrorMessage); } }