Você está na página 1de 11

using using using using using using using using using using using using using using

System; System.Collections; System.Configuration; System.Data; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Data.SqlClient; PSCS.PRISM.QueueController; PSCS.BusinessInvestment.DTO; PSCS.PRISM.BAL;

namespace PSCS.BusinessInvestment.UI.Controls { public partial class InvestmentOptedByCustomer : System.Web.UI.UserControl { DTO.NomineeDetails nomineeDetails = new DTO.NomineeDetails(); DTO.InvestmentOptedByCustomer investmentOptedByCustomer = new DTO.Invest mentOptedByCustomer(); InvestmentOptedByCustomerInfo investmentOptedByCustomerInfo = new Invest mentOptedByCustomerInfo(); NomineeInfo nomineeInfo = new NomineeInfo(); /// <summary> /// on page load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { LoadCustomerGrid(); LoadConsultantGrid(); LoadInvestmentType(); LoadRelation(ddlRelationNominee1); } } catch (Exception) { throw; } } /// <summary> /// Bind/Load the data from DB into RadioButtonList of InvestmentType /// </summary> private void LoadInvestmentType() { try { DataTable dataTable = new DataTable(); dataTable.Load(investmentOptedByCustomerInfo.AllInvestmentType() );

rblInvestmentType.DataSource = dataTable; rblInvestmentType.DataTextField = "InvestmentType"; rblInvestmentType.DataValueField = "ID"; rblInvestmentType.DataBind(); } catch (Exception) { throw; } } /// <summary> /// Bind/Load the data form DB into Grid /// </summary> private void LoadCustomerGrid() { try { DataTable allCustomerDataTable = new DataTable(); allCustomerDataTable.Load(investmentOptedByCustomerInfo.AllCusto mer()); grdCustomerSearch.DataSource = allCustomerDataTable; grdCustomerSearch.DataBind(); } catch (Exception) { throw; } } /// <summary> /// Bind/Load the data form DB into Grid /// </summary> private void LoadConsultantGrid() { try { DataTable allConsultantDataTable = new DataTable(); allConsultantDataTable.Load(investmentOptedByCustomerInfo.AllCon sultant()); gdvConsultantSearch.DataSource = allConsultantDataTable; gdvConsultantSearch.DataBind(); } catch (Exception) { throw; } } /// <summary> /// when Customer is search and selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grdCustomerSearch_SelectedIndexChanged(object sender, Eve ntArgs e) { gdvConsultantSearch.Focus(); lblCustomerName1Is.Text = grdCustomerSearch.SelectedRow.Cells[1].Tex t.ToString();

lblCustomerName2Is.Text = grdCustomerSearch.SelectedRow.Cells[1].Tex t.ToString(); lblCustomerName3Is.Text = grdCustomerSearch.SelectedRow.Cells[1].Tex t.ToString(); } /// <summary> /// when Consultant is search and selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gdvConsultantSearch_SelectedIndexChanged(object sender, E ventArgs e) { rblInvestmentType.Focus(); } /// <summary> /// when investment type is selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void rblInvestmentType_SelectedIndexChanged(object sender, Eve ntArgs e) { int investmentTypeID = Convert.ToInt16(rblInvestmentType.SelectedVal ue.ToString()); LoadInvestmentTenure(investmentTypeID); LoadInvestmentMode(investmentTypeID); ddlInvestmentTenure.Focus(); } /// <summary> /// Bind/Load the proper data from DB into DropDownList /// </summary> private void LoadInvestmentMode(int investmentTypeID) { try { investmentOptedByCustomer.InvestmentType_ID = investmentTypeID; DataTable dataTable = new DataTable(); dataTable.Load(investmentOptedByCustomerInfo.InvestmentModeForIn vestmentTypeID(investmentOptedByCustomer)); ddlInvestmentMode.DataSource = dataTable; ddlInvestmentMode.DataValueField = "InstallmentModeID"; ddlInvestmentMode.DataTextField = "InstallmentMode"; ddlInvestmentMode.DataBind(); ddlInvestmentMode.Items.Insert(0, new ListItem("Select", "0")); ddlInvestmentMode.SelectedIndex = 0; } catch (Exception) { throw; } } /// <summary> /// Bind/Load the proper data from DB into DropDownList /// </summary>

private void LoadRelation(DropDownList ddl) { try { DataTable dataTable = new DataTable(); dataTable.Load(investmentOptedByCustomerInfo.AllRelation()); ddl.DataSource = dataTable; ddl.DataValueField = "ID"; ddl.DataTextField = "Relation"; ddl.DataBind(); ddl.Items.Insert(0, new ListItem("Select", "0")); ddl.SelectedIndex = 0; } catch (Exception) { throw; } } /// <summary> /// Bind/Load the proper data from DB into DropDownList /// </summary> private void LoadInvestmentTenure(int investmentTypeID) { try { investmentOptedByCustomer.InvestmentType_ID = investmentTypeID; DataTable dataTable = new DataTable(); dataTable.Load(investmentOptedByCustomerInfo.InvestmentTenureFor InvestmentType(investmentOptedByCustomer)); ddlInvestmentTenure.DataSource = dataTable; ddlInvestmentTenure.DataValueField = "ID"; ddlInvestmentTenure.DataTextField = "Tenure"; ddlInvestmentTenure.DataBind(); ddlInvestmentTenure.Items.Insert(0, new ListItem("Select", "0")) ; ddlInvestmentTenure.SelectedIndex = 0; } catch (Exception) { throw; } } /// <summary> /// when investment tenure is selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ddlInvestmentTenure_SelectedIndexChanged(object sender, E ventArgs e) { try { if (!ddlInvestmentMode.SelectedIndex.Equals(0)) LoadAmount(Convert.ToInt16(rblInvestmentType.SelectedValue), Convert.ToInt16(ddlInvestmentTenure.SelectedValue), Convert.ToInt16(ddlInvestme ntMode.SelectedValue));

} catch (Exception) { throw; } ddlInvestmentMode.Focus(); } /// <summary> /// when investment mode is selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ddlInvestmentMode_SelectedIndexChanged(object sender, Eve ntArgs e) { try { if (!ddlInvestmentTenure.SelectedIndex.Equals(0)) LoadAmount(Convert.ToInt16(rblInvestmentType.SelectedValue), Convert.ToInt16(ddlInvestmentTenure.SelectedValue), Convert.ToInt16(ddlInvestme ntMode.SelectedValue)); } catch (Exception) { throw; } } /// <summary> /// Bind/Load the proper data from DB into DropDownList of Amount /// </summary> private void LoadAmount(int type, int tenure, int mode) { try { investmentOptedByCustomer.InvestmentType_ID = type; investmentOptedByCustomer.InvestmentTenure_ID = tenure; investmentOptedByCustomer.InvestmentMode_ID = mode; DataTable dataTable = new DataTable(); dataTable.Load(investmentOptedByCustomerInfo.AllAmount(investmen tOptedByCustomer)); ddlAmount.DataSource = dataTable; ddlAmount.DataValueField = "InvestmentAmount"; ddlAmount.DataTextField = "InvestmentAmount"; ddlAmount.DataBind(); ddlAmount.Items.Insert(0, new ListItem("Select", "0")); ddlAmount.SelectedIndex = 0; } catch (Exception) { throw; } } /// <summary> /// when joining date is selected

/// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void txtJoiningDate_TextChanged(object sender, EventArgs e) { try { investmentOptedByCustomer.JoiningDate = DateTime.ParseExact(txtJ oiningDate.Text, "dd/MM/yyyy", null); DateTime maturityDate = investmentOptedByCustomer.JoiningDate.Ad dMonths(Convert.ToInt16(ddlInvestmentTenure.SelectedItem.ToString())); txtMaturityDate.Text = maturityDate.ToString("dd/MM/yyyy"); } catch (Exception) { throw; } } /// <summary> /// when their is two nominee /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lnkAddNominee2_Click(object sender, EventArgs e) { pnlNominee2Details.Visible = true; LoadRelation(ddlRelationNominee2); } /// <summary> /// when their is three nominee /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lnkAddNominee3_Click(object sender, EventArgs e) { pnlNominee3Details.Visible = true; LoadRelation(ddlRelationNominee3); } /// <summary> /// clear all the controls /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCancel_Click(object sender, EventArgs e) { try { ResetPage(); } catch (Exception) { throw; } } /// <summary>

/// close Nominee 2 windows /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lnlCloseNominee2_Click(object sender, EventArgs e) { pnlNominee2Details.Visible = false; txtFirstNameNominee2.Text = string.Empty; txtMiddleNameNominee2.Text = string.Empty; txtLastNameNominee2.Text = string.Empty; txtDOBNominee2.Text = string.Empty; lblCustomerName2Is.Text = string.Empty; ddlRelationNominee2.Items.Clear(); } /// <summary> /// close Nominee 3 windows /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lnkCloseNominee3_Click(object sender, EventArgs e) { pnlNominee3Details.Visible = false; txtFirstNameNominee3.Text = string.Empty; txtMiddleNameNominee3.Text = string.Empty; txtLastNameNominee3.Text = string.Empty; txtDOBNominee3.Text = string.Empty; lblCustomerName3Is.Text = string.Empty; ddlRelationNominee3.Items.Clear(); } /// <summary> /// to reset all the control of the page /// </summary> private void ResetPage() { try { txtFirstNameNominee1.Text = string.Empty; txtMiddleNameNominee1.Text = string.Empty; txtLastNameNominee1.Text = string.Empty; txtDOBNominee1.Text = string.Empty; lblCustomerName1Is.Text = string.Empty; ddlRelationNominee1.SelectedIndex = 0; lnlCloseNominee2_Click(new object(), new System.EventArgs()); lnkCloseNominee3_Click(new object(), new System.EventArgs()); ddlInvestmentTenure.Items.Clear(); ddlInvestmentMode.Items.Clear(); foreach (ListItem li in rblInvestmentType.Items) { li.Selected = false; } ddlAmount.Items.Clear(); txtJoiningDate.Text = string.Empty; txtMaturityDate.Text = string.Empty; gdvConsultantSearch.SelectedIndex = -1;

grdCustomerSearch.SelectedIndex = -1; ResetCustomerSearchSelectPanel(); } catch (Exception) { throw; } } /// <summary> /// calculate catalog ID /// </summary> /// <returns> catalog ID </returns> private int CatlogID() { try { investmentOptedByCustomer.InvestmentType_ID =Convert.ToInt16(rbl InvestmentType.SelectedValue); investmentOptedByCustomer.InvestmentTenure_ID = Convert.ToInt16( ddlInvestmentTenure.SelectedValue); investmentOptedByCustomer.InvestmentMode_ID = Convert.ToInt16(dd lInvestmentMode.SelectedValue); investmentOptedByCustomer.Amount = Convert.ToDouble(ddlAmount.Se lectedValue); return investmentOptedByCustomerInfo.CatalogID(investmentOptedBy Customer); } catch (Exception) { throw; } } /// <summary> /// set all DTO values belongls to Investment Plan /// </summary> private void setDtoOfInvestmentPlan() { try { investmentOptedByCustomer.Customer_ID = Convert.ToInt16(grdCusto merSearch.DataKeys[grdCustomerSearch.SelectedIndex].Value.ToString()); investmentOptedByCustomer.Consultant_ID = Convert.ToInt16(gdvCon sultantSearch.DataKeys[gdvConsultantSearch.SelectedIndex].Value.ToString()); investmentOptedByCustomer.InvestmentCatalogue_ID = CatlogID(); investmentOptedByCustomer.JoiningDate = DateTime.ParseExact(txtJ oiningDate.Text, "dd/MM/yyyy", null); investmentOptedByCustomer.MaturityDate = DateTime.ParseExact(txt MaturityDate.Text, "dd/MM/yyyy", null); } catch (Exception) { throw; }

} /// <summary> /// set all DTO values belongls to Customer search /// </summary> private void setDto_SearchCustomer() { try { investmentOptedByCustomer.CustomerFname = txtCustomerFirstName.T ext; investmentOptedByCustomer.CustomerMname = txtCustomerMiddleName. Text; investmentOptedByCustomer.CustomerLname = txtCustomerLastName.Te xt; investmentOptedByCustomer.CustomerPincode = txtCustomerPinCode.T ext; if(!txtCustomerDateOfBirth.Text.Equals(string.Empty)) investmentOptedByCustomer.CustomerDob = DateTime.ParseExact( txtCustomerDateOfBirth.Text, "dd/MM/yyyy", null); investmentOptedByCustomer.CustomerContactNumber = txtCustomerCon tactNumber.Text; } catch (Exception) { throw; } } /// <summary> /// while saving the nominee details /// </summary> private int InsertNominee() { try { int countNominee; nomineeDetails.Customer_ID = Convert.ToInt16(grdCustomerSearch.D ataKeys[grdCustomerSearch.SelectedIndex].Value.ToString()); nomineeDetails.InvestmentCatalogue_ID = CatlogID(); nomineeDetails.FirstName1 = txtFirstNameNominee1.Text; nomineeDetails.MiddleName1 = txtMiddleNameNominee1.Text; nomineeDetails.LastName1 = txtLastNameNominee1.Text; nomineeDetails.DateOfBirth1 = DateTime.ParseExact(txtDOBNominee1 .Text, "dd/MM/yyyy", null); nomineeDetails.Relation_ID1 = Convert.ToInt16(ddlRelationNominee 1.SelectedValue); nomineeInfo.AddNominee(nomineeDetails); if (pnlNominee2Details.Visible) { nomineeDetails.FirstName1 = txtFirstNameNominee2.Text; nomineeDetails.MiddleName1 = txtMiddleNameNominee2.Text; nomineeDetails.LastName1 = txtLastNameNominee2.Text; nomineeDetails.DateOfBirth1 = DateTime.ParseExact(txtDOBNomi nee2.Text, "dd/MM/yyyy", null); nomineeDetails.Relation_ID1 = Convert.ToInt16(ddlRelationNom

inee2.SelectedValue); nomineeInfo.AddNominee(nomineeDetails); if (pnlNominee3Details.Visible) { nomineeDetails.FirstName1 = txtFirstNameNominee3.Text; nomineeDetails.MiddleName1 = txtMiddleNameNominee3.Text; nomineeDetails.LastName1 = txtLastNameNominee3.Text; nomineeDetails.DateOfBirth1 = DateTime.ParseExact(txtDOB Nominee3.Text, "dd/MM/yyyy", null); nomineeDetails.Relation_ID1 = Convert.ToInt16(ddlRelatio nNominee3.SelectedValue); nomineeInfo.AddNominee(nomineeDetails); countNominee = 3; } else { countNominee = 2; } } else { countNominee = 1; } return countNominee; } catch (Exception) { throw; } } /// <summary> /// when all the necessary information is filled and click on save butto n /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { setDtoOfInvestmentPlan(); investmentOptedByCustomerInfo.AddOptedInvestment(investmentOpted ByCustomer); int numberOfNominee = InsertNominee(); } catch (Exception) { throw; } } /// <summary> /// when user click on customer search button to search customer /// </summary>

/// <param name="sender"></param> /// <param name="e"></param> protected void btnSearchCustomer_Click(object sender, EventArgs e) { try { if (txtCustomerFirstName.Text == string.Empty && txtCustomerMidd leName.Text == string.Empty && txtCustomerLastName.Text == string.Empty && txtCustomerPinCo de.Text == string.Empty && txtCustomerContactNumber.Text == string.Empty && txtCustomer DateOfBirth.Text == string.Empty) { LoadCustomerGrid(); } else { setDto_SearchCustomer(); DataTable searchedCustomer = new DataTable(); searchedCustomer.Load(investmentOptedByCustomerInfo.SearchCu stomer(investmentOptedByCustomer)); grdCustomerSearch.DataSource = searchedCustomer; grdCustomerSearch.DataBind(); ResetCustomerSearchSelectPanel(); } } catch (Exception) { throw; } } /// <summary> /// reset all control of Customer Search/Select Panel only /// </summary> protected void ResetCustomerSearchSelectPanel() { try { txtCustomerFirstName.Text = string.Empty; txtCustomerMiddleName.Text = string.Empty; txtCustomerLastName.Text = string.Empty; txtCustomerContactNumber.Text = string.Empty; txtCustomerDateOfBirth.Text = string.Empty; txtCustomerPinCode.Text = string.Empty; } catch (Exception) { throw; } } } }

Você também pode gostar