using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; namespace infoExpediters { public partial class addyourcompany : System.Web.UI.Page { AddCompany obj = new AddCompany(); protected void Page_Load(object sender, EventArgs e) { txtPriceListDate.Attributes.Add("readonly", "readonly"); if (!IsPostBack) { GetStates(); GetRegions(); GetPaperStates(); GetPartStates(); GetTimeZone(); GetCompanyNames(); } } //Display all states in drop down list public void GetStates() { try { DataSet ds = obj.GetStates(); ddlState.DataSource = ds.Tables["Codes"]; ddlState.DataTextField = "CodeName"; ddlState.DataValueField = "CodeValue"; ddlState.DataBind(); int val; val = 0; ddlState.Items.Insert(0, "[Select State]"); ddlState.Items[0].Value = val.ToString(); } catch (Exception ex) { string s1 = ex.Message; } } //Display regions in drop down list public void GetRegions() { try { DataSet ds = obj.GetRegions(); ddlRegions.DataSource = ds.Tables["Codes"]; ddlRegions.DataTextField = "CodeName"; ddlRegions.DataValueField = "CodeValue"; ddlRegions.DataBind(); int val; val = 0; ddlRegions.Items.Insert(0, "[Select Region]"); ddlRegions.Items[0].Value = val.ToString(); } catch (Exception ex) { string s2 = ex.Message; } } //Display all states in drop down list public void GetPartStates() { try { DataSet ds = obj.GetPartStates(); ddlPartsStateType.DataSource = ds.Tables["Codes"]; ddlPartsStateType.DataTextField = "CodeName"; ddlPartsStateType.DataValueField = "CodeValue"; ddlPartsStateType.DataBind(); int val; val = 0; ddlPartsStateType.Items.Insert(0, "[Select State]"); ddlPartsStateType.Items[0].Value = val.ToString(); } catch (Exception ex) { string s3 = ex.Message; } } //Display all states in drop down list public void GetPaperStates() { try { DataSet ds = obj.GetPaperStates(); ddlPaperStateType.DataSource = ds.Tables["Codes"]; ddlPaperStateType.DataTextField = "CodeName"; ddlPaperStateType.DataValueField = "CodeValue"; ddlPaperStateType.DataBind(); int val; val = 0; ddlPaperStateType.Items.Insert(0, "[Select State]"); ddlPaperStateType.Items[0].Value = val.ToString(); } catch (Exception ex) { string s4 = ex.Message; } } //Display all time zones in drop down list public void GetTimeZone() { try { DataSet ds = obj.GetTimeZone(); ddlTimeZoneCode.DataSource = ds.Tables["Codes"]; ddlTimeZoneCode.DataTextField = "CodeName"; ddlTimeZoneCode.DataValueField = "CodeValue"; ddlTimeZoneCode.DataBind(); int val; val = 0; ddlTimeZoneCode.Items.Insert(0, "[Select TimeZone]"); ddlTimeZoneCode.Items[0].Value = val.ToString(); } catch (Exception ex) { string s5 = ex.Message; } } //Display all parent companys public void GetCompanyNames() { try { DataSet ds = obj.GetCompanyNames(); ddlCompanyParent.DataSource = ds.Tables["Company"]; ddlCompanyParent.DataTextField = "CompanyName"; ddlCompanyParent.DataValueField = "CompanyId"; ddlCompanyParent.DataBind(); int val; val = 0; ddlCompanyParent.Items.Insert(0, "[None]"); ddlCompanyParent.Items[0].Value = val.ToString(); } catch (Exception ex) { string s6 = ex.Message; } } //save company details protected void btnSubmit_Click(object sender, EventArgs e) { try { Hashtable ht = new Hashtable(); ht.Add("@companyname", txtCompanyName.Text.Trim()); ht.Add("@tag", txtCompanyTag.Text.Trim()); ht.Add("@parentcompanyid", ddlCompanyParent.SelectedItem.Value.ToString()); ht.Add("@address1", txtAddress1.Text.Trim()); ht.Add("@address2", txtAddress2.Text.Trim()); ht.Add("@city", txtCity.Text.Trim()); ht.Add("@statetype", ddlState.SelectedItem.Value.ToString()); ht.Add("@zip", txtZip.Text.Trim()); ht.Add("@paperaddress1", txtPaperAddress1.Text.Trim()); ht.Add("@paperaddress2", txtPaperAddress2.Text.Trim()); ht.Add("@papercity", txtPaperCity.Text.Trim()); ht.Add("@paperstatetype", ddlPaperStateType.SelectedItem.Value.ToString()); ht.Add("@paperzip", txtPaperZip.Text.Trim()); ht.Add("@partsaddress1", txtPartsAddress1.Text.Trim()); ht.Add("@partsaddress2", txtPartsAddress2.Text.Trim()); ht.Add("@partscity", txtPartsCity.Text.Trim()); ht.Add("@partsstatetype", ddlPartsStateType.SelectedItem.Value.ToString()); ht.Add("@partszip", txtPartsZip.Text.Trim()); ht.Add("@shippingcutofftime", txtShippingCutOffTime.Text.Trim()); ht.Add("@timezonecode", ddlTimeZoneCode.SelectedItem.Value.ToString()); ht.Add("@companyphonearea", txtPh1.Text.Trim()); ht.Add("@companyphonepre", txtPh2.Text.Trim()); ht.Add("@companyphonesuffix", txtPh3.Text.Trim()); ht.Add("@companyfaxarea", txtFax1.Text.Trim()); ht.Add("@companyfaxpre", txtFax2.Text.Trim()); ht.Add("@companyfaxsuffix", txtFax3.Text.Trim()); ht.Add("@companyTollarea", txttf1.Text.Trim()); ht.Add("@companyTollpre", txttf2.Text.Trim()); ht.Add("@companyTollsuffix", txttf3.Text.Trim()); ht.Add("@companyTecharea", txtTechPh1.Text.Trim()); ht.Add("@companyTechpre", txtTechPh2.Text.Trim()); ht.Add("@companyTechsuffix", txtTechPh3.Text.Trim()); ht.Add("@companyCSarea", txtCustomerNo1.Text.Trim()); ht.Add("@companyCSpre", txtCustomerNo2.Text.Trim()); ht.Add("@companyCSsuffix", txtCustomerNo3.Text.Trim()); ht.Add("@webSite", txtWebsite.Text.Trim()); ht.Add("@emailId", txtEmail.Text.Trim()); ht.Add("@pricelist", txtPriceList.Text.Trim()); ht.Add("@keywords", txtKeywords.Text.Trim()); ht.Add("@pricelistdate", txtPriceListDate.Text.Trim()); ht.Add("@Status", "0"); ht.Add("@CompanyId", "0"); ht.Add("@CompanyIdValue", "0"); ht.Add("@logoUrl", fu1.FileName.ToString()); ht.Add("@string", hdnRegions.Value); Hashtable ht1 = new Hashtable(); ht1 = obj.InsertData(ht); if (ht1["status"].ToString() == "0") { lbErrorMessage.Text = "Company name already exist"; } else { if ((fu1.PostedFile != null) && (fu1.PostedFile.ContentLength > 0)) { string filepath = Request.PhysicalApplicationPath + "CompanyLogos"; string strFileName = System.IO.Path.GetFileNameWithoutExtension(fu1.PostedFile.FileName) + "_" + ht1["companyid"].ToString() + System.IO.Path.GetExtension(fu1.PostedFile.FileName); fu1.PostedFile.SaveAs(filepath + ("\\" + strFileName)); lbMessage.Text = "uploaded successfully...."; } else { lbMessage.Text = "uploaded failed"; } Response.Redirect("Message.aspx", false); } } catch (Exception ex) { string s = ex.Message; } } } }