Пример #1
0
        //Save Company
        private void SaveButton_Click(object sender, EventArgs e)
        {
            companny.Name      = nameTextBox.Text;
            companny.ErrorText = categoryErrorLabel.Text;

            bool isExist = companyManagement.IsExisted(companny);

            if (isExist)
            {
                categoryErrorLabel.Text = "*This Company Already Existed!!";
                return;
            }

            bool verify = companyManagement.IsVerified(companny);

            if (verify)
            {
                categoryErrorLabel.Text = "*Field Must Not Be Empty!!!!";
                return;
            }

            bool isAdd = companyManagement.IsAdded(companny);

            if (isAdd)
            {
                nameTextBox.Clear();
                categoryErrorLabel.Text = "";

                DataTable dt = new DataTable();
                dt = companyRepository.AddCompany();
                companyDataGridView.DataSource = dt;
            }
        }
Пример #2
0
 public long AddCompany(CompanyObject companyAccount)
 {
     try
     {
         return(_companyAccountRepository.AddCompany(companyAccount));
     }
     catch (Exception ex)
     {
         ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #3
0
        public Company SignUpCompany(string name, string login, string mobilePhone, string email, string paswword)
        {
            Company company = new Company {
                Name = name, MobileNumber = mobilePhone, Email = email
            };
            CompanyAccessData compData = new CompanyAccessData {
                Login = login, Password = paswword, Company = company
            };

            if (CompanyRepository.AddCompany(company, compData))
            {
                CompanyRepository.SaveChages();
                return(company);
            }
            else
            {
                return(null);
            }
        }
        public async Task <int> AddCompany(Company company)
        {
            await ValidateCompany(company);

            var companyExists = CompanyExists(company);

            if (!companyExists)
            {
                _companyRepository.AddCompany(company);

                MessageBox.Show("Company sucessfully added!", "Company added", MessageBoxButton.OK, MessageBoxImage.Information);

                return(1);
            }
            else
            {
                MessageBox.Show("Company already exists!", "Company exists", MessageBoxButton.OK, MessageBoxImage.Hand);

                return(1);
            }
        }
Пример #5
0
        public ActionResult CreateCompany(CompanyFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var company = Mapper.Map <CompanyFormViewModel, Company>(viewModel);

            try
            {
                companyRepository.AddCompany(company);

                unitOfWork.Save();
                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception)
            {
                return(View("CompanyForm"));
            }
        }
Пример #6
0
        public ActionResult Create(CompanyVM model)
        {
            try
            {
                string companyId = string.Empty;
                model.CreatedBy = LogInManager.LoggedInUserId;

                companyId = companyRepository.AddCompany(model);

                if (!string.IsNullOrWhiteSpace(companyId))
                {
                    return(Json(new
                    {
                        IsSuccess = true,
                        data = new
                        {
                            CompanyId = companyId
                        }
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = "Company details not saved successfully."
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "Create");
                return(Json(new
                {
                    IsSuccess = false,
                    errorMessage = e.Message
                }));
            }
        }
Пример #7
0
        private void OnNewCompanySaveButton(object sender, RoutedEventArgs e)
        {
            (bool isCompanyNameEmpty, bool isCompanyNameError) = service.ValidateCompanyNameTextField(companyNameTextField, companyNameErrorLabel);
            (bool isAddressEmpty, bool isAddressError)         = service.ValidateAddressTextField(addressTextField, addressErrorLabel);
            (bool isPostalCodeEmpty, bool isPostalCodeError)   = service.ValidatePostalcodeTextField(postalcodeTextField, postalcodeErrorLabel);
            (bool isCityEmpty, bool isCityError)       = service.ValidateCityTextField(cityTextField, cityErrorLabel);
            (bool isCountryEmpty, bool isCountryError) = service.ValidateCountryTextField(countryTextField, countryErrorLabel);

            if (isUpdateFlag)
            {
                isCompanyNameEmpty = false;
                isAddressEmpty     = false;
                isPostalCodeEmpty  = false;
                isCityEmpty        = false;
                isCountryEmpty     = false;
            }

            if (!isCompanyNameEmpty && !isCompanyNameError && !isAddressEmpty &&
                !isAddressError && !isPostalCodeEmpty && !isPostalCodeError &&
                !isCityEmpty && !isCityError && !isCountryEmpty && !isCountryError)
            {
                if (!isUpdateFlag)
                {
                    company = new Company();
                }

                company.CompanyName = companyNameTextField.Text;
                company.Address     = addressTextField.Text;
                company.City        = cityTextField.Text;
                company.Country     = countryTextField.Text;
                company.PostalCode  = postalcodeTextField.Text;

                repository.AddCompany(company, context, isUpdateFlag);

                companyWindow.RefreshCompanyGridData();
                Close();
            }
        }
        public ActionResult Add(CompanyInformation uInfo, HttpPostedFileBase CompanyImage)
        {
            if (ModelState.IsValid)
            {
                if (CompanyImage != null)
                {
                    if (CompanyImage.ContentLength > 500 * 1024)
                    {
                        ModelState.AddModelError("CompanyImage", "Image must be less than 500Kb.");

                        return(View(uInfo));
                    }
                }

                using (var cRepository = new CompanyRepository())
                {
                    cRepository.AddCompany(uInfo, CompanyImage != null ? CompanyImage.InputStream : null, CompanyImage != null ? CompanyImage.FileName : null);

                    return(RedirectToAction("Manage"));
                }
            }

            return(View(uInfo));
        }