protected void btnSave_Click(object sender, EventArgs e) { CompanyTableAdapters.un_co_detailsTableAdapter coTA = new CompanyTableAdapters.un_co_detailsTableAdapter(); if (coTA.GetCompanyByName(txtCompanyShortName.Text, null).GetEnumerator().MoveNext()) { SetErrorMessage(WebConstants.Messages.Error.ALREAD_EXISTS); } else { IEnumerator ie = coTA.InsertAndReturn(false, txtCompanyShortName.Text, txtCompanyLongName.Text, txtContactTitle.Text, txtContactInitial.Text, txtForename.Text, txtSurname.Text, txtAddressNo.Text, txtAddress1.Text, txtAddress2.Text, txtAddress3.Text, txtAddress4.Text, txtAddress5.Text, txtPostalCode.Text, getFullAddress(), txtTele.Text, txtTele1.Text, txtFax.Text, txtEmail.Text, txtCoNotes.Text, 0, 0, false,null, DateTime.Now, null, DateTime.Now, cbAutoSave.Checked, tbFireWarden.Text, tbFirstAider.Text, cbMultiSups.Checked, tbSupervisor.Text, true, 1, true, DateTime.Today, 15, Utility.GetTrialEndDate(DateTime.Today,15),true).GetEnumerator(); if (ie.MoveNext()) { int coId = ((Company.un_co_detailsRow)ie.Current).co_id; Session[WebConstants.Session.REG_CO_ID] = coId; DepartmentTableAdapters.DepartmentSelectCommandTableAdapter deptTA = new DepartmentTableAdapters.DepartmentSelectCommandTableAdapter(); IEnumerator ieDept = deptTA.InsertAndReturn(coId,false,txtCompanyShortName.Text,txtCompanyLongName.Text,txtContactTitle.Text, txtContactInitial.Text, txtForename.Text, txtSurname.Text, txtAddressNo.Text, txtAddress1.Text, txtAddress2.Text, txtAddress3.Text, txtAddress4.Text, txtAddress5.Text, txtPostalCode.Text, getFullAddress(), txtTele.Text, txtTele1.Text, txtFax.Text, txtEmail.Text,txtCoNotes.Text,null,DateTime.Now,null,DateTime.Now).GetEnumerator(); if(ieDept.MoveNext()) { Session[WebConstants.Session.REG_DEPT_ID] = ((Department.DepartmentSelectCommandRow)ieDept.Current).dept_id; } SetInfoMessage(WebConstants.Messages.Information.RECORD_SAVED); Session[WebConstants.Session.WIZARD_STEP] = 2; Response.Redirect("~/Register/AddDepartment.aspx"); } } }
public static Company.un_co_detailsRow GetCompany(int coId) { Company.un_co_detailsRow dataRow = null; CompanyTableAdapters.un_co_detailsTableAdapter tableAdapter = new CompanyTableAdapters.un_co_detailsTableAdapter(); IEnumerator iEnumerator = tableAdapter.GetCompanyById(coId).GetEnumerator(); if (iEnumerator.MoveNext()) { dataRow = (Company.un_co_detailsRow)iEnumerator.Current; } return dataRow; }
protected void gvCompanies_RowCommand(object sender, GridViewCommandEventArgs e) { CompanyTableAdapters.un_co_detailsTableAdapter coTA = new CompanyTableAdapters.un_co_detailsTableAdapter(); int coId = int.Parse(e.CommandArgument.ToString()); //HyperLink1.Text = e.CommandName; if (e.CommandName.Equals("Activate")) { coTA.UpdateActive(true, coId); } else if (e.CommandName.Equals("Deactivate")) { coTA.UpdateActive(false, coId); } gvCompanies.DataBind(); }
protected void btnUpdate_Click(object sender, EventArgs e) { int coId = (int)Session[WebConstants.Session.REG_CO_ID]; CompanyTableAdapters.un_co_detailsTableAdapter coTA = new CompanyTableAdapters.un_co_detailsTableAdapter(); if (coTA.GetCompanyByName(txtCompanyShortName.Text, coId).GetEnumerator().MoveNext()) { SetErrorMessage(WebConstants.Messages.Error.ALREAD_EXISTS); } else { coTA.Update(false, txtCompanyShortName.Text, txtCompanyLongName.Text, txtContactTitle.Text, txtContactInitial.Text, txtForename.Text, txtSurname.Text, txtAddressNo.Text, txtAddress1.Text, txtAddress2.Text, txtAddress3.Text, txtAddress4.Text, txtAddress5.Text, txtPostalCode.Text, getFullAddress(), txtTele.Text, txtTele1.Text, txtFax.Text, txtEmail.Text, txtCoNotes.Text, 0, 0, false, null, DateTime.Now, cbAutoSave.Checked, tbFireWarden.Text, tbFirstAider.Text, cbMultiSups.Checked, tbSupervisor.Text, true, DateTime.Today, 15, Utility.GetTrialEndDate(DateTime.Today,15),true, coId); SetInfoMessage(WebConstants.Messages.Information.RECORD_SAVED); Session[WebConstants.Session.WIZARD_STEP] = 2; Response.Redirect("~/Register/AddDepartment.aspx"); } }
public void HandlePostLoginProcess(int userId, string role, int coId) { TimeSpan SessTimeOut = new TimeSpan(0, 0, HttpContext.Current.Session.Timeout, 0, 0); HttpContext.Current.Cache.Insert(userId.ToString(), HttpContext.Current.Request.UserHostAddress, null, DateTime.MaxValue, SessTimeOut, System.Web.Caching.CacheItemPriority.NotRemovable, null); Company.un_co_detailsRow company = DatabaseUtility.GetCompany(coId); if (company != null && company.flg_show_wizard) { HttpContext.Current.Session[WebConstants.Session.REG_CO_ID] = company.co_id; HttpContext.Current.Session[WebConstants.Session.REG_USER_ID] = userId; DepartmentTableAdapters.DepartmentSelectCommandTableAdapter deptTA = new DepartmentTableAdapters.DepartmentSelectCommandTableAdapter(); IEnumerator ie = deptTA.GetDepartmentsByCoId(coId).GetEnumerator(); if (ie.MoveNext()) { Department.DepartmentSelectCommandRow department = (Department.DepartmentSelectCommandRow)ie.Current; HttpContext.Current.Session[WebConstants.Session.REG_DEPT_ID] = department.dept_id; } if (company.Isflg_trialNull() == true || company.flg_trial == false) { company.trial_start_date = DateTime.Today; company.flg_trial = true; company.trial_num_of_days = 15; company.trial_end_date = Utility.GetTrialEndDate(DateTime.Today, 15); CompanyTableAdapters.un_co_detailsTableAdapter coTA = new CompanyTableAdapters.un_co_detailsTableAdapter(); coTA.Update(company); } HttpContext.Current.Response.Redirect("~/Register/AddCompany.aspx"); } else if (role.Equals(WebConstants.Roles.User)) { HttpContext.Current.Response.Redirect("TermsConditions.aspx"); } else { HttpContext.Current.Response.Redirect(role + "Home.aspx"); } }
protected void btnUpdate_Click(object sender, EventArgs e) { int coId = int.Parse(Request[WebConstants.Request.CO_ID]); CompanyTableAdapters.un_co_detailsTableAdapter coTA = new CompanyTableAdapters.un_co_detailsTableAdapter(); if (coTA.GetCompanyByName(txtCompanyShortName.Text, coId).GetEnumerator().MoveNext()) { SetErrorMessage(WebConstants.Messages.Error.ALREAD_EXISTS); } else if(Validate()) { if (cbTrial.Checked) { coTA.Update(false, txtCompanyShortName.Text, txtCompanyLongName.Text, txtContactTitle.Text, txtContactInitial.Text, txtForename.Text, txtSurname.Text, txtAddressNo.Text, txtAddress1.Text, txtAddress2.Text, txtAddress3.Text, txtAddress4.Text, txtAddress5.Text, txtPostalCode.Text, getFullAddress(), txtTele.Text, txtTele1.Text, txtFax.Text, txtEmail.Text, txtCoNotes.Text, 0, 0, false, loggedInUserId, DateTime.Now, cbAutoSave.Checked, tbFireWarden.Text, tbFirstAider.Text, cbMultiSups.Checked, tbSupervisor.Text, cbTrial.Checked, tbTrialStartDate.SelectedDate, int.Parse(tbTrialNumOfDays.Text), GetTrialEndDate(),cbWizard.Checked, coId); } else { coTA.Update(false, txtCompanyShortName.Text, txtCompanyLongName.Text, txtContactTitle.Text, txtContactInitial.Text, txtForename.Text, txtSurname.Text, txtAddressNo.Text, txtAddress1.Text, txtAddress2.Text, txtAddress3.Text, txtAddress4.Text, txtAddress5.Text, txtPostalCode.Text, getFullAddress(), txtTele.Text, txtTele1.Text, txtFax.Text, txtEmail.Text, txtCoNotes.Text, 0, 0, false, loggedInUserId, DateTime.Now, cbAutoSave.Checked, tbFireWarden.Text, tbFirstAider.Text, cbMultiSups.Checked, tbSupervisor.Text, cbTrial.Checked, null,null,null,cbWizard.Checked,coId); } SetInfoMessage(WebConstants.Messages.Information.RECORD_SAVED); } }
private void UpdateTrialLicense() { CompanyTableAdapters.un_co_detailsTableAdapter compTA = new CompanyTableAdapters.un_co_detailsTableAdapter(); if (Session[WebConstants.Session.REGISTERING_FOR_TRIAL] != null) { compTA.CompanyTrialUpdate((int)Session[WebConstants.Session.SIMPLICITY_COMPANY_ID], true); Simplicity.Data.SimplicityEntities simplicityDatabaseContext = new Simplicity.Data.SimplicityEntities(); int userId = (int)Session[WebConstants.Session.SIMPLICITY_USER_ID]; Simplicity.Data.UserProduct userProduct = (from userProd in simplicityDatabaseContext.UserProducts where userProd.ProductID == 2 && userProd.UserID == userId select userProd).FirstOrDefault(); if (userProduct == null) { userProduct = new Simplicity.Data.UserProduct(); userProduct.UserID = userId; userProduct.ProductID = 2; simplicityDatabaseContext.AddToUserProducts(userProduct); } userProduct.IsTrial = true; userProduct.StartDate = DateTime.Now; userProduct.EndDate = DateTime.Now.AddDays(15); simplicityDatabaseContext.SaveChanges(); } else { compTA.CompanyTrialUpdate((int)Session[WebConstants.Session.SIMPLICITY_COMPANY_ID], false); } }