/// <summary> /// Adds or updates the row in the Database /// </summary> /// <returns>true on success, false on error</returns> private bool SaveData() { // // Check that the Form has passed validation // Page.Validate(); if (!Page.IsValid) { // Validation failed return false; } sazehDataSet sazehDS = new sazehDataSet(); sazehService sazehLogic = new sazehService(); sazehDataSet.sazehRow sazehRowCurrent; switch (DataEntryMode) { case PageDataEntryMode.AddRow: // // Create a New Row // sazehRowCurrent = sazehDS.sazeh.NewsazehRow(); break; case PageDataEntryMode.EditRow: // // Update existing Row // if (sazehLogic.GetByszh_id(sazehDS, m_szh_idCurrent) == 0) { // // sazeh Row not found // return false; } else { sazehRowCurrent = sazehDS.sazeh[0]; } break; default: return false; } // // Set the DataRow values from the Page Controls // // mlk_id if (ctlmlk_id.Text.Length == 0) { sazehRowCurrent.Setmlk_idNull(); } else { sazehRowCurrent.mlk_id = Convert.ToInt32(ctlmlk_id.Text); } // rsht_id sazehRowCurrent.rsht_id = Convert.ToInt32(ctlrsht_id.Text); // modirt_id sazehRowCurrent.modirt_id = Convert.ToInt32(ctlmodirt_id.Text); // shrstan_id sazehRowCurrent.shrstan_id = Convert.ToInt32(ctlshrstan_id.Text); // shobh_id if (ctlshobh_id.Text.Length == 0) { sazehRowCurrent.Setshobh_idNull(); } else { sazehRowCurrent.shobh_id = ctlshobh_id.Text; } // fndsion_noe_id sazehRowCurrent.fndsion_noe_id = Convert.ToInt32(ctlfndsion_noe_id.SelectedItem.Value); // fndsion_tozi if (ctlfndsion_tozi.Text.Length == 0) { sazehRowCurrent.Setfndsion_toziNull(); } else { sazehRowCurrent.fndsion_tozi = ctlfndsion_tozi.Text; } // sgf_noe_id sazehRowCurrent.sgf_noe_id = Convert.ToInt32(ctlsgf_noe_id.SelectedItem.Value); // sgf_sayr if (ctlsgf_sayr.Text.Length == 0) { sazehRowCurrent.Setsgf_sayrNull(); } else { sazehRowCurrent.sgf_sayr = ctlsgf_sayr.Text; } // sgf_tozi if (ctlsgf_tozi.Text.Length == 0) { sazehRowCurrent.Setsgf_toziNull(); } else { sazehRowCurrent.sgf_tozi = ctlsgf_tozi.Text; } // sklt_noe_id sazehRowCurrent.sklt_noe_id = Convert.ToInt32(ctlsklt_noe_id.SelectedItem.Value); // sklt_tozi if (ctlsklt_tozi.Text.Length == 0) { sazehRowCurrent.Setsklt_toziNull(); } else { sazehRowCurrent.sklt_tozi = ctlsklt_tozi.Text; } // sklt_sayr if (ctlsklt_sayr.Text.Length == 0) { sazehRowCurrent.Setsklt_sayrNull(); } else { sazehRowCurrent.sklt_sayr = ctlsklt_sayr.Text; } // divar_karji_glb_id sazehRowCurrent.divar_karji_glb_id = Convert.ToInt32(ctldivar_karji_glb_id.SelectedItem.Value); // divar_dakli_glb_partition sazehRowCurrent.divar_dakli_glb_partition = ctldivar_dakli_glb_partition.Checked; // divar_dakli_glb_simani sazehRowCurrent.divar_dakli_glb_simani = ctldivar_dakli_glb_simani.Checked; // divar_dakli_glb_lika sazehRowCurrent.divar_dakli_glb_lika = ctldivar_dakli_glb_lika.Checked; // divar_dakli_glb_hblx sazehRowCurrent.divar_dakli_glb_hblx = ctldivar_dakli_glb_hblx.Checked; // divar_dakli_glb_sofali sazehRowCurrent.divar_dakli_glb_sofali = ctldivar_dakli_glb_sofali.Checked; // divar_dakli_glb_poma sazehRowCurrent.divar_dakli_glb_poma = ctldivar_dakli_glb_poma.Checked; // divar_dakli_glb_ajor sazehRowCurrent.divar_dakli_glb_ajor = ctldivar_dakli_glb_ajor.Checked; // divar_dakli_glb_drywall sazehRowCurrent.divar_dakli_glb_drywall = ctldivar_dakli_glb_drywall.Checked; // divar_dakli_glb_sayer sazehRowCurrent.divar_dakli_glb_sayer = ctldivar_dakli_glb_sayer.Checked; // divar_dakli_glb_sayer_val if (ctldivar_dakli_glb_sayer_val.Text.Length == 0) { sazehRowCurrent.Setdivar_dakli_glb_sayer_valNull(); } else { sazehRowCurrent.divar_dakli_glb_sayer_val = ctldivar_dakli_glb_sayer_val.Text; } // divar_dakli_glb_tozi if (ctldivar_dakli_glb_tozi.Text.Length == 0) { sazehRowCurrent.Setdivar_dakli_glb_toziNull(); } else { sazehRowCurrent.divar_dakli_glb_tozi = Convert.ToInt32(ctldivar_dakli_glb_tozi.Text); } // thvil_tarikh sazehRowCurrent.thvil_tarikh = ctlthvil_tarikh.Text; // thvil_krshnas sazehRowCurrent.thvil_krshnas = Convert.ToInt32(ctlthvil_krshnas.Text); if (DataEntryMode == PageDataEntryMode.AddRow) { // // Add the new Row to the DataSet // sazehDS.sazeh.Rows.Add(sazehRowCurrent); } // // Save the changes to the database // sazehLogic.UpdateDataSet(sazehDS); // // Update the primary key values // m_szh_idCurrent = sazehRowCurrent.szh_id; return true; }
/// <summary> /// Loads a row from the sazeh table for viewing or editing /// </summary> /// <returns>true on success, false on error</returns> private bool LoadData() { if ((DataEntryMode != PageDataEntryMode.EditRow) && (DataEntryMode != PageDataEntryMode.ViewRow)) { return true; } sazehDataSet sazehDS = new sazehDataSet(); sazehService sazehLogic = new sazehService(); if (sazehLogic.GetByszh_id(sazehDS, m_szh_idCurrent) == 0) { // // sazeh Row not found // return false; } sazehDataSet.sazehRow sazehRowCurrent = sazehDS.sazeh[0]; ListItem SelectedListItem; // // Populate the Page controls from the DataRow // ctlszh_id.Text = sazehRowCurrent.szh_id.ToString(); ctlmlk_id.Text = (sazehRowCurrent.Ismlk_idNull()) ? string.Empty : sazehRowCurrent.mlk_id.ToString(); ctlrsht_id.Text = sazehRowCurrent.rsht_id.ToString(); ctlmodirt_id.Text = sazehRowCurrent.modirt_id.ToString(); ctlshrstan_id.Text = sazehRowCurrent.shrstan_id.ToString(); ctlshobh_id.Text = (sazehRowCurrent.Isshobh_idNull()) ? string.Empty : sazehRowCurrent.shobh_id; SelectedListItem = ctlfndsion_noe_id.Items.FindByValue(sazehRowCurrent.fndsion_noe_id.ToString()); if (SelectedListItem != null) { ctlfndsion_noe_id.ClearSelection(); SelectedListItem.Selected = true; } ctlfndsion_tozi.Text = (sazehRowCurrent.Isfndsion_toziNull()) ? string.Empty : sazehRowCurrent.fndsion_tozi; SelectedListItem = ctlsgf_noe_id.Items.FindByValue(sazehRowCurrent.sgf_noe_id.ToString()); if (SelectedListItem != null) { ctlsgf_noe_id.ClearSelection(); SelectedListItem.Selected = true; } ctlsgf_sayr.Text = (sazehRowCurrent.Issgf_sayrNull()) ? string.Empty : sazehRowCurrent.sgf_sayr; ctlsgf_tozi.Text = (sazehRowCurrent.Issgf_toziNull()) ? string.Empty : sazehRowCurrent.sgf_tozi; SelectedListItem = ctlsklt_noe_id.Items.FindByValue(sazehRowCurrent.sklt_noe_id.ToString()); if (SelectedListItem != null) { ctlsklt_noe_id.ClearSelection(); SelectedListItem.Selected = true; } ctlsklt_tozi.Text = (sazehRowCurrent.Issklt_toziNull()) ? string.Empty : sazehRowCurrent.sklt_tozi; ctlsklt_sayr.Text = (sazehRowCurrent.Issklt_sayrNull()) ? string.Empty : sazehRowCurrent.sklt_sayr; SelectedListItem = ctldivar_karji_glb_id.Items.FindByValue(sazehRowCurrent.divar_karji_glb_id.ToString()); if (SelectedListItem != null) { ctldivar_karji_glb_id.ClearSelection(); SelectedListItem.Selected = true; } ctldivar_dakli_glb_partition.Checked = sazehRowCurrent.divar_dakli_glb_partition; ctldivar_dakli_glb_simani.Checked = sazehRowCurrent.divar_dakli_glb_simani; ctldivar_dakli_glb_lika.Checked = sazehRowCurrent.divar_dakli_glb_lika; ctldivar_dakli_glb_hblx.Checked = sazehRowCurrent.divar_dakli_glb_hblx; ctldivar_dakli_glb_sofali.Checked = sazehRowCurrent.divar_dakli_glb_sofali; ctldivar_dakli_glb_poma.Checked = sazehRowCurrent.divar_dakli_glb_poma; ctldivar_dakli_glb_ajor.Checked = sazehRowCurrent.divar_dakli_glb_ajor; ctldivar_dakli_glb_drywall.Checked = sazehRowCurrent.divar_dakli_glb_drywall; ctldivar_dakli_glb_sayer.Checked = sazehRowCurrent.divar_dakli_glb_sayer; ctldivar_dakli_glb_sayer_val.Text = (sazehRowCurrent.Isdivar_dakli_glb_sayer_valNull()) ? string.Empty : sazehRowCurrent.divar_dakli_glb_sayer_val; ctldivar_dakli_glb_tozi.Text = (sazehRowCurrent.Isdivar_dakli_glb_toziNull()) ? string.Empty : sazehRowCurrent.divar_dakli_glb_tozi.ToString(); ctlthvil_tarikh.Text = sazehRowCurrent.thvil_tarikh; ctlthvil_krshnas.Text = sazehRowCurrent.thvil_krshnas.ToString(); return true; }