protected void btnIssueContract_Click(object sender, EventArgs e) { var agencyContract = new AgencyContract(); agencyContract.Agency = Agency; DateTime?contractValidFromDate = null; try { contractValidFromDate = DateTime.ParseExact(txtContractValidFromDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch { } agencyContract.ContractValidFromDate = contractValidFromDate; DateTime?contractValidToDate = null; try { contractValidToDate = DateTime.ParseExact(txtContractValidToDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch { } agencyContract.ContractValidToDate = contractValidToDate; agencyContract.ContractTemplateName = "Contract_" + Agency.Name + "_" + contractValidFromDate.Value.ToString("ddMMyyyy") + "_" + contractValidToDate.Value.ToString("ddMMyyyy"); agencyContract.ContractTemplatePath = "/Modules/Sails/Admin/ExportTemplates/Contract Lv1.doc"; AgencyViewBLL.AgencyContractSaveOrUpdate(agencyContract); Response.Redirect(Request.RawUrl); }
protected void btnAgencyNotesSave_Click(object sender, EventArgs e) { var roleId = 0; try { roleId = Int32.Parse(ddlAgencyNotesRole.SelectedValue); } catch { } var role = AgencyViewBLL.RoleGetById(roleId); var agencyNotesId = 0; try { agencyNotesId = Int32.Parse(hidAgencyNotesId.Value); } catch { } AgencyNotes agencyNotes = null; agencyNotes = AgencyViewBLL.AgencyNotesGetById(agencyNotesId); if (agencyNotes == null || agencyNotes.Id == 0) { agencyNotes = new AgencyNotes(); } agencyNotes.Agency = Agency; agencyNotes.Role = role; agencyNotes.Note = txtAgencyNotesNote.Text; AgencyViewBLL.AgencyNotesSaveOrUpdate(agencyNotes); Response.Redirect(Request.RawUrl); }
public void LoadContracts() { var agencyId = Agency.Id; rptContracts.DataSource = AgencyViewBLL.AgencyContractGetAllByAgency(agencyId); rptContracts.DataBind(); }
public new void Dispose() { if (agencyViewBLL != null) { agencyViewBLL.Dispose(); agencyViewBLL = null; } }
public void lbtContractTemplate_Click(object sender, EventArgs e) { var agencyContractId = -1; try { agencyContractId = Int32.Parse(((LinkButton)sender).CommandArgument); } catch { } var agencyContract = AgencyViewBLL.AgencyContractGetById(agencyContractId); ExportContractToWord(agencyContract); }
protected void rptContracts_ItemCommand(object source, RepeaterCommandEventArgs e) { var agencyContractId = int.Parse(e.CommandArgument.ToString()); var agencyContract = AgencyViewBLL.AgencyContractGetById(agencyContractId); if (e.CommandName == "DownloadContract") { ExportContractToWord(agencyContract); } if (e.CommandName == "DownloadQuotation") { ExportQuotationToWord(agencyContract); } }
protected void rptAgencyNotes_ItemCommand(object source, RepeaterCommandEventArgs e) { var agencyNotesId = 0; if (e.CommandName == "Delete") { try { agencyNotesId = Convert.ToInt32(e.CommandArgument); } catch { } var agencyNotes = AgencyViewBLL.AgencyNotesGetById(agencyNotesId); AgencyViewBLL.DeleteAgencyNotes(agencyNotes); } Response.Redirect(Request.RawUrl); }
protected void Page_Unload(object sender, EventArgs e) { if (agencyViewBLL != null) { agencyViewBLL.Dispose(); agencyViewBLL = null; } if (userBLL != null) { userBLL.Dispose(); userBLL = null; } if (permissionBLL != null) { permissionBLL.Dispose(); permissionBLL = null; } }
public Aspose.Words.Document GetGeneratedQuotation(AgencyContract agencyContract) { Quotation quotation = null; if (agencyContract != null) { //quotation = agencyContract.Quotation; } else { var selectedQuotation = -1; try { //selectedQuotation = Int32.Parse(ddlQuotationTemplate.SelectedValue); } catch { } quotation = AgencyViewBLL.QuotationGetById(selectedQuotation); } var doc = new Aspose.Words.Document(Server.MapPath("ExportTemplates/Quotation.doc")); var textValidFromDate = ""; try { textValidFromDate = quotation.ValidFrom.Value.ToString("dd/MM/yyyy"); } catch { } var textValidToDate = ""; try { textValidToDate = quotation.ValidTo.Value.ToString("dd/MM/yyyy"); } catch { } doc.Range.Replace(new Regex("(\\[ValidFromDate\\])"), textValidFromDate); doc.Range.Replace(new Regex("(\\[ValidToDate\\])"), textValidToDate); return(doc); }
protected void Page_Load(object sender, EventArgs e) { _editPermission = Module.PermissionCheck(Permission.ACTION_EDITAGENCY, UserIdentity); _viewBookingPermission = Module.PermissionCheck("VIEWBOOKINGBYAGENCY", UserIdentity); _contactsPermission = Module.PermissionCheck("CONTACTS", UserIdentity); _recentActivitiesPermission = Module.PermissionCheck("RECENTACTIVITIES", UserIdentity); _contractsPermission = Module.PermissionCheck("CONTRACTS", UserIdentity); if (!IsPostBack) { if (Request.QueryString["agencyid"] != null) { var agency = Module.AgencyGetById(Convert.ToInt32(Request.QueryString["agencyid"])); if (agency.Sale == UserIdentity) { _editPermission = true; } litName1.Text = agency.Name; litName.Text = agency.Name; litTradingName.Text = agency.TradingName; litRepresentative.Text = agency.Representative; litRepresentativePosition.Text = agency.RepresentativePosition; litContact.Text = agency.Contact; litContactAddress.Text = agency.ContactAddress; litContactEmail.Text = agency.ContactEmail; litContactPosition.Text = agency.ContactPosition; if (agency.QAgentlevel != null) { litAgentLevel.Text = agency.QAgentlevel.Name; } litWebsite.Text = !String.IsNullOrEmpty(agency.Website) ? "<a href = " + agency.Website + ">" + agency.Website + "</a>" : ""; if (agency.Role != null) { litRole.Text = agency.Role.Name; } else { litRole.Text = "Customize Role"; } if (agency.Sale != null) { litSale.Text = agency.Sale.AllName; } else { litSale.Text = @"Unbound"; } litTax.Text = agency.TaxCode; if (agency.Location != null) { litLocation.Text = agency.Location.Name; } litAddress.Text = agency.Address; if (!string.IsNullOrEmpty(agency.Email)) { hplEmail.NavigateUrl = string.Format("mailto:{0}", agency.Email); hplEmail.Text = agency.Email; } litPhone.Text = agency.Phone; litPayment.Text = agency.PaymentPeriod.ToString(); litNote.Text = agency.Description; var agencyId = Agency.Id; rptContracts.DataSource = AgencyViewBLL.AgencyContractGetAllByAgency(agencyId); rptContracts.DataBind(); rptContacts.DataSource = Module.ContactGetByAgency(agency, !_editPermission); // nếu không có quyền edit thì ko có quyền view rptContacts.DataBind(); hplEditAgency.Visible = _editPermission; hplEditAgency.NavigateUrl = string.Format("AgencyEdit.aspx?NodeId={0}&SectionId={1}&agencyid={2}", Node.Id, Section.Id, agency.Id); hplAddContact.Visible = _editPermission; hplAddContact.NavigateUrl = "javascript:"; string url = string.Format("AgencyContactEdit.aspx?NodeId={0}&SectionId={1}&agencyid={2}", Node.Id, Section.Id, agency.Id); hplAddContact.Attributes.Add("onclick", CMS.ServerControls.Popup.OpenPopupScript(url, "Contact", 300, 400)); url = string.Format("AgencyContractEdit.aspx?NodeId={0}&SectionId={1}&agencyid={2}", Node.Id, Section.Id, agency.Id); hplBookingList.NavigateUrl = string.Format( "BookingList.aspx?NodeId={0}&SectionId={1}&ai={2}", Node.Id, Section.Id, agency.Id); hplReceivable.NavigateUrl = string.Format("PaymentReport.aspx?NodeId={0}&SectionId={1}&ai={2}&from={3}&to={4}", Node.Id, Section.Id, agency.Id, DateTime.Today.AddMonths(-3).ToOADate(), DateTime.Today.ToOADate()); rptActivities.DataSource = Module.GetObject <Activity>(Expression.And(Expression.Eq("ObjectType", "MEETING"), Expression.Eq("Params", Convert.ToString(agency.Id))), 0, 0, Order.Desc("DateMeeting")); rptActivities.DataBind(); } } LoadContracts(); RenderViewBookingByThisAgency(); RenderContacts(); RenderRecentActivities(); RenderContracts(); ddlContractTemplate.DataSource = AgencyViewBLL.ContractGetAll(); ddlContractTemplate.DataTextField = "Name"; ddlContractTemplate.DataValueField = "Id"; ddlContractTemplate.DataBind(); //ddlQuotationTemplate.DataSource = AgencyViewBLL.QuotationGetAll(); //ddlQuotationTemplate.DataTextField = "Name"; //ddlQuotationTemplate.DataValueField = "Id"; //ddlQuotationTemplate.DataBind(); ddlCruise.DataSource = AgencyViewBLL.CruiseGetAll(); ddlCruise.DataTextField = "Name"; ddlCruise.DataValueField = "Id"; ddlCruise.DataBind(); var agencyNotes = AgencyViewBLL.AgencyNotesGetAllByAgency(Agency); rptAgencyNotes.DataSource = agencyNotes.OrderBy(an => an.Role.Id); rptAgencyNotes.DataBind(); var roles = AgencyViewBLL.RolesGetAll(); ddlAgencyNotesRole.DataSource = roles.Where(r => r.IsUsedInAgencyNotes == true); ddlAgencyNotesRole.DataTextField = "Name"; ddlAgencyNotesRole.DataValueField = "Id"; ddlAgencyNotesRole.DataBind(); }
protected void btnSave_Click(object sender, EventArgs e) { var uploadPath = ""; var contentType = ""; if (fuAttachment.HasFile) { var fileName = DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + Guid.NewGuid().ToString(); var fileExtension = new FileInfo(fuAttachment.FileName).Extension; var fullFileName = fileName + fileExtension; uploadPath = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Upload/"), fullFileName); fuAttachment.SaveAs(uploadPath); contentType = fuAttachment.PostedFile.ContentType; } var agencyContactId = 0; try { agencyContactId = Int32.Parse(hidAgencyContactId.Value); } catch { } var agencyContact = AgencyViewBLL.AgencyContactGetById(agencyContactId); var dateMeeting = new DateTime(); try { dateMeeting = DateTime.ParseExact(txtDateMeeting.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch { } var problems = ""; Cruise cruise = null; if (ddlType.SelectedValue == "Problem Report") { if (chkBus.Checked) { problems += "Bus,"; } if (chkCabin.Checked) { problems += "Cabin,"; } if (chkGuide.Checked) { problems += "Guide,"; } if (chkFood.Checked) { problems += "Food,"; } if (chkOthers.Checked) { problems += "Others,"; } problems = problems.TrimEnd(new char[] { ',' }); var cruiseId = 0; try { cruiseId = Int32.Parse(ddlCruise.SelectedValue); } catch { } cruise = AgencyViewBLL.CruiseGetById(cruiseId); } var activityId = 0; try { activityId = Int32.Parse(hidActivityId.Value); } catch { } var activity = AgencyViewBLL.ActivityGetById(activityId); if (activity == null || activity.Id == 0) { activity = new Activity(); activity.Params = agencyContact != null && agencyContact.Agency != null?agencyContact.Agency.Id.ToString() : 0.ToString(); activity.Url = "AgencyView.aspx?NodeId=1&SectionId=15&agencyid=" + agencyContact != null && agencyContact.Agency != null?agencyContact.Agency.Id.ToString() : 0.ToString(); activity.ObjectId = agencyContact != null ? agencyContact.Id : 0; } activity.UpdateTime = DateTime.Now; activity.Time = DateTime.Now; activity.DateMeeting = dateMeeting; activity.Note = txtNote.Text; activity.ObjectType = "MEETING"; activity.User = CurrentUser; activity.Level = ImportantLevel.Important; activity.Type = ddlType.SelectedValue; activity.NeedManagerAttention = chkNeedManagerAttention.Checked; activity.Attachment = uploadPath == "" ? activity.Attachment : uploadPath; activity.AttachmentContentType = contentType == "" ? activity.AttachmentContentType : contentType; activity.Problems = problems; activity.Cruise = cruise; AgencyViewBLL.ActivitySaveOrUpdate(activity); Response.Redirect(Request.RawUrl); }