public bool Validate() { string name = txtName.Text.Trim(); if (name.Length == 0) { MessageError.ShowDialog(Translator.GetString("Company name cannot be empty!")); return(false); } CompanyRecord c = CompanyRecord.GetByName(name); if (c != null && c.Id != companyRecord.Id) { if (Message.ShowDialog(Translator.GetString("Warning!"), string.Empty, Translator.GetString("Company with this name already exists! Do you want to continue?"), "Icons.Warning32.png", MessageButtons.YesNo) != ResponseType.Yes) { return(false); } } string code = txtCode.Text.Trim(); c = CompanyRecord.GetByCode(name); if (!string.IsNullOrEmpty(code) && c != null && c.Id != companyRecord.Id) { if (Message.ShowDialog(Translator.GetString("Warning!"), string.Empty, Translator.GetString("Company with this code already exists! Do you want to continue?"), "Icons.Warning32.png", MessageButtons.YesNo) != ResponseType.Yes) { return(false); } } return(true); }
public User GetUser() { user.Code = txtCode.Text.Trim(); user.Name = txtName.Text.Trim(); user.Name2 = txtDisplayName.Text.Trim(); if (passwordChanged) { user.Password = txtPassword1.Text.Trim(); } user.UserLevel = (UserAccessLevel)cboAccessLevel.GetSelectedValue(); user.CardNo = txtCardNo.Text.Trim(); if (lockedLocation == null) { if (!string.IsNullOrWhiteSpace(txtLocation.Text)) { Location resolved = Location.GetByName(txtLocation.Text); if (resolved != null) { EvaluateLocation(resolved); } } } user.LockedLocationId = lockedLocation != null ? lockedLocation.Id : -1; if (defaultPartner == null) { if (!string.IsNullOrWhiteSpace(txtDefaultPartner.Text)) { Partner resolved = Partner.GetByName(txtDefaultPartner.Text); if (resolved != null) { EvaluateDefaultPartner(resolved); } } } user.DefaultPartnerId = defaultPartner != null ? defaultPartner.Id : -1; if (lockedPartner == null) { if (!string.IsNullOrWhiteSpace(txtPartner.Text)) { Partner resolved = Partner.GetByName(txtPartner.Text); if (resolved != null) { EvaluatePartner(resolved); } } } user.LockedPartnerId = lockedPartner != null ? lockedPartner.Id : -1; if (defaultCompany == null) { if (!string.IsNullOrWhiteSpace(txtCompany.Text)) { CompanyRecord resolved = CompanyRecord.GetByName(txtCompany.Text); if (resolved != null) { EvaluateCompany(resolved); } } } user.DefaultCompanyId = defaultCompany != null ? defaultCompany.Id : -1; user.HideItemsPurchasePrice = !chkShowItemsPurchasePrice.Active; user.HideItemsAvailability = !chkShowItemsAvailability.Active; user.AllowZeroPrices = chkAllowZeroPrices.Active; long selectedGroupId = gEditPanel.GetSelectedGroupId(); if (selectedGroupId == PartnersGroup.DeletedGroupId) { user.Deleted = true; } else { user.GroupId = selectedGroupId; } return(user); }