public bool SaveSection(MSeccion section) { bool Saved = false; try { DBManager DB = new DBManager(ConfigurationManager.AppSettings["SQLiteDB"]); StringBuilder WhereStatement = new StringBuilder(); WhereStatement.AppendFormat("DistritoId = {0} and Nombre like {1}", section.District.Id, Extensions.SParam(section.Nombre)); object ID = DB.GetValue("Seccion", "ID", WhereStatement.ToString()); if (ID == null) { DB.Insert("Seccion", new object[] { "ID", "null" , "Nombre", Extensions.SParam(section.Nombre) , "DistritoId", section.District.Id }); Saved = true; } } catch (Exception E) { throw E; } return(Saved); }
protected void BtnSave_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(TxtName.Text)) { MDistrito SelectedDistrict = new MDistrito(Int32.Parse(DpDistritos.SelectedItem.Value), DpDistritos.SelectedItem.Text); MSeccion NewSeccion = new MSeccion(SelectedDistrict, TxtName.Text); Saved = C.SaveSection(NewSeccion); ReloadSections(); TxtName.Text = string.Empty; } }
public List <MSeccion> GetSections() { List <MSeccion> Result = new List <MSeccion>(); try { DBManager DB = new DBManager(ConfigurationManager.AppSettings["SQLiteDB"]); DataTable DistrictsTable = DB.GetTable("V_Seccion_Distrito", new object[] { "Distrito", "ID", "Nombre" }); foreach (DataRow Row in DistrictsTable.Rows) { MSeccion S = new MSeccion(Row["Distrito"].ToString(), Int32.Parse(Row["ID"].ToString()), Row["Nombre"].ToString()); Result.Add(S); } } catch (Exception E) { throw E; } return(Result); }