public void Add_Name(object s, EventArgs e) { GridViewRow gvrow = (GridViewRow)((DropDownList)s).NamingContainer; DropDownList d = (DropDownList)gvrow.FindControl("UID_Drop"); Label TN = (Label)gvrow.FindControl("Feculty_Name"); Label HC = (Label)gvrow.FindControl("Hash_Code"); LinkButton ab = (LinkButton)gvrow.FindControl("add_button"); LinkButton ub = (LinkButton)gvrow.FindControl("update_button"); if (d.Text != "Select") { // ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "Alert", "alert('" + d.Text + "')", true); ArrayList al = new DatabaseConnectionManager().Get_Backup_Queries("SELECT Teacher_Name FROM teacher_data Where uid='" + d.Text + "'", "Teacher_Name"); TN.Text = al[0].ToString(); if (HC.Text == "") { ab.Enabled = true; } else { ub.Enabled = true; } } else { TN.Text = ""; ub.Enabled = false; ab.Enabled = false; } }
protected void add_load(Object sender, EventArgs e) { if (add_Sec.Text != "Select") { int temp_flag = 0; int skip_one = 0; String course_code = ""; String Course_title = ""; String temp = add_course.Text; for (int j = 0; j < temp.Length; j++) { if (temp[j].Equals(':')) { temp_flag = 1; } if (temp_flag == 0) { course_code += temp[j]; } else { if (skip_one == 1) { Course_title += temp[j]; } skip_one = 1; } } ArrayList sn = new DatabaseConnectionManager().Get_Query("SELECT * FROM load_table Where Course_Code='" + course_code + "' AND Section_Number='" + add_Sec.Text + "'", 3); TL.Text = int.Parse(sn[0].ToString()) + ""; TT.Text = int.Parse(sn[1].ToString()) + ""; TP.Text = int.Parse(sn[2].ToString()) + ""; int cre = 0; if (sn[0].ToString() != "0") { cre += int.Parse(sn[0].ToString()); } if (sn[1].ToString() != "0") { cre += (int.Parse(sn[1].ToString())) / 2; } if (sn[2].ToString() != "0") { cre += (int.Parse(sn[2].ToString())) / 2; } Credit.Text = cre + ""; add_new.Visible = true; add_new.Enabled = true; } else { TL.Text = 0 + ""; TT.Text = 0 + ""; TP.Text = 0 + ""; Credit.Text = "" + 0; add_new.Visible = false; } }
protected void modify_RowDataBound(object sender, GridViewRowEventArgs e) { ArrayList CA = new DatabaseConnectionManager().Get_Query("SELECT DISTINCT Course_Code,Course_Title FROM load_table where uid!='' AND Group_Label!='5'", 1); ArrayList SA = new DatabaseConnectionManager().Get_Query("SELECT DISTINCT Section_Number FROM load_table WHERE uid!=''", 2); if (e.Row.RowType == DataControlRowType.DataRow) { if ((e.Row.RowState & DataControlRowState.Edit) > 0) { DropDownList dN = (e.Row.FindControl("n") as DropDownList); DropDownList SN = (e.Row.FindControl("SN") as DropDownList); //dN.ID = "1"; //SN.DataSource = SA; //SN.DataBind(); dN.DataSource = CA; Label lc = (e.Row.FindControl("CC_Label") as Label); dN.DataBind(); } banner_update(); } ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "", "Close_add_pop();", true); banner_update(); }
private static bool Configure(string connectionId, Func <DatabaseConnectionConfiguration, bool> validateConfigFunc) { var configurationIsOk = false; try { using (var dialog = new DataConnectionDialog()) { dialog.ChooseDataSourceTitle = $"Database connection: {connectionId}"; dialog.Title = $"Database connection: {connectionId}"; // If you want the user to select from any of the available data sources, do this: DataSource.AddStandardDataSources(dialog); // OR, if you want only certain data sources to be available // (e.g. only SQL Server), do something like this instead: //dialog.DataSources.Add(DataSource.SqlDataSource); //dialog.DataSources.Add(DataSource.SqlFileDataSource); while (!configurationIsOk) { // The way how you show the dialog is somewhat unorthodox; `dialog.ShowDialog()` // would throw a `NotSupportedException`. Do it this way instead: DialogResult userChoice = DataConnectionDialog.Show(dialog); // Return the resulting connection string if a connection was selected: if (userChoice == DialogResult.OK) { var config = new DatabaseConnectionConfiguration(); config.ConnectionString = dialog.ConnectionString; config.ConnectionId = connectionId; if (dialog.SelectedDataSource.Name.Contains("Oracle")) { config.DatabaseType = EDatabaseType.Oracle; } else { config.DatabaseType = EDatabaseType.MSSQLServer; } DatabaseConnectionManager.SaveConfiguration(config); configurationIsOk = validateConfigFunc(config); } else { configurationIsOk = false; } } } } catch (Exception e) { MessageBox.Show(e.Message); } return(configurationIsOk); }
//returns the current available charity organisations public List <CharOrg> query() { using (var _dcm = new DatabaseConnectionManager()) { IEnumerable <CharOrg> charOrgList = (from x in _dcm.CharOrgs select x); return(charOrgList.ToList()); } }
public int query() { using (var _dcm = new DatabaseConnectionManager()) { int count = _dcm.FoodItems.Count(x => x.Id == id); return(count); } }
public long query() { using (var _dcm = new DatabaseConnectionManager()) { User query_user = _dcm.Users.Where(x => (x.Username == username && x.Password == password)).FirstOrDefault(); return(query_user.Id); } }
//returns the food items for the user identified by uid, that will expire between leftTime and rightTime public List <FoodItem> getFoodListExp(long id, DateTime leftDate, DateTime rightDate) { using (var _dcm = new DatabaseConnectionManager()) { IEnumerable <FoodItem> food_item_enum = _dcm.FoodItems.Where(x => (x.User_id == id && x.ExpDate <= rightDate && x.ExpDate >= leftDate && x.ConsDate == null)); return(food_item_enum.ToList()); } }
public DateTime query() { using (var _dcm = new DatabaseConnectionManager()) { User query_user = _dcm.Users.Where(x => x.Username == username).FirstOrDefault(); return(query_user.LastSent); } }
public List <FoodItem> GetUnmarkedFoodItems() { using (var _dcm = new DatabaseConnectionManager()) { IEnumerable <FoodItem> food_item_enum = _dcm.FoodItems.Where(x => (x.Marked == false && x.ExpDate <= DateTime.Now)); return(food_item_enum.ToList()); } }
public FoodItem getFoodItem(long id) { using (var _dcm = new DatabaseConnectionManager()) { FoodItem foodItem = _dcm.FoodItems.Where(x => x.Id == id).FirstOrDefault(); return(foodItem); } }
public MailBot query() { using (var _dcm = new DatabaseConnectionManager()) { MailBot mailBot = _dcm.MailBots.First(); return(mailBot); } }
public string query() { using (var _dcm = new DatabaseConnectionManager()) { User query_user = _dcm.Users.Where(x => x.Username == username).FirstOrDefault(); return(query_user.Mail); } }
public void addFoodItem(FoodItem fi) { using (var _dcm = new DatabaseConnectionManager()) { _dcm.Add(fi); _dcm.SaveChanges(); } }
public List <FoodItem> get_food_list(long id) { using (var _dcm = new DatabaseConnectionManager()) { IEnumerable <FoodItem> food_item_enum = (from _food_item in _dcm.FoodItems where _food_item.User_id == id select _food_item).AsEnumerable(); return(food_item_enum.ToList()); } }
public void banner_update() { T_Uid.Text = uid; ArrayList load = new DatabaseConnectionManager().Get_Load(uid); T_Total.Text = load[0].ToString(); T_Credit.Text = load[1].ToString(); T_Max.Text = load[2].ToString(); }
public void removeFoodItem(long id) { using (var _dcm = new DatabaseConnectionManager()) { var foodItem = _dcm.FoodItems.Find(id); _dcm.FoodItems.Remove(foodItem); _dcm.SaveChanges(); } }
protected void SN_TextChanged(object sender, EventArgs e) { // ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Selected')", true); GridViewRow gvrow = (GridViewRow)((DropDownList)sender).NamingContainer; DropDownList ds = (DropDownList)gvrow.FindControl("SN"); DropDownList dd = (DropDownList)gvrow.FindControl("n"); Label AL = (Label)gvrow.FindControl("AL"); Label CR = (Label)gvrow.FindControl("Credit"); int temp_flag = 0; int skip_one = 0; String course_code = ""; String Course_title = ""; String temp = dd.Text; for (int j = 0; j < temp.Length; j++) { if (temp[j].Equals(':')) { temp_flag = 1; } if (temp_flag == 0) { course_code += temp[j]; } else { if (skip_one == 1) { Course_title += temp[j]; } skip_one = 1; } } ArrayList sn = new DatabaseConnectionManager().Get_Query("SELECT * FROM load_table Where Course_Code='" + course_code + "' AND Section_Number='" + ds.Text + "'", 3); AL.Text = int.Parse(sn[0].ToString()) + int.Parse(sn[1].ToString()) + int.Parse(sn[2].ToString()) + ""; int cre = 0; if (sn[0].ToString() != "0") { cre += int.Parse(sn[0].ToString()); } if (sn[1].ToString() != "0") { cre += (int.Parse(sn[1].ToString())) / 2; } if (sn[2].ToString() != "0") { cre += (int.Parse(sn[2].ToString())) / 2; } CR.Text = cre + ""; //ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('"+sn[0].ToString()+"-"+sn[1].ToString()+"-"+course_code+"')", true); }
public void editConsDate(long id, DateTime?consDate) { using (var _dcm = new DatabaseConnectionManager()) { var foodItem = _dcm.FoodItems.Find(id); foodItem.ConsDate = consDate; _dcm.FoodItems.Update(foodItem); _dcm.SaveChanges(); } }
public int query() { int count = 0; using (var _dcm = new DatabaseConnectionManager()) { count = _dcm.Users.Count(x => (x.Username == username && x.Password == password)); } return(count); }
private DownloadDetails AddDownloadDetails(DownloadDetails downloadDetails) { _downloadDetails.AddOrUpdate(downloadDetails.DownloadId ?? Int32.MaxValue, downloadDetails, (previous, current) => downloadDetails); var connection = DatabaseConnectionManager.GetConnection(); connection.InsertOrReplace(downloadDetails); connection.Commit(); return(downloadDetails); }
public void RemoveDownloadDetails(int downloadId) { if (_downloadDetails.ContainsKey(downloadId)) { _downloadDetails.TryRemove(downloadId, out var downloadDetail); var connection = DatabaseConnectionManager.GetConnection(); connection.Delete(downloadDetail); connection.Commit(); } }
public void TestSetup() { databaseConnection = new DatabaseConnectionManager(Properties.Settings.Default.TestDatabase); List <AgentDataModel> agents = databaseConnection.GetAgentsFromDatabase(); if (agents.Count == 0) { databaseConnection.AddAgentToDatabase(agent, false, false); } }
public static bool Configure(DatabaseConnectionConfiguration configuration) { try { using (var dialog = new DataConnectionDialog()) { dialog.ChooseDataSourceTitle = $"Database connection: {configuration.ConnectionId}"; dialog.Title = $"Database connection: {configuration.ConnectionId}"; DataSource.AddStandardDataSources(dialog); if (!string.IsNullOrEmpty(configuration.ConnectionString)) { if (configuration.DatabaseType == EDatabaseType.MSSQLServer) { dialog.SelectedDataSource = DataSource.SqlDataSource; } else { dialog.SelectedDataSource = DataSource.OracleDataSource; } dialog.ConnectionString = configuration.ConnectionString; } DialogResult userChoice = DataConnectionDialog.Show(dialog); // Return the resulting connection string if a connection was selected: if (userChoice == DialogResult.OK) { configuration.ConnectionString = dialog.ConnectionString; if (dialog.SelectedDataSource.Name.Contains("Oracle")) { configuration.DatabaseType = EDatabaseType.Oracle; } else { configuration.DatabaseType = EDatabaseType.MSSQLServer; } DatabaseConnectionManager.SaveConfiguration(configuration); return(true); } } } catch (Exception e) { MessageBox.Show(e.Message); } return(false); }
public bool command() { bool res = false; using (var _dcm = new DatabaseConnectionManager()) { _dcm.Add(fi); _dcm.SaveChanges(); res = true; } return(res); }
protected void add_btn(object sender, EventArgs e) { // ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('ss')", true); add_UID.Text = uid; ArrayList load = new DatabaseConnectionManager().Get_Load(uid); add_AL.Text = load[0].ToString(); add_credit.Text = load[1].ToString(); new DatabaseConnectionManager().Load_Domain(Select_Domain); Select_Domain.Items.Add("Select"); Select_Domain.Text = "Select"; ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "", "Show_add_pop();", true); }
public bool command() { bool res = false; using (var _dcm = new DatabaseConnectionManager()) { var foodItem = _dcm.FoodItems.Find(id); _dcm.FoodItems.Remove(foodItem); _dcm.SaveChanges(); res = true; } return(res); }
public void UpdateMarked(List <FoodItem> foodItems) { using (var _dcm = new DatabaseConnectionManager()) { foreach (FoodItem fi in foodItems) { FoodItem nfi = _dcm.FoodItems.Where(x => x.Id == fi.Id).FirstOrDefault(); nfi.Marked = true; _dcm.FoodItems.Update(nfi); _dcm.SaveChanges(); } } }
public bool command() { bool res = false; using (var _dcm = new DatabaseConnectionManager()) { var user = _dcm.Users.Find(uid); user.LastSent = date; _dcm.Users.Update(user); _dcm.SaveChanges(); res = true; } return(res); }
public static void InitializeDatabaseAccessClasses(IDataContextHandler dataContextHandler, IDatabaseConnectionConfigurationStorage configurationStorage, IDatabaseConnectionConfigurator connectionConfigurator, params Type[] dbContextTypes) { DatabaseConnectionConfigurationStorage = configurationStorage; DatabaseConnectionConfigurator = connectionConfigurator; DataContextManager.Initialize(dataContextHandler); DatabaseConnectionManager.Initialize(configurationStorage); foreach (var dbType in dbContextTypes) { dataContextHandler.RegisterDataContextType(dbType); } }
public IDbConnection CreateConnection(IUpgradeLog upgradeLog, DatabaseConnectionManager databaseConnectionManager) { return createConnection(upgradeLog, databaseConnectionManager); }