protected void Page_Load(object sender, EventArgs e) { //Grab the Organization Code from the url www.url/Customer.aspx?OrgCode={0} CustomerID = Request.QueryString["CustomerID"]; //Set customer to be the one from the Database customer = siftaDB.Customers.FirstOrDefault(p => p.CustomerID.ToString() == CustomerID); //If the customer is not valid send them back to the Default Page if (customer == null) { Response.Redirect("Default.aspx"); } //Set the User to be a User from this OrgCode for Permissions user = new User(customer.Center.OrgCode); //Set the Session variable Title Session["Title"] = customer.Center.Name.Replace(" Water Science Center", " "); //Set Customer Logo Source imgCustLogo.ImageUrl = String.Format("https://sifta.water.usgs.gov/Services/REST/Customer/CustomerIcon.ashx?CustomerID={0}", CustomerID); //Set the target folder for the image uploader var dir = FileDirectoryHelper.GetTempDirectory(); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } rauImage.TargetFolder = dir; if (user.CanInsert) { pnlCopyAgreeement.Visible = true; } if (user.CanUpdate && !Page.IsPostBack) { rtsCustomerOptions.Tabs.Add(new RadTab() { Text = "Edit Customer", TabIndex = 2 }); //Check for Texas Users Only /*if (customer.Center.CoopDBAccess) * { * rtsCustomerOptions.Tabs.Add(new RadTab() { Text = "Account Funding", TabIndex = 3 }); * }*/ } //Set the search box to be a blank list rsbCoopFunding.DataSource = new List <string>(); //Initialize if (!IsPostBack) { initializeTabStrip(rtsCustomerOptions, rmpCustomerOptions); PageDataBind(); } }
/// <summary> /// Takes a user control and maps the values from it to a customer object. /// The user control being used is the Customer.ascx. /// Found at Controls/Customer.ascx /// </summary> /// <param name="uc">The User Control for editing customer information</param> /// <param name="c">The Customer Object</param> protected void GrabValuesFromUserControl(UserControl uc, ref Customer c) { #region User Controls //Grab the controls from the user controls var rauImage = (uc.FindControl("rauImage") as RadAsyncUpload); var rtbCustomerCd = (uc.FindControl("rtbCustomerCd") as RadTextBox); var rcbAgreementType = (uc.FindControl("rcbAgreementType") as RadComboBox); var rntbCustomerNo = (uc.FindControl("rntbCustomerNo") as RadNumericTextBox); var rtbCustomerName = (uc.FindControl("rtbCustomerName") as RadTextBox); var rtbCustomerAbbrev = (uc.FindControl("rtbCustomerAbbrev") as RadTextBox); var rtbCustomerUrl = (uc.FindControl("rtbCustomerUrl") as RadTextBox); var rtbRemarks = (uc.FindControl("rtbRemarks") as RadTextBox); var rtbCustomerTin = (uc.FindControl("rtbCustomerTin") as RadTextBox); var racbTags = (uc.FindControl("racbTags") as RadAutoCompleteBox); #endregion #region Assign Values c.OrgCode = center.OrgCode; c.Code = rtbCustomerCd.Text; //If the combo box had a selected value convert it to int and store it as the customer agreement type. If not set the agreementtypeID to null if (!String.IsNullOrEmpty(rcbAgreementType.SelectedValue)) { c.CustomerAgreementTypeID = Convert.ToInt32(rcbAgreementType.SelectedValue); } else { c.CustomerAgreementTypeID = null; } //c.CustomerAgreementTypeID = null; //Convert double to long to store in db if (rntbCustomerNo.Value != null) { c.Number = Convert.ToInt64(rntbCustomerNo.Value); } else { c.Number = null; } c.Name = rtbCustomerName.Text; c.Abbreviation = rtbCustomerAbbrev.Text; c.URL = rtbCustomerUrl.Text; c.Remarks = rtbRemarks.Text; c.TaxIdentificationNumber = rtbCustomerTin.Text; //Set the Created and Modified date and by fields if (c.CreatedDate == null) { c.CreatedBy = c.ModifiedBy = user.ID; c.CreatedDate = c.ModifiedDate = DateTime.Now; } else { c.ModifiedDate = DateTime.Now; c.ModifiedBy = user.ID; } #endregion #region Customer Image Upload //If a file was even uploaded if (rauImage.UploadedFiles.Count > 0) { foreach (UploadedFile file in rauImage.UploadedFiles) { var dir = FileDirectoryHelper.GetTempDirectory(); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var path = dir + file.FileName; if (File.Exists(path)) { c.IconType = file.ContentType; c.Icon = File.ReadAllBytes(path); File.Delete(path); } } } #endregion }