コード例 #1
0
ファイル: EditCompanyAdmin.aspx.cs プロジェクト: phucls/ara
 protected void Page_Load(object sender, EventArgs e)
 {
     SetErrorMessages();
     EnableValidator(false);
     m_companyId = int.Parse(Request.QueryString["RequestId"]);
     m_company = ClientServiceFactory.CompanyService.GetCompanyById(m_companyId);
     if (Page.IsPostBack) return;
     if (m_company != null)
     {
         txtCompany.Text = Dictionary.COMPANY_ADMIN_EDIT_HEADER;
         txtCompanyName.Text = m_company.CompanyName;
         txtAddress.Text = m_company.Address;
         txtEmail.Text = m_company.Email;
         txtPhone.Text = m_company.Phone;
         txtUsername.Text = m_company.UserName;
         txtPassword.Text = m_company.Password;
         s_rowVersion = m_company.RowVersion;
     }
     else if (m_companyId == -4438)
     {
         txtCompany.Text = Dictionary.COMPANY_ADMIN_NEW_HEADER;
     }
     else
     {
         txtCompany.Text = Dictionary.COMPANY_DELETED_EXCEPTION_MSG;
     }
 }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SetErrorMessages();
     EnableValidator(false);
     var user = Page.User.Identity.Name;
     if (user != Dictionary.ADMIN_USERNAME)
     {
         try
         {
             if (Request.QueryString["Method"] == "Edit")
             {
                 m_company = ClientServiceFactory.CompanyService.GetCompanyByUserName(user);
                 m_campaign = ClientServiceFactory.CampaignService.GetCampaignById
                     (int.Parse(Request.QueryString["RequestId"]));
                 if (m_company != null)
                 {
                     txtCampaignName.Text = m_campaign.CampaignName;
                     txtDescription.Text = m_campaign.Description;
                     txtStartTime.Text = m_campaign.StartTime.Date.ToString(Dictionary.DATE_FORMAT);
                     if (m_campaign.EndTime != null)
                     {
                         var endDate = (DateTime) m_campaign.EndTime;
                         txtEndTime.Text = endDate.Date.ToString(Dictionary.DATE_FORMAT);
                     }
                     txtGift.Text = m_campaign.Gift;
                     txtMission.Text = m_campaign.NumMission.ToString();
                     s_rowVersion = m_campaign.RowVersion;
                     m_campaignTypeName = m_campaign.CampaignTypeId.CampaignTypeName;
                 }
                 else
                 {
                     lblMessage.Text = Dictionary.CAMPAIGN_DELETED_EXCEPTION_MSG;
                 }
             }
             else
             {
                 m_company = ClientServiceFactory.CompanyService.GetCompanyByUserName(user);
                 m_campaign = new Campaign();
                 m_campaignTypeName = Request.QueryString["Type"];
                 SetCampaignType();
             }
         }
         catch (FaultException<CompanyAlreadyDeletedException> ex)
         {
             lblMessage.Text = ex.Message;
         }
     }
     else
     {
         Response.Redirect(Routes.NAVIGATION_TO_HOME_PAGE_OF_ADMIN);
     }
 }
コード例 #3
0
ファイル: CompanyServiceImpl.svc.cs プロジェクト: phucls/ara
 /// <summary>
 ///     Save new company
 /// </summary>
 /// <param name="company"></param>
 public void SaveNewCompany(Company company)
 {
     var srvDao = NinjectKernelFactory.Kernel.Get<ICompanyDataAccess>();
     using (var tr = TransactionsFactory.CreateTransactionScope())
     {
         try
         {
             srvDao.Save(company);
         }
         catch (ADOException)
         {
             throw new FaultException<CompanyNameAlreadyExistException>(
                 new CompanyNameAlreadyExistException
                 {
                     MessageError = Dictionary.COMPANY_NAME_CONSTRAINT_EXCEPTION_MSG
                 },
                 new FaultReason(Dictionary.UNIQUE_CONSTRAINT_EXCEPTION_REASON));
         }
         catch (StaleObjectStateException)
         {
             throw new FaultException<ConcurrentUpdateException>(
                 new ConcurrentUpdateException
                 {
                     MessageError = Dictionary.COMPANY_CONCURRENT_UPDATE_EXCEPTION_MSG
                 },
                 new FaultReason(Dictionary.COMPANY_CONCURRENT_UPDATE_EXCEPTION_MSG));
         }
         catch (Exception ex)
         {
             throw new FaultException<Exception>(
                 new Exception(ex.Message),
                 new FaultReason(Dictionary.UNKNOWN_REASON));
         }
         tr.Complete();
     }
 }
コード例 #4
0
ファイル: EditCompanyAdmin.aspx.cs プロジェクト: phucls/ara
 protected void btnSave_OnClick(object sender, EventArgs e)
 {
     EnableValidator(true);
     Page.Validate();
     if (!Page.IsValid) return;
     if (txtCompany.Text == Dictionary.COMPANY_ADMIN_NEW_HEADER)
     {
         var company = new Company
         {
             CompanyName = txtCompanyName.Text,
             Address = txtAddress.Text,
             Email = txtAddress.Text,
             Phone = txtPhone.Text,
             UserName = txtUsername.Text,
             Password = txtPassword.Text
         };
         try
         {
             ClientServiceFactory.CompanyService.SaveNewCompany(company);
         }
         catch (FaultException<CompanyNameAlreadyExistException> ex)
         {
             lblMessage.Text = ex.Detail.MessageError;
         }
         catch (FaultException<Exception> ex)
         {
             lblMessage.Text = ex.Detail.Message;
         }
         RedirectToCompanyAdmin();
     }
     else
     {
         m_company.CompanyName = txtCompanyName.Text;
         m_company.Address = txtAddress.Text;
         m_company.Email = txtEmail.Text;
         m_company.Phone = txtPhone.Text;
         m_company.UserName = txtUsername.Text;
         m_company.Password = txtPassword.Text;
         m_company.RowVersion = s_rowVersion;
         try
         {
             ClientServiceFactory.CompanyService.SaveNewCompany(m_company);
         }
         catch (FaultException<ConcurrentUpdateException> ex)
         {
             lblMessage.Text = ex.Detail.MessageError;
         }
         RedirectToCompanyAdmin();
     }
 }