private void BindGridView() { int count; SalesRepresentativeReportingChild obj = new SalesRepresentativeReportingChild(); string companyName = ddlCompanyName.SelectedValue.ToString(); string lastName = ddlSalesRepLastName.SelectedValue.ToString(); string salesRepTypeName = ddlSalesRepTypeName.SelectedValue.ToString(); string territoryName = ddlTerritoryName.SelectedValue.ToString(); string regionName = ddlRegionName.SelectedValue.ToString(); // string distributionRegionName = ddlDistributionRegionName.SelectedValue.ToString(); string subBusinessUnitName = ddlSubBusinessUnitName.SelectedValue.ToString(); string businessUnitName = ddlBusinessUnitName.SelectedValue.ToString(); DataSet ds = obj.GetSKPickingBoard2(lastName, salesRepTypeName, territoryName, regionName, subBusinessUnitName, businessUnitName, companyName);//distributionRegionName, SalesRepresentativeGridView.DataSource = ds.Tables[0]; SalesRepresentativeGridView.DataBind(); count = ds.Tables[0].Rows.Count; if (count > 1) { lblRecordCount.Text = "Record Count: " + count; } else { lblRecordCount.Text = "Record Count: " + count; } }
protected void OnSelectedTypeIndexChanged(object sender, EventArgs e) { string territoryName = newTerritoryName.SelectedValue.ToString(); SalesRepresentativeReportingChild li = new SalesRepresentativeReportingChild(); newBusinessUnitName.Items.Clear(); newBusinessUnitName.Items.Insert(0, new ListItem("Select One")); newBusinessUnitName.DataSource = li.NewBusinessUnitNameList(territoryName).Tables[0]; newBusinessUnitName.DataTextField = "BusinessUnitName"; newBusinessUnitName.DataBind(); newSubBusinessUnitName.Items.Clear(); newSubBusinessUnitName.Items.Insert(0, new ListItem("Select One")); newSubBusinessUnitName.DataSource = li.NewSubBusinessUnitNameList(territoryName).Tables[0]; newSubBusinessUnitName.DataTextField = "SubBusinessUnitName"; newSubBusinessUnitName.DataBind(); newCompanyName.Items.Clear(); newCompanyName.Items.Insert(0, new ListItem("Select One")); newCompanyName.DataSource = li.NewCompanyNameList(territoryName).Tables[0]; newCompanyName.DataTextField = "CompanyName"; newCompanyName.DataBind(); newRegionName.Items.Clear(); newRegionName.Items.Insert(0, new ListItem("Select One")); newRegionName.DataSource = li.NewRegionNameList(territoryName).Tables[0]; newRegionName.DataTextField = "RegionName"; newRegionName.DataBind(); ModalPopupExtender1.Show(); }
protected void btnExportToExcel_Click(object sender, EventArgs e) { SalesRepresentativeReportingChild obj = new SalesRepresentativeReportingChild(); DataSet ds = obj.GetSKPickingBoard2("Select One", "Select One", "Select One", "Select One", "Select One", "Select One", "Select One");//, "Select One"); WorkbookEngine we = new WorkbookEngine(); we.ExportDataSetToExcel(ds.Tables[0], "Sales Representative Reporting"); }
protected void btnSaveNewSalesRepresentative_Click(object sender, EventArgs e) { bool isFormFilled = true; string display = ""; SalesRepresentativeReportingChild li = new SalesRepresentativeReportingChild(); li.SalesRepFirstName = newSalesRepFirstName.Text; li.SalesRepLastName = newSalesRepLastName.Text; li.Title = newTitle.Text; if (!String.IsNullOrEmpty(Convert.ToString((Request.Form[newHireDate.UniqueID])))) { li.HireDate = Convert.ToDateTime((Request.Form[newHireDate.UniqueID])); } if (!String.IsNullOrEmpty(Convert.ToString((Request.Form[newDemoSigned.UniqueID])))) { li.DemoSigned = Convert.ToDateTime((Request.Form[newDemoSigned.UniqueID])); } //if (!String.IsNullOrEmpty(Convert.ToString((Request.Form[newEffectiveDate.UniqueID])))) //{ // li.EffectiveDate = Convert.ToDateTime((Request.Form[newEffectiveDate.UniqueID])); //} if (!String.IsNullOrEmpty(Convert.ToString((Request.Form[newTerminationDate.UniqueID])))) { li.TerminationDate = Convert.ToDateTime((Request.Form[newTerminationDate.UniqueID])); } li.CustomerID = Convert.ToInt32(newCustomerNumber.Text); //li.VoiceMailPin = Convert.ToInt32(newVoiceMailPin.Text); li.Notes = newNotes.Text; // li.VendorID = newVendorNumber.Text; li.SalesRepCompanyName = newSalesRepCompany.Text; li.InventoryNotes = newInventoryNotes.Text; li.SalesRepTypeName = newSalesRepTypeName.SelectedValue.ToString(); li.TerritoryName = newTerritoryName.SelectedValue.ToString(); li.RegionName = newRegionName.SelectedValue.ToString(); li.DistributionRegionName = newDistributionRegionName.SelectedValue.ToString(); li.SubBusinessUnitName = newSubBusinessUnitName.SelectedValue.ToString(); li.BusinessUnitName = newBusinessUnitName.SelectedValue.ToString(); li.CompanyName = newCompanyName.SelectedValue.ToString(); li.Address1 = newAddress1.Text; li.Address2 = newAddress2.Text; li.Address3 = newAddress3.Text; li.City = newCity.Text; li.StateProvinceName = newStateProvinceName.SelectedValue.ToString(); li.PostalCode = newPostalCode.Text; li.CountryName = newCountryName.SelectedValue.ToString(); li.CustomerNumber = newCustomerNumber.Text; li.WorkPhone = newWorkPhone.Text; // li.VoiceMailExtension = newVoiceMailExtension.Text; //li.VoiceMailPin = newVoiceMailPin.Text; li.FaxNumber = newFaxNumber.Text; li.MobilePhone = newMobilePhone.Text; // li.Pager = newPager.Text; li.PersonalCellPhone = newPersonalCellPhone.Text; li.InternationalPhone = newInternationalPhone.Text; // li.InternationalFax = newInternationalFax.Text; li.InternationalCell = newInternationalCell.Text; li.PrimaryEmail = newPrimaryEmail.Text; li.SecondaryEmail = newSecondaryEmail.Text; //li.GlobalAddress = newGlobalAddress.SelectedValue.ToString(); if (String.IsNullOrEmpty(li.SalesRepFirstName) || String.IsNullOrEmpty(li.SalesRepLastName) || String.IsNullOrEmpty(li.SalesRepTypeName)) { display = "Please select all the mandatory fields "; ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); isFormFilled = false; } if (isFormFilled) { // DataSet result = li.AddNewSalesRepresentative(salesRepFirstName, salesRepLastName, title, hireDate, terminationDate, notes, vendorID, salesRepCompanyName, demoSigned, // effectiveDate, inventoryNotes, salesRepTypeName, territoryName, regionName, distributionRegionName, subBusinessUnitName, businessUnitName, companyName, address1, address2, address3, // city, stateProvinceName, postalCode, countryName, customerID, workPhone, voiceMailExtension, voiceMailPin, faxNumber, mobilePhone, pager, personalCellPhone, internationalPhone, internationalFax, // internationalCell, primaryEmail, secondaryEmail, globaladdress); DataSet result = li.AddNewSalesRepresentative(li); string res = Convert.ToString(result.Tables[0].Rows[0].ItemArray[0]); if (res.Equals("Customer Number does not exists")) { display = "Customer Number does not exists"; ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); isFormFilled = true; ModalPopupExtender1.Show(); } else if (res.Equals("PostalCode does not exists")) { display = "PostalCode does not exists"; ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); isFormFilled = true; ModalPopupExtender1.Show(); } else if (res.Equals("Success")) { display = "A new Sales Representative is successfully added in the database"; ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); isFormFilled = true; } if (isFormFilled) { newSalesRepFirstName.Text = ""; newSalesRepLastName.Text = ""; newTitle.Text = ""; newNotes.Text = ""; // newVendorNumber.Text = ""; newSalesRepCompany.Text = ""; newInventoryNotes.Text = ""; newSalesRepTypeName.SelectedIndex = 0; newTerritoryName.SelectedIndex = 0; BindGridView(); } } }
protected void SalesRepresentative_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow && SalesRepresentativeGridView.EditIndex == e.Row.RowIndex) { SalesRepresentativeReportingChild li = new SalesRepresentativeReportingChild(); //Find the DropDownList in the Row DropDownList ddlSalesRepTypeNameList = (e.Row.FindControl("SalesRepTypeName") as DropDownList); ddlSalesRepTypeNameList.DataSource = li.SalesRepTypeNameList().Tables[0]; ddlSalesRepTypeNameList.DataTextField = "SalesRepTypeName"; ddlSalesRepTypeNameList.DataValueField = "SalesRepTypeName"; ddlSalesRepTypeNameList.DataBind(); //Add Default Item in the DropDownList ddlSalesRepTypeNameList.Items.Insert(0, new ListItem("Select One")); //Select the Country of Customer in DropDownList string salesRepTypeNames = (e.Row.FindControl("lblSalesRepTypeName") as Label).Text; ddlSalesRepTypeNameList.Items.FindByValue(salesRepTypeNames).Selected = true; //Find the DropDownList in the Row DropDownList ddlTerritoryNameList = (e.Row.FindControl("TerritoryName") as DropDownList); ddlTerritoryNameList.DataSource = li.TerritoryNameList().Tables[0]; ddlTerritoryNameList.DataTextField = "TerritoryName"; ddlTerritoryNameList.DataValueField = "TerritoryName"; ddlTerritoryNameList.DataBind(); //Add Default Item in the DropDownList ddlTerritoryNameList.Items.Insert(0, new ListItem("Select One")); //Select the Country of Customer in DropDownList string territoryNames = (e.Row.FindControl("lblTerritoryName") as Label).Text; ListItem item = ddlTerritoryNameList.Items.FindByValue(territoryNames); if (item != null) { ddlTerritoryNameList.SelectedValue = territoryNames; } //Find the DropDownList in the Row DropDownList ddlRegionNameList = (e.Row.FindControl("RegionName") as DropDownList); ddlRegionNameList.DataSource = li.RegionNameList().Tables[0]; ddlRegionNameList.DataTextField = "RegionName"; ddlRegionNameList.DataValueField = "RegionName"; ddlRegionNameList.DataBind(); //Add Default Item in the DropDownList ddlRegionNameList.Items.Insert(0, new ListItem("Select One")); //Select the Country of Customer in DropDownList string regionNames = (e.Row.FindControl("lblRegionName") as Label).Text; ListItem item1 = ddlRegionNameList.Items.FindByValue(regionNames); if (item1 != null) { ddlRegionNameList.SelectedValue = regionNames; } //DropDownList ddlDistributionRegionNameList = (e.Row.FindControl("DistributionRegionName") as DropDownList); //ddlDistributionRegionNameList.DataSource = li.DistributionRegionNameList().Tables[0]; //ddlDistributionRegionNameList.DataTextField = "DistributionRegionName"; //ddlDistributionRegionNameList.DataValueField = "DistributionRegionName"; //ddlDistributionRegionNameList.DataBind(); ////Add Default Item in the DropDownList //ddlDistributionRegionNameList.Items.Insert(0, new ListItem("Select One")); ////Select the Country of Customer in DropDownList //string distributionRegionNames = (e.Row.FindControl("lblDistributionRegionName") as Label).Text; //ddlDistributionRegionNameList.Items.FindByValue(distributionRegionNames).Selected = true; //Find the DropDownList in the Row DropDownList ddlSubBusinessUnitNameList = (e.Row.FindControl("SubBusinessUnitName") as DropDownList); ddlSubBusinessUnitNameList.DataSource = li.SubBusinessUnitNameList().Tables[0]; ddlSubBusinessUnitNameList.DataTextField = "SubBusinessUnitName"; ddlSubBusinessUnitNameList.DataValueField = "SubBusinessUnitName"; ddlSubBusinessUnitNameList.DataBind(); //Add Default Item in the DropDownList ddlSubBusinessUnitNameList.Items.Insert(0, new ListItem("Select One")); //Select the Country of Customer in DropDownList string subBusinessUnitNames = (e.Row.FindControl("lblSubBusinessUnitName") as Label).Text; ListItem item2 = ddlSubBusinessUnitNameList.Items.FindByValue(subBusinessUnitNames); if (item2 != null) { ddlSubBusinessUnitNameList.SelectedValue = subBusinessUnitNames; } //Find the DropDownList in the Row DropDownList ddlBusinessUnitNameList = (e.Row.FindControl("BusinessUnitName") as DropDownList); ddlBusinessUnitNameList.DataSource = li.BusinessUnitNameList().Tables[0]; ddlBusinessUnitNameList.DataTextField = "BusinessUnitName"; ddlBusinessUnitNameList.DataValueField = "BusinessUnitName"; ddlBusinessUnitNameList.DataBind(); //Add Default Item in the DropDownList ddlBusinessUnitNameList.Items.Insert(0, new ListItem("Select One")); //Select the Country of Customer in DropDownList string businessUnitNames = (e.Row.FindControl("lblBusinessUnitName") as Label).Text; ListItem item3 = ddlBusinessUnitNameList.Items.FindByValue(businessUnitNames); if (item3 != null) { ddlBusinessUnitNameList.SelectedValue = businessUnitNames; } //Find the DropDownList in the Row DropDownList ddlCompanyNameList = (e.Row.FindControl("CompanyName") as DropDownList); ddlCompanyNameList.DataSource = li.CompanyNameList().Tables[0]; ddlCompanyNameList.DataTextField = "CompanyName"; ddlCompanyNameList.DataValueField = "CompanyName"; ddlCompanyNameList.DataBind(); //Add Default Item in the DropDownList ddlCompanyNameList.Items.Insert(0, new ListItem("Select One")); //Select the Country of Customer in DropDownList string companyNames = (e.Row.FindControl("lblCompanyName") as Label).Text; ddlCompanyNameList.Items.FindByValue(companyNames).Selected = true; } }
protected void SalesRepresentative_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (Page.IsValid) { SalesRepresentativeReportingChild li = new SalesRepresentativeReportingChild(); GridViewRow row = SalesRepresentativeGridView.Rows[e.RowIndex]; string display = ""; bool isFormFilled = true; try { li.SalesRepContactID = Convert.ToInt32(SalesRepresentativeGridView.DataKeys[e.RowIndex].Values[0]); li.SalesRepFirstName = Convert.ToString(((TextBox)row.FindControl("SalesRepFirstName")).Text); li.SalesRepLastName = Convert.ToString(((TextBox)row.FindControl("SalesRepLastName")).Text); //if (((TextBox)row.FindControl("SalesRepFirstName")).Text != string.Empty) //{ // li.SalesRepFirstName = Convert.ToString(((TextBox)row.FindControl("SalesRepFirstName")).Text); //} //else //{ // display = "SalesRep FirstName cannot be empty"; // ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); // isFormFilled = false; //} //if (((TextBox)row.FindControl("SalesRepLastName")).Text != string.Empty) //{ // li.SalesRepLastName = Convert.ToString(((TextBox)row.FindControl("SalesRepLastName")).Text); //} //else //{ // display = "SalesRep LastName cannot be empty"; // ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); // isFormFilled = false; //} if (((TextBox)row.FindControl("Title")).Text != string.Empty) { li.Title = Convert.ToString(((TextBox)row.FindControl("Title")).Text); } if (((TextBox)row.FindControl("Notes")).Text != string.Empty) { li.Notes = Convert.ToString(((TextBox)row.FindControl("Notes")).Text); } if (((TextBox)row.FindControl("InventoryNotes")).Text != string.Empty) { li.InventoryNotes = Convert.ToString(((TextBox)row.FindControl("InventoryNotes")).Text); } if (((TextBox)row.FindControl("WorkPhone")).Text != string.Empty) { li.WorkPhone = Convert.ToString(((TextBox)row.FindControl("WorkPhone")).Text); } if (((TextBox)row.FindControl("Address1")).Text != string.Empty) { li.Address1 = Convert.ToString(((TextBox)row.FindControl("Address1")).Text); } if (((TextBox)row.FindControl("Address2")).Text != string.Empty) { li.Address2 = Convert.ToString(((TextBox)row.FindControl("Address2")).Text); } if (((TextBox)row.FindControl("Address3")).Text != string.Empty) { li.Address3 = Convert.ToString(((TextBox)row.FindControl("Address3")).Text); } if (!String.IsNullOrEmpty(Convert.ToString((Request.Form[row.FindControl("DemoSigned").UniqueID])))) { li.DemoSigned = Convert.ToDateTime((Request.Form[row.FindControl("DemoSigned").UniqueID])); } if (((TextBox)row.FindControl("SalesRepCompanyName")).Text != string.Empty) { li.SalesRepCompanyName = Convert.ToString(((TextBox)row.FindControl("SalesRepCompanyName")).Text); } if (((DropDownList)row.FindControl("CompanyName")).SelectedValue != "Select One") { li.CompanyName = ((DropDownList)row.FindControl("CompanyName")).SelectedValue; } else { display = "CompanyName from dropdown"; ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); isFormFilled = false; } if (((DropDownList)row.FindControl("SalesRepTypeName")).SelectedValue != "Select One") { li.SalesRepTypeName = ((DropDownList)row.FindControl("SalesRepTypeName")).SelectedValue; } else { display = "Select SalesRepTypeName from dropdown"; ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); isFormFilled = false; } if (((DropDownList)row.FindControl("TerritoryName")).SelectedValue != "Select One") { li.TerritoryName = ((DropDownList)row.FindControl("TerritoryName")).SelectedValue; } //else //{ // display = "Select TerritoryName from dropdown"; // ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); // isFormFilled = false; //} if (((DropDownList)row.FindControl("RegionName")).SelectedValue != "Select One") { li.RegionName = ((DropDownList)row.FindControl("RegionName")).SelectedValue; } else { display = "Select RegionName from dropdown"; ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); isFormFilled = false; } if (((DropDownList)row.FindControl("SubBusinessUnitName")).SelectedValue != "Select One") { li.SubBusinessUnitName = ((DropDownList)row.FindControl("SubBusinessUnitName")).SelectedValue; } else { display = "Select SubBusinessUnitName from dropdown"; ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); isFormFilled = false; } if (((DropDownList)row.FindControl("BusinessUnitName")).SelectedValue != "Select One") { li.BusinessUnitName = ((DropDownList)row.FindControl("BusinessUnitName")).SelectedValue; } else { display = "Select BusinessUnitName from dropdown"; ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); isFormFilled = false; } if (((TextBox)row.FindControl("FaxNumber")).Text != string.Empty) { li.FaxNumber = Convert.ToString(((TextBox)row.FindControl("FaxNumber")).Text); } if (((TextBox)row.FindControl("MobilePhone")).Text != string.Empty) { li.MobilePhone = Convert.ToString(((TextBox)row.FindControl("MobilePhone")).Text); } if (((TextBox)row.FindControl("PersonalCellPhone")).Text != string.Empty) { li.PersonalCellPhone = Convert.ToString(((TextBox)row.FindControl("PersonalCellPhone")).Text); } if (((TextBox)row.FindControl("InternationalPhone")).Text != string.Empty) { li.InternationalPhone = Convert.ToString(((TextBox)row.FindControl("InternationalPhone")).Text); } if (((TextBox)row.FindControl("InternationalCell")).Text != string.Empty) { li.InternationalCell = Convert.ToString(((TextBox)row.FindControl("InternationalCell")).Text); } if (((TextBox)row.FindControl("PrimaryEmail")).Text != string.Empty) { li.PrimaryEmail = Convert.ToString(((TextBox)row.FindControl("PrimaryEmail")).Text); } //else //{ // display = "PrimaryEmail cannot be empty"; // ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); // isFormFilled = false; //} if (((TextBox)row.FindControl("SecondaryEmail")).Text != string.Empty) { li.SecondaryEmail = Convert.ToString(((TextBox)row.FindControl("SecondaryEmail")).Text); } if (!String.IsNullOrEmpty(Convert.ToString((Request.Form[row.FindControl("DemoSigned").UniqueID])))) { li.DemoSigned = Convert.ToDateTime((Request.Form[row.FindControl("DemoSigned").UniqueID])); } if (!String.IsNullOrEmpty(Convert.ToString((Request.Form[row.FindControl("HireDate").UniqueID])))) { li.HireDate = Convert.ToDateTime((Request.Form[row.FindControl("HireDate").UniqueID])); } //else //{ // display = "Hire Date cannot be empty"; // ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); // isFormFilled = false; //} if (!String.IsNullOrEmpty(Convert.ToString((Request.Form[row.FindControl("TerminationDate").UniqueID])))) { li.TerminationDate = Convert.ToDateTime((Request.Form[row.FindControl("TerminationDate").UniqueID])); } //else //{ // display = "Termination Date cannot be empty"; // ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); // isFormFilled = false; //} if (li.HireDate > li.TerminationDate) { display = "Termination Date must be after Hire date"; ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); isFormFilled = false; } if (isFormFilled) { DataSet result = li.UpdateSKPickingBoard(li, memberships); string res = Convert.ToString(result.Tables[0].Rows[0].ItemArray[0]); //if (res.Equals("Duplicate CompanyKey")) //{ // display = "Company Key already exists in the database"; // ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); // isFormFilled = false; //} //else if (res.Equals("Duplicate CompanyName")) //{ // display = "Company Name already exists in the database"; // ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('" + display + "');", true); // isFormFilled = false; //} if (res.Equals("Success")) { } } } catch (Exception ex) { throw ex; } SalesRepresentativeGridView.EditIndex = -1; BindGridView(); } }
protected void Page_Load(object sender, EventArgs e) { //VBFunctions.ADFunctions obj = new VBFunctions.ADFunctions(); //string userID = obj.GetUserName(); //// string dirEntry = obj.GetDirectoryEntry(); //memberships = obj.VerifyGroupMemberships("LDAP://192.168.100.3/ou=Cooper Network Users,dc=coopersurgical1,dc=com", "webapps", "Yankees#1", userID); if (!Page.IsPostBack) { //if (memberships == 1 || memberships == 4) //{ SalesRepresentativeReportingChild li = new SalesRepresentativeReportingChild(); DataTable table = new DataTable(); ddlSalesRepLastName.DataSource = li.LastNameList().Tables[0]; ddlSalesRepLastName.DataTextField = "SalesRepLastName"; ddlSalesRepLastName.DataBind(); ddlSalesRepTypeName.DataSource = li.SalesRepTypeNameList().Tables[0]; ddlSalesRepTypeName.DataTextField = "SalesRepTypeName"; ddlSalesRepTypeName.DataBind(); newSalesRepTypeName.DataSource = ddlSalesRepTypeName.DataSource; newSalesRepTypeName.DataTextField = "SalesRepTypeName"; newSalesRepTypeName.DataBind(); ddlTerritoryName.DataSource = li.TerritoryNameList().Tables[0]; ddlTerritoryName.DataTextField = "TerritoryName"; ddlTerritoryName.DataBind(); newTerritoryName.DataSource = ddlTerritoryName.DataSource; newTerritoryName.DataTextField = "TerritoryName"; newTerritoryName.DataBind(); ddlRegionName.DataSource = li.RegionNameList().Tables[0]; ddlRegionName.DataTextField = "RegionName"; ddlRegionName.DataBind(); newRegionName.DataSource = ddlRegionName.DataSource; newRegionName.DataTextField = "RegionName"; newRegionName.DataBind(); ddlDistributionRegionName.DataSource = li.DistributionRegionNameList().Tables[0]; ddlDistributionRegionName.DataTextField = "DistributionRegionName"; ddlDistributionRegionName.DataBind(); newDistributionRegionName.DataSource = ddlDistributionRegionName.DataSource; newDistributionRegionName.DataTextField = "DistributionRegionName"; newDistributionRegionName.DataBind(); ddlSubBusinessUnitName.DataSource = li.SubBusinessUnitNameList().Tables[0]; ddlSubBusinessUnitName.DataTextField = "SubBusinessUnitName"; ddlSubBusinessUnitName.DataBind(); newSubBusinessUnitName.DataSource = ddlSubBusinessUnitName.DataSource; newSubBusinessUnitName.DataTextField = "SubBusinessUnitName"; newSubBusinessUnitName.DataBind(); ddlBusinessUnitName.DataSource = li.BusinessUnitNameList().Tables[0]; ddlBusinessUnitName.DataTextField = "BusinessUnitName"; ddlBusinessUnitName.DataBind(); newBusinessUnitName.DataSource = ddlBusinessUnitName.DataSource; newBusinessUnitName.DataTextField = "BusinessUnitName"; newBusinessUnitName.DataBind(); ddlCompanyName.DataSource = li.CompanyNameList().Tables[0]; ddlCompanyName.DataTextField = "CompanyName"; ddlCompanyName.DataBind(); newCompanyName.DataSource = ddlCompanyName.DataSource; newCompanyName.DataTextField = "CompanyName"; newCompanyName.DataBind(); newCountryName.DataSource = li.CountryNameList().Tables[0]; newCountryName.DataTextField = "CountryName"; newCountryName.DataBind(); newStateProvinceName.DataSource = li.StateProvinceNameList().Tables[0]; newStateProvinceName.DataTextField = "StateProvinceName"; newStateProvinceName.DataBind(); //newCustomerNumber.DataSource = li.CustomerNumberList().Tables[0]; //newCustomerNumber.DataTextField = "CustomerID"; //newCustomerNumber.DataBind(); BindGridView(); // } } }
// public DataSet AddNewSalesRepresentative(string salesRepFirstName, string salesRepLastName, string title, string hireDate, string terminationDate, // string notes, string vendorID, string salesRepCompanyName, string demoSigned, string effectiveDate, string inventoryNotes, string salesRepTypeName, // string territoryName, string regionName, string distributionRegionName, string subBusinessUnitName, string businessUnitName, string companyName, string address1, // string address2, string address3, string city, string stateProvinceName, string postalCode, string countryName, string customerID, string workPhone, string voiceMailExtension, // string voiceMailPin, string faxNumber, string mobilePhone, string pager, string personalCellPhone, string internationalPhone, string internationalFax, string internationalCell, // string primaryEmail, string secondaryEmail, string globaladdress) public DataSet AddNewSalesRepresentative(SalesRepresentativeReportingChild li) { DataSet ds = new DataSet(); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString())) try { using (SqlCommand cmd = new SqlCommand("dbo.Web_SR_AddNewSalesRepresentative", connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("SalesRepFirstName", li.SalesRepFirstName); cmd.Parameters.AddWithValue("SalesRepLastName", li.SalesRepLastName); if (!String.IsNullOrEmpty(li.Title)) { cmd.Parameters.AddWithValue("Title", li.Title); } // if (!String.IsNullOrEmpty(li.CustomerNumber)) cmd.Parameters.AddWithValue("CustomerNumber", li.CustomerNumber); if (!String.IsNullOrEmpty(li.SalesRepTypeName)) { cmd.Parameters.AddWithValue("SalesRepTypeName", li.SalesRepTypeName); } if (!String.IsNullOrEmpty(li.SalesRepCompanyName)) { cmd.Parameters.AddWithValue("SalesRepCompanyName", li.SalesRepCompanyName); } if (!String.IsNullOrEmpty(li.Address1)) { cmd.Parameters.AddWithValue("Address1", li.Address1); } if (!String.IsNullOrEmpty(li.Address2)) { cmd.Parameters.AddWithValue("Address2", li.Address2); } if (!String.IsNullOrEmpty(li.Address3)) { cmd.Parameters.AddWithValue("Address3", li.Address3); } if (!String.IsNullOrEmpty(li.City)) { cmd.Parameters.AddWithValue("City", li.City); } if (!String.IsNullOrEmpty(li.StateProvinceName)) { cmd.Parameters.AddWithValue("StateProvinceName", li.StateProvinceName); } //if (!String.IsNullOrEmpty(li.PostalCode)) cmd.Parameters.AddWithValue("PostalCode", li.PostalCode); if (!String.IsNullOrEmpty(li.CountryName)) { cmd.Parameters.AddWithValue("CountryName", li.CountryName); } // if (li.HireDate != DateTime.MinValue) cmd.Parameters.AddWithValue("HireDate", li.HireDate); if (li.TerminationDate != DateTime.MinValue) { cmd.Parameters.AddWithValue("TerminationDate", li.TerminationDate); } if (!String.IsNullOrEmpty(li.WorkPhone)) { cmd.Parameters.AddWithValue("WorkPhone", li.WorkPhone); } //if (!String.IsNullOrEmpty(li.VoiceMailExtension)) // cmd.Parameters.AddWithValue("VoiceMailExtension", li.VoiceMailExtension); // if (!(li.VoiceMailPin.GetValueOrDefault(0) == 0)) cmd.Parameters.AddWithValue("VoiceMailPin", li.VoiceMailPin); if (!String.IsNullOrEmpty(li.FaxNumber)) { cmd.Parameters.AddWithValue("FaxNumber", li.FaxNumber); } if (!String.IsNullOrEmpty(li.MobilePhone)) { cmd.Parameters.AddWithValue("MobilePhone", li.MobilePhone); } if (!String.IsNullOrEmpty(li.Pager)) { cmd.Parameters.AddWithValue("Pager", li.Pager); } if (!String.IsNullOrEmpty(li.PersonalCellPhone)) { cmd.Parameters.AddWithValue("PersonalCellPhone", li.PersonalCellPhone); } if (!String.IsNullOrEmpty(li.InternationalPhone)) { cmd.Parameters.AddWithValue("InternationalPhone", li.InternationalPhone); } if (!String.IsNullOrEmpty(li.InternationalFax)) { cmd.Parameters.AddWithValue("InternationalFax", li.InternationalFax); } if (!String.IsNullOrEmpty(li.InternationalCell)) { cmd.Parameters.AddWithValue("InternationalCell", li.InternationalCell); } if (!String.IsNullOrEmpty(li.PrimaryEmail)) { cmd.Parameters.AddWithValue("PrimaryEmail", li.PrimaryEmail); } if (!String.IsNullOrEmpty(li.SecondaryEmail)) { cmd.Parameters.AddWithValue("SecondaryEmail", li.SecondaryEmail); } //cmd.Parameters.AddWithValue("VendorID", li.VendorID); cmd.Parameters.AddWithValue("Notes", li.Notes); if (!String.IsNullOrEmpty(li.InventoryNotes)) { cmd.Parameters.AddWithValue("InventoryNotes", li.InventoryNotes); } if (li.DemoSigned != DateTime.MinValue) { cmd.Parameters.AddWithValue("DemoSigned", li.DemoSigned); } if (!String.IsNullOrEmpty(li.TerritoryName)) { cmd.Parameters.AddWithValue("TerritoryName", li.TerritoryName); } if (!String.IsNullOrEmpty(li.RegionName)) { cmd.Parameters.AddWithValue("RegionName", li.RegionName); } if (!String.IsNullOrEmpty(li.DistributionRegionName)) { cmd.Parameters.AddWithValue("DistributionRegionName", li.DistributionRegionName); } if (!String.IsNullOrEmpty(li.SubBusinessUnitName)) { cmd.Parameters.AddWithValue("SubBusinessUnitName", li.SubBusinessUnitName); } if (!String.IsNullOrEmpty(li.BusinessUnitName)) { cmd.Parameters.AddWithValue("BusinessUnitName", li.BusinessUnitName); } if (!String.IsNullOrEmpty(li.CompanyName)) { cmd.Parameters.AddWithValue("CompanyName", li.CompanyName); } // if (li.EffectiveDate != DateTime.MinValue) // cmd.Parameters.AddWithValue("EffectiveDate", li.EffectiveDate); //if (!String.IsNullOrEmpty(li.GlobalAddress)) // cmd.Parameters.AddWithValue("Globaladdress", li.GlobalAddress); if (String.IsNullOrEmpty(HttpContext.Current.User.Identity.Name)) { cmd.Parameters.Add("@UpdateUser", SqlDbType.VarChar).Value = "sysadmin"; } else { cmd.Parameters.Add("@UpdateUser", SqlDbType.VarChar).Value = HttpContext.Current.User.Identity.Name; } connection.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(cmd)) { adapter.Fill(ds); } } } catch (Exception ex) { throw ex; } finally { connection.Close(); } return(ds); }
public DataSet UpdateSKPickingBoard(SalesRepresentativeReportingChild li, int memberships) { DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString()); SqlCommand sqlCmd = new SqlCommand("dbo.Web_SR_UpdateSalesRepresentative", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; // if (memberships == 1 || memberships == 2) // { sqlCmd.Parameters.Add("@SalesRepContactID", SqlDbType.Int).Value = li.SalesRepContactID; // sqlCmd.Parameters.Add("@EffectiveDate", SqlDbType.DateTime).Value = li.EffectiveDate; sqlCmd.Parameters.Add("@HireDate", SqlDbType.DateTime).Value = li.HireDate; if (li.DemoSigned != DateTime.MinValue) { sqlCmd.Parameters.Add("@DemoSigned", SqlDbType.DateTime).Value = li.DemoSigned; } // if (li.TerminationDate != DateTime.MinValue) sqlCmd.Parameters.Add("@TerminationDate", SqlDbType.DateTime).Value = li.TerminationDate; sqlCmd.Parameters.Add("@Title", SqlDbType.NVarChar).Value = li.Title; if (!String.IsNullOrEmpty(li.CompanyName)) { sqlCmd.Parameters.Add("@CompanyName", SqlDbType.NVarChar).Value = li.CompanyName; } if (!String.IsNullOrEmpty(li.Notes)) { sqlCmd.Parameters.Add("@Notes", SqlDbType.NVarChar).Value = li.Notes; } if (!String.IsNullOrEmpty(li.InventoryNotes)) { sqlCmd.Parameters.Add("@InventoryNotes", SqlDbType.NVarChar).Value = li.InventoryNotes; } if (!String.IsNullOrEmpty(li.SalesRepCompanyName)) { sqlCmd.Parameters.Add("@SalesRepCompanyName", SqlDbType.NVarChar).Value = li.SalesRepCompanyName; } if (!String.IsNullOrEmpty(li.WorkPhone)) { sqlCmd.Parameters.Add("@WorkPhone", SqlDbType.NVarChar).Value = li.WorkPhone; } if (!String.IsNullOrEmpty(li.SalesRepTypeName)) { sqlCmd.Parameters.Add("@SalesRepTypeName", SqlDbType.NVarChar).Value = li.SalesRepTypeName; } if (!String.IsNullOrEmpty(li.TerritoryName)) { sqlCmd.Parameters.Add("@TerritoryName", SqlDbType.NVarChar).Value = li.TerritoryName; } if (!String.IsNullOrEmpty(li.RegionName)) { sqlCmd.Parameters.Add("@RegionName", SqlDbType.NVarChar).Value = li.RegionName; } if (!String.IsNullOrEmpty(li.SubBusinessUnitName)) { sqlCmd.Parameters.Add("@SubBusinessUnitName", SqlDbType.NVarChar).Value = li.SubBusinessUnitName; } if (!String.IsNullOrEmpty(li.BusinessUnitName)) { sqlCmd.Parameters.Add("@BusinessUnitName", SqlDbType.NVarChar).Value = li.BusinessUnitName; } //if (!String.IsNullOrEmpty(li.VoiceMailExtension)) // sqlCmd.Parameters.Add("@VoiceMailExtension", SqlDbType.NVarChar).Value = li.VoiceMailExtension; if (!String.IsNullOrEmpty(li.Address1)) { sqlCmd.Parameters.Add("@Address1", SqlDbType.NVarChar).Value = li.Address1; } if (!String.IsNullOrEmpty(li.Address2)) { sqlCmd.Parameters.Add("@Address2", SqlDbType.NVarChar).Value = li.Address2; } if (!String.IsNullOrEmpty(li.Address3)) { sqlCmd.Parameters.Add("@Address3", SqlDbType.NVarChar).Value = li.Address3; } if (!String.IsNullOrEmpty(li.FaxNumber)) { sqlCmd.Parameters.Add("@FaxNumber", SqlDbType.NVarChar).Value = li.FaxNumber; } if (!String.IsNullOrEmpty(li.MobilePhone)) { sqlCmd.Parameters.Add("@MobilePhone", SqlDbType.NVarChar).Value = li.MobilePhone; } //if (!String.IsNullOrEmpty(li.Pager)) // sqlCmd.Parameters.Add("@Pager", SqlDbType.NVarChar).Value = li.Pager; if (!String.IsNullOrEmpty(li.PersonalCellPhone)) { sqlCmd.Parameters.Add("@PersonalCellPhone", SqlDbType.NVarChar).Value = li.PersonalCellPhone; } if (!String.IsNullOrEmpty(li.InternationalPhone)) { sqlCmd.Parameters.Add("@InternationalPhone", SqlDbType.NVarChar).Value = li.InternationalPhone; } //if (!String.IsNullOrEmpty(li.InternationalFax)) // sqlCmd.Parameters.Add("@InternationalFax", SqlDbType.NVarChar).Value = li.InternationalFax; if (!String.IsNullOrEmpty(li.InternationalCell)) { sqlCmd.Parameters.Add("@InternationalCell", SqlDbType.NVarChar).Value = li.InternationalCell; } if (!String.IsNullOrEmpty(li.PrimaryEmail)) { sqlCmd.Parameters.Add("@PrimaryEmail", SqlDbType.NVarChar).Value = li.PrimaryEmail; } if (!String.IsNullOrEmpty(li.SecondaryEmail)) { sqlCmd.Parameters.Add("@SecondaryEmail", SqlDbType.NVarChar).Value = li.SecondaryEmail; } if (String.IsNullOrEmpty(HttpContext.Current.User.Identity.Name)) { sqlCmd.Parameters.Add("@UpdateUser", SqlDbType.VarChar).Value = "sysadmin"; } else { sqlCmd.Parameters.Add("@UpdateUser", SqlDbType.VarChar).Value = HttpContext.Current.User.Identity.Name; } // } try { sqlConn.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(sqlCmd)) { adapter.Fill(ds); } } catch (Exception ex) { throw ex; } return(ds); }