private void UpdateRecord() { dbo_DimCustomerClass oclsdbo_DimCustomer = new dbo_DimCustomerClass(); dbo_DimCustomerClass clsdbo_DimCustomer = new dbo_DimCustomerClass(); oclsdbo_DimCustomer.CustomerKey = System.Convert.ToInt32(Session["CustomerKey"]); oclsdbo_DimCustomer = dbo_DimCustomerDataClass.Select_Record(oclsdbo_DimCustomer); if (VerifyData() == true) { SetData(clsdbo_DimCustomer); bool bSucess = false; bSucess = dbo_DimCustomerDataClass.Update(oclsdbo_DimCustomer, clsdbo_DimCustomer); if (bSucess == true) { pnlForm.Visible = false; pnlSave.Visible = false; pnlGrid.Visible = true; lblMode.InnerText = ""; Session.Remove("dvdbo_DimCustomer"); LoadGriddbo_DimCustomer(); } else { ec.ShowMessage(" Update failed. ", " Dbo. Dim Customer "); } } }
private void InsertRecord() { dbo_DimCustomerClass clsdbo_DimCustomer = new dbo_DimCustomerClass(); if (VerifyData() == true) { SetData(clsdbo_DimCustomer); bool bSucess = false; bSucess = dbo_DimCustomerDataClass.Add(clsdbo_DimCustomer); if (bSucess == true) { pnlForm.Visible = false; pnlSave.Visible = false; pnlGrid.Visible = true; lblMode.InnerText = ""; Session.Remove("dvdbo_DimCustomer"); LoadGriddbo_DimCustomer(); } else { ec.ShowMessage(" Insert failed. ", " Dbo. Dim Customer "); } } }
private void SetData(dbo_DimCustomerClass clsdbo_DimCustomer) { if (string.IsNullOrEmpty(txtGeographyKey.SelectedValue)) { clsdbo_DimCustomer.GeographyKey = null; } else { clsdbo_DimCustomer.GeographyKey = System.Convert.ToInt32(txtGeographyKey.SelectedValue); } clsdbo_DimCustomer.CustomerAlternateKey = System.Convert.ToString(txtCustomerAlternateKey.Text); if (string.IsNullOrEmpty(txtTitle.Text)) { clsdbo_DimCustomer.Title = null; } else { clsdbo_DimCustomer.Title = txtTitle.Text; } if (string.IsNullOrEmpty(txtFirstName.Text)) { clsdbo_DimCustomer.FirstName = null; } else { clsdbo_DimCustomer.FirstName = txtFirstName.Text; } if (string.IsNullOrEmpty(txtMiddleName.Text)) { clsdbo_DimCustomer.MiddleName = null; } else { clsdbo_DimCustomer.MiddleName = txtMiddleName.Text; } if (string.IsNullOrEmpty(txtLastName.Text)) { clsdbo_DimCustomer.LastName = null; } else { clsdbo_DimCustomer.LastName = txtLastName.Text; } clsdbo_DimCustomer.NameStyle = txtNameStyle.Checked ? true : false; if (string.IsNullOrEmpty(txtBirthDate.Text)) { clsdbo_DimCustomer.BirthDate = null; } else { clsdbo_DimCustomer.BirthDate = System.Convert.ToDateTime(txtBirthDate.Text); } if (string.IsNullOrEmpty(txtMaritalStatus.Text)) { clsdbo_DimCustomer.MaritalStatus = null; } else { clsdbo_DimCustomer.MaritalStatus = txtMaritalStatus.Text; } if (string.IsNullOrEmpty(txtSuffix.Text)) { clsdbo_DimCustomer.Suffix = null; } else { clsdbo_DimCustomer.Suffix = txtSuffix.Text; } if (string.IsNullOrEmpty(txtGender.Text)) { clsdbo_DimCustomer.Gender = null; } else { clsdbo_DimCustomer.Gender = txtGender.Text; } if (string.IsNullOrEmpty(txtEmailAddress.Text)) { clsdbo_DimCustomer.EmailAddress = null; } else { clsdbo_DimCustomer.EmailAddress = txtEmailAddress.Text; } if (string.IsNullOrEmpty(txtYearlyIncome.Text)) { clsdbo_DimCustomer.YearlyIncome = null; } else { clsdbo_DimCustomer.YearlyIncome = System.Convert.ToDecimal(txtYearlyIncome.Text); } if (string.IsNullOrEmpty(txtTotalChildren.Text)) { clsdbo_DimCustomer.TotalChildren = null; } else { clsdbo_DimCustomer.TotalChildren = System.Convert.ToByte(txtTotalChildren.Text); } if (string.IsNullOrEmpty(txtNumberChildrenAtHome.Text)) { clsdbo_DimCustomer.NumberChildrenAtHome = null; } else { clsdbo_DimCustomer.NumberChildrenAtHome = System.Convert.ToByte(txtNumberChildrenAtHome.Text); } if (string.IsNullOrEmpty(txtEnglishEducation.Text)) { clsdbo_DimCustomer.EnglishEducation = null; } else { clsdbo_DimCustomer.EnglishEducation = txtEnglishEducation.Text; } if (string.IsNullOrEmpty(txtSpanishEducation.Text)) { clsdbo_DimCustomer.SpanishEducation = null; } else { clsdbo_DimCustomer.SpanishEducation = txtSpanishEducation.Text; } if (string.IsNullOrEmpty(txtFrenchEducation.Text)) { clsdbo_DimCustomer.FrenchEducation = null; } else { clsdbo_DimCustomer.FrenchEducation = txtFrenchEducation.Text; } if (string.IsNullOrEmpty(txtEnglishOccupation.Text)) { clsdbo_DimCustomer.EnglishOccupation = null; } else { clsdbo_DimCustomer.EnglishOccupation = txtEnglishOccupation.Text; } if (string.IsNullOrEmpty(txtSpanishOccupation.Text)) { clsdbo_DimCustomer.SpanishOccupation = null; } else { clsdbo_DimCustomer.SpanishOccupation = txtSpanishOccupation.Text; } if (string.IsNullOrEmpty(txtFrenchOccupation.Text)) { clsdbo_DimCustomer.FrenchOccupation = null; } else { clsdbo_DimCustomer.FrenchOccupation = txtFrenchOccupation.Text; } if (string.IsNullOrEmpty(txtHouseOwnerFlag.Text)) { clsdbo_DimCustomer.HouseOwnerFlag = null; } else { clsdbo_DimCustomer.HouseOwnerFlag = txtHouseOwnerFlag.Text; } if (string.IsNullOrEmpty(txtNumberCarsOwned.Text)) { clsdbo_DimCustomer.NumberCarsOwned = null; } else { clsdbo_DimCustomer.NumberCarsOwned = System.Convert.ToByte(txtNumberCarsOwned.Text); } if (string.IsNullOrEmpty(txtAddressLine1.Text)) { clsdbo_DimCustomer.AddressLine1 = null; } else { clsdbo_DimCustomer.AddressLine1 = txtAddressLine1.Text; } if (string.IsNullOrEmpty(txtAddressLine2.Text)) { clsdbo_DimCustomer.AddressLine2 = null; } else { clsdbo_DimCustomer.AddressLine2 = txtAddressLine2.Text; } if (string.IsNullOrEmpty(txtPhone.Text)) { clsdbo_DimCustomer.Phone = null; } else { clsdbo_DimCustomer.Phone = txtPhone.Text; } if (string.IsNullOrEmpty(txtDateFirstPurchase.Text)) { clsdbo_DimCustomer.DateFirstPurchase = null; } else { clsdbo_DimCustomer.DateFirstPurchase = System.Convert.ToDateTime(txtDateFirstPurchase.Text); } if (string.IsNullOrEmpty(txtCommuteDistance.Text)) { clsdbo_DimCustomer.CommuteDistance = null; } else { clsdbo_DimCustomer.CommuteDistance = txtCommuteDistance.Text; } }
private void GetData() { ClearRecord(); dbo_DimCustomerClass clsdbo_DimCustomer = new dbo_DimCustomerClass(); clsdbo_DimCustomer.CustomerKey = System.Convert.ToInt32(Session["CustomerKey"]); clsdbo_DimCustomer = dbo_DimCustomerDataClass.Select_Record(clsdbo_DimCustomer); if ((clsdbo_DimCustomer != null)) { try { txtCustomerKey.Text = System.Convert.ToString(clsdbo_DimCustomer.CustomerKey); if (clsdbo_DimCustomer.GeographyKey == null) { txtGeographyKey.SelectedValue = default(string); } else { txtGeographyKey.SelectedValue = System.Convert.ToString(clsdbo_DimCustomer.GeographyKey); } txtCustomerAlternateKey.Text = System.Convert.ToString(clsdbo_DimCustomer.CustomerAlternateKey); if (clsdbo_DimCustomer.Title == null) { txtTitle.Text = default(string); } else { txtTitle.Text = System.Convert.ToString(clsdbo_DimCustomer.Title); } if (clsdbo_DimCustomer.FirstName == null) { txtFirstName.Text = default(string); } else { txtFirstName.Text = System.Convert.ToString(clsdbo_DimCustomer.FirstName); } if (clsdbo_DimCustomer.MiddleName == null) { txtMiddleName.Text = default(string); } else { txtMiddleName.Text = System.Convert.ToString(clsdbo_DimCustomer.MiddleName); } if (clsdbo_DimCustomer.LastName == null) { txtLastName.Text = default(string); } else { txtLastName.Text = System.Convert.ToString(clsdbo_DimCustomer.LastName); } //if (clsdbo_DimCustomer.NameStyle == null) { txtNameStyle.Checked = default(string); } else { txtNameStyle.Checked = System.Convert.ToBoolean(clsdbo_DimCustomer.NameStyle); } if (clsdbo_DimCustomer.BirthDate == null) { txtBirthDate.Text = DateTime.Now.ToString(); } else { txtBirthDate.Text = System.Convert.ToDateTime(clsdbo_DimCustomer.BirthDate).ToShortDateString(); } if (clsdbo_DimCustomer.MaritalStatus == null) { txtMaritalStatus.Text = default(string); } else { txtMaritalStatus.Text = System.Convert.ToString(clsdbo_DimCustomer.MaritalStatus); } if (clsdbo_DimCustomer.Suffix == null) { txtSuffix.Text = default(string); } else { txtSuffix.Text = System.Convert.ToString(clsdbo_DimCustomer.Suffix); } if (clsdbo_DimCustomer.Gender == null) { txtGender.Text = default(string); } else { txtGender.Text = System.Convert.ToString(clsdbo_DimCustomer.Gender); } if (clsdbo_DimCustomer.EmailAddress == null) { txtEmailAddress.Text = default(string); } else { txtEmailAddress.Text = System.Convert.ToString(clsdbo_DimCustomer.EmailAddress); } if (clsdbo_DimCustomer.YearlyIncome == null) { txtYearlyIncome.Text = default(string); } else { txtYearlyIncome.Text = System.Convert.ToString(clsdbo_DimCustomer.YearlyIncome); } if (clsdbo_DimCustomer.TotalChildren == null) { txtTotalChildren.Text = default(string); } else { txtTotalChildren.Text = System.Convert.ToString(clsdbo_DimCustomer.TotalChildren); } if (clsdbo_DimCustomer.NumberChildrenAtHome == null) { txtNumberChildrenAtHome.Text = default(string); } else { txtNumberChildrenAtHome.Text = System.Convert.ToString(clsdbo_DimCustomer.NumberChildrenAtHome); } if (clsdbo_DimCustomer.EnglishEducation == null) { txtEnglishEducation.Text = default(string); } else { txtEnglishEducation.Text = System.Convert.ToString(clsdbo_DimCustomer.EnglishEducation); } if (clsdbo_DimCustomer.SpanishEducation == null) { txtSpanishEducation.Text = default(string); } else { txtSpanishEducation.Text = System.Convert.ToString(clsdbo_DimCustomer.SpanishEducation); } if (clsdbo_DimCustomer.FrenchEducation == null) { txtFrenchEducation.Text = default(string); } else { txtFrenchEducation.Text = System.Convert.ToString(clsdbo_DimCustomer.FrenchEducation); } if (clsdbo_DimCustomer.EnglishOccupation == null) { txtEnglishOccupation.Text = default(string); } else { txtEnglishOccupation.Text = System.Convert.ToString(clsdbo_DimCustomer.EnglishOccupation); } if (clsdbo_DimCustomer.SpanishOccupation == null) { txtSpanishOccupation.Text = default(string); } else { txtSpanishOccupation.Text = System.Convert.ToString(clsdbo_DimCustomer.SpanishOccupation); } if (clsdbo_DimCustomer.FrenchOccupation == null) { txtFrenchOccupation.Text = default(string); } else { txtFrenchOccupation.Text = System.Convert.ToString(clsdbo_DimCustomer.FrenchOccupation); } if (clsdbo_DimCustomer.HouseOwnerFlag == null) { txtHouseOwnerFlag.Text = default(string); } else { txtHouseOwnerFlag.Text = System.Convert.ToString(clsdbo_DimCustomer.HouseOwnerFlag); } if (clsdbo_DimCustomer.NumberCarsOwned == null) { txtNumberCarsOwned.Text = default(string); } else { txtNumberCarsOwned.Text = System.Convert.ToString(clsdbo_DimCustomer.NumberCarsOwned); } if (clsdbo_DimCustomer.AddressLine1 == null) { txtAddressLine1.Text = default(string); } else { txtAddressLine1.Text = System.Convert.ToString(clsdbo_DimCustomer.AddressLine1); } if (clsdbo_DimCustomer.AddressLine2 == null) { txtAddressLine2.Text = default(string); } else { txtAddressLine2.Text = System.Convert.ToString(clsdbo_DimCustomer.AddressLine2); } if (clsdbo_DimCustomer.Phone == null) { txtPhone.Text = default(string); } else { txtPhone.Text = System.Convert.ToString(clsdbo_DimCustomer.Phone); } if (clsdbo_DimCustomer.DateFirstPurchase == null) { txtDateFirstPurchase.Text = DateTime.Now.ToString(); } else { txtDateFirstPurchase.Text = System.Convert.ToDateTime(clsdbo_DimCustomer.DateFirstPurchase).ToShortDateString(); } if (clsdbo_DimCustomer.CommuteDistance == null) { txtCommuteDistance.Text = default(string); } else { txtCommuteDistance.Text = System.Convert.ToString(clsdbo_DimCustomer.CommuteDistance); } } catch (Exception ex) { ec.ShowMessage(ex.Message, " Dbo. Dim Customer "); } } }