public static void MyClassInitialize(TestContext testContext) { SessionManager.Instance.UpdateSchema(); var driver = new DBDriver(SessionManager.Instance.CurrentSession.Connection); Guid userId1 = Guid.NewGuid(); Guid userId2 = Guid.NewGuid(); Guid roleId = Guid.NewGuid(); MyClassCleanup(); DataHelper.CreateInstance().Initailze(driver) .Insert(UnitTestHelper.RoleTable) .Columns(new[] {"Id", "Name", "Comment"}) .Values(new object[] {roleId, "role1", "comment"}) .NewCommand() .Insert(UnitTestHelper.UserTable) .Columns(new[] {"Id", "loginid", "UpdateTime", "LastActivityDate", "Email"}) .Values ( new object[] {userId1, "UserDaoTest1", DateTime.Now, LastActivityDate, "Email1" + EmailHostName}, new object[] {userId2, "UserDaoTest2", DateTime.Now, LastActivityDate, "Email2" + EmailHostName} ) .NewCommand() .Insert(UnitTestHelper.UserRoleRelation) .Columns("RoleId", "UserId") .Values(new object[] {roleId, userId1}, new object[] {roleId, userId2}) .Execute(); SessionManager.Instance.CleanUp(); }
public static void MyClassCleanup() { var driver = new DBDriver(SessionManager.Instance.CurrentSession.Connection); DataHelper.CreateInstance().Initailze(driver).Delete("Ornament_MemberShip_Member"). Execute(); }
public static void MyClassCleanup() { var driver = new DBDriver(SessionManager.Instance.CurrentSession.Connection); DataHelper.CreateInstance().Initailze(driver) .Delete("CoreTest_Tips").Execute(); }
public void SaveAdnGet() { ISession session = SessionManager.Instance.CurrentSession; var driver = new DBDriver(SessionManager.Instance.CurrentSession.Connection); try { var t = new Entity(); t.Collection.Add("key1", "value1"); t.Collection.Add("key2", "value2"); session.SaveOrUpdate(t); session.Flush(); DataTable table; DataHelper.CreateInstance().Initailze(driver) .Select("CoreTest_Entity").Into(out table).Execute(); string s = "<?xml version=\"1.0\" encoding=\"utf-8\"?><keyValue><i k=\"key1\">value1</i><i k=\"key2\">value2</i></keyValue>"; Assert.AreEqual(s, table.Rows[0]["Collection"].ToString()); t = session.Get<Entity>(t.Id); Assert.AreEqual("value1", t.Collection["key1"]); Assert.AreEqual("value2", t.Collection["key2"]); } finally { DataHelper.CreateInstance() .Initailze(driver).Delete("CoreTest_Tips"). Execute(); } }
private void compMatrixGrid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { DBDriver myDB=new DBDriver(); //retrieve the new values from the datagrid TextBox tb; tb=(TextBox)e.Item.Cells[1].Controls[0]; string low=tb.Text; tb=(TextBox)e.Item.Cells[2].Controls[0]; string med=tb.Text; tb=(TextBox)e.Item.Cells[3].Controls[0]; string high=tb.Text; string level = e.Item.Cells[0].Text; //store new values to DB myDB.Query="update compMatrix set lowComplexity=@low, medComplexity=@med, highComplexity=@high where compLevel=@level;"; myDB.addParam("@low", low); myDB.addParam("@med", med); myDB.addParam("@high", high); myDB.addParam("@level", level); myDB.nonQuery(); //make sure nothing is being edited, and reload the page this.compMatrixGrid.EditItemIndex=-1; Response.Redirect(Request.Url.AbsolutePath); }
public void SaveAdnGet() { ISession session = SessionManager.Instance.CurrentSession; var driver = new DBDriver(SessionManager.Instance.CurrentSession.Connection); try { var t = new Entity(); t.Collection.Add("key1", "value1"); t.Collection.Add("key2", "value2"); session.SaveOrUpdate(t); session.Flush(); DataTable table; DataHelper.CreateInstance().Initailze(driver) .Select("CoreTest_Entity").Into(out table).Execute(); string s = "<?xml version=\"1.0\" encoding=\"utf-8\"?><keyValue><i k=\"key1\">value1</i><i k=\"key2\">value2</i></keyValue>"; Assert.AreEqual(s, table.Rows[0]["Collection"].ToString()); t = session.Get <Entity>(t.Id); Assert.AreEqual("value1", t.Collection["key1"]); Assert.AreEqual("value2", t.Collection["key2"]); } finally { DataHelper.CreateInstance() .Initailze(driver).Delete("CoreTest_Tips"). Execute(); } }
public static void MyClassInitialize(TestContext testContext) { SessionManager.Instance.UpdateSchema(); var driver = new DBDriver(SessionManager.Instance.CurrentSession.Connection); Guid userId1 = Guid.NewGuid(); Guid userId2 = Guid.NewGuid(); Guid roleId = Guid.NewGuid(); MyClassCleanup(); DataHelper.CreateInstance().Initailze(driver) .Insert(UnitTestHelper.RoleTable) .Columns(new[] { "Id", "Name", "Comment" }) .Values(new object[] { roleId, "role1", "comment" }) .NewCommand() .Insert(UnitTestHelper.UserTable) .Columns(new[] { "Id", "loginid", "UpdateTime", "LastActivityDate", "Email" }) .Values ( new object[] { userId1, "UserDaoTest1", DateTime.Now, LastActivityDate, "Email1" + EmailHostName }, new object[] { userId2, "UserDaoTest2", DateTime.Now, LastActivityDate, "Email2" + EmailHostName } ) .NewCommand() .Insert(UnitTestHelper.UserRoleRelation) .Columns("RoleId", "UserId") .Values(new object[] { roleId, userId1 }, new object[] { roleId, userId2 }) .Execute(); SessionManager.Instance.CleanUp(); }
public void SaveAndUpdate() { var session = SessionManager.Instance.CurrentSession; var driver = new DBDriver(session.Connection); try { var t = new Tips { PerformTime = new Time(13, 0, 0), PopupTime = new Time(12, 12, 12) }; session.SaveOrUpdate(t); session.Flush(); DataTable table; DataHelper.CreateInstance().Initailze(driver) .Select("CoreTest_Tips").Into(out table).Execute(); Assert.AreEqual(table.Rows[0]["PerformTime"].ToString(), t.PerformTime.Ticks.ToString()); Assert.AreEqual(table.Rows[0]["PopupTime"].ToString(), t.PopupTime.ToString()); } finally { DataHelper.CreateInstance() .Initailze(driver).Delete("CoreTest_Tips"). Execute(); } }
private void compMatrixGrid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { DBDriver myDB = new DBDriver(); //retrieve the new values from the datagrid TextBox tb; tb = (TextBox)e.Item.Cells[1].Controls[0]; string low = tb.Text; tb = (TextBox)e.Item.Cells[2].Controls[0]; string med = tb.Text; tb = (TextBox)e.Item.Cells[3].Controls[0]; string high = tb.Text; string level = e.Item.Cells[0].Text; //store new values to DB myDB.Query = "update compMatrix set lowComplexity=@low, medComplexity=@med, highComplexity=@high where compLevel=@level;"; myDB.addParam("@low", low); myDB.addParam("@med", med); myDB.addParam("@high", high); myDB.addParam("@level", level); myDB.nonQuery(); //make sure nothing is being edited, and reload the page this.compMatrixGrid.EditItemIndex = -1; Response.Redirect(Request.Url.AbsolutePath); }
private void cleanMail_Click(object sender, System.EventArgs e) { DBDriver myDB = new DBDriver(); myDB.Query = "delete from messages where ID not in (select messageID from recipients);"; myDB.nonQuery(); }
private void Page_Load(object sender, System.EventArgs e) { //initialize the DB object DBDriver myDB = new DBDriver(); //set the appropriate SQL query myDB.Query = "select t.ID as taskID, t.name as name, m.name as moduleName, p.name as projectName,\n" + "t.actEndDate as actEndDate, t.complete as complete, a.dateAss as dateAss, a.devID, a.taskID\n" + "from tasks t, assignments a, modules m, projects p\n" + "where t.ID = a.taskID and a.devID = @devID\n" + "and t.moduleID = m.ID\n" + "and m.projectID = p.ID\n" + "order by p.name, m.name, t.name;"; myDB.addParam("@devID", Request.Cookies["user"]["id"]); //initialize the dataset DataSet ds = new DataSet(); //initialize the data adapter //fill the dataset;this is updated myDB.createAdapter().Fill(ds); //fill the display grid DataGrid1.DataSource = ds; if (!Page.IsPostBack) { DataGrid1.DataBind(); } }
/// <summary> /// Override the original run method defined by the super-class because /// we don't want to run an actual calculation. Plots the data for /// every selected time-step. /// </summary> protected void Run() { ISessionInfo session = m_Database.Controller.GetSessionInfo(m_config.SessionGuid); var timesteps = session.Timesteps.Where( tsi => this.m_config.TimeSteps.Contains(tsi.TimeStepNumber)).ToArray(); int TotCnt = timesteps.Count(); int process = this.DBDriver.MyRank + 1; int processCount = this.DBDriver.Size; this.m_info = this.m_Database.Controller.GetSessionInfo(this.m_config.SessionGuid); GC.Collect(); for (int i = 0; i < timesteps.Length; i++) { var ts = timesteps[i]; double physTime = ts.PhysicalTime; TimestepNumber timestepNo = ts.TimeStepNumber; if (this.GridDat == null || !this.GridDat.Grid.ID.Equals(ts.Grid.ID)) { WriteMessage(process, processCount, "Loading grid ..."); GridCommons grid = DBDriver.LoadGrid(ts.Grid.ID, m_Database); this.GridDat = this.m_Database.Controller.GetInitializationContext(ts).GridData; WriteMessage(process, processCount, " Number of cells: " + this.GridDat.Grid.NoOfUpdateCells); this.CreatePlotter(); } WriteMessage(process, processCount, "Loading timestep ... (" + (i + 1) + " of " + TotCnt + ")"); var fields = DBDriver.LoadFields(ts, this.GridDat, this.m_config.FieldNames).ToList(); WriteMessage(process, processCount, "Loaded timestep " + timestepNo + ". Plotting..."); //{ // Console.WriteLine("computing vorticity..."); // DGField velX = fields.Single(f => f.Identification == "VelocityX"); // DGField velY = fields.Single(f => f.Identification == "VelocityY"); // DGField vortZ = velX.CloneAs(); // vortZ.Identification = "Vorticity"; // vortZ.Clear(); // vortZ.DerivativeByFlux(1.0, velY, 0); // vortZ.DerivativeByFlux(-1.0, velX, 1); // Console.WriteLine("done."); // fields.Add(vortZ); //} PlotCurrentState(fields, physTime, timestepNo); double perc = Math.Round(100.0 * (double)(i + 1) / (double)TotCnt, 1); WriteMessage(process, processCount, "Finished timestep (" + perc + "% of timesteps done)"); // Free memory if possible timesteps[i] = null; GC.Collect(); } }
public static void MyClassCleanup() { var driver = new DBDriver(SessionManager.Instance.CurrentSession.Connection); DataHelper.CreateInstance().Initailze(driver) .Delete(UnitTestHelper.UserRoleRelation).Execute().Delete("Ornament_MemberShip_User").Execute() .Delete("Ornament_MemberShip_Role").Execute(); CurrentSessionContext.Unbind(SessionManager.Instance.GetSessionFactory()).Close(); }
public static void MyClassCleanup() { var driver = new DBDriver(SessionManager.Instance.CurrentSession.Connection); DataHelper.CreateInstance().Initailze(driver) .Delete(UnitTestHelper.UserRoleRelation) .NewCommand() .Delete(UnitTestHelper.UserTable).NewCommand() .Delete(UnitTestHelper.RoleTable).Execute(); }
private void MessagesDataGrid_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { //add appropriate warning popup and Database delete statement here string delID = this.MessagesDataGrid.Items[e.Item.ItemIndex].Cells[0].Text; DBDriver myDB = new DBDriver(); myDB.Query = "delete from recipients where recipientID=@rID and MessageID=@mID;"; myDB.addParam("@rID", Request.Cookies["user"]["id"]); myDB.addParam("@mID", delID); myDB.nonQuery(); Response.Redirect(Request.Url.AbsolutePath); }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if(!this.IsPostBack) { DBDriver myDB=new DBDriver(); myDB.Query="select * from compMatrix;"; DataSet ds=new DataSet(); myDB.createAdapter().Fill(ds); this.compMatrixGrid.DataSource=ds; this.compMatrixGrid.DataBind(); } }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (!this.IsPostBack) { DBDriver myDB = new DBDriver(); myDB.Query = "select * from compMatrix;"; DataSet ds = new DataSet(); myDB.createAdapter().Fill(ds); this.compMatrixGrid.DataSource = ds; this.compMatrixGrid.DataBind(); } }
private static void LoadCache(object s) { int minId = 0; if (phones == null) { phones = new Dictionary <int, tbl_phone_locateItem>(); } else { minId = phones.Values.Max(e => e.id); } System.Diagnostics.Stopwatch st = new System.Diagnostics.Stopwatch(); st.Start(); using (var dBase = new DBDriver().CreateDBase()) { var q = GetQueries(dBase); q.Filter.AndFilters.Add(tbl_phone_locateItem.identifyField, minId, Shotgun.Model.Filter.EM_DataFiler_Operator.More); q.SortKey.Add(tbl_phone_locateItem.identifyField, Shotgun.Model.Filter.EM_SortKeyWord.asc); q.PageSize = 2000; var count = q.TotalCount; var pageCount = count / q.PageSize + ((count % q.PageSize) > 0 ? 1 : 0); bool iDone = true; for (int p = 1; p <= pageCount; p++) { q.CurrentPage = p; try { var itmes = q.GetDataList(); itmes.ForEach(e => phones[int.Parse(e.phone)] = e); } catch (System.Data.DataException) { iDone = false; break; } } cacheStatus = iDone ? 2 : 0; st.Stop(); Shotgun.Library.SimpleLogRecord.WriteLog("load_cache", string.Format("threadId:{0} tbl_phone_locateItem cache Elapsed {1:#,###}ms ,count {2}", System.Threading.Thread.CurrentThread.ManagedThreadId, st.ElapsedMilliseconds, phones.Count) ); } }
private void cleanPeople_Click(object sender, System.EventArgs e) { DBDriver myDB=new DBDriver(); myDB.Query="create table temp(id int);"; myDB.nonQuery(); myDB.Query="insert into temp (id) select id from users;"; myDB.nonQuery(); myDB.Query="insert into temp (id) select id from newUsers;"; myDB.nonQuery(); myDB.Query="delete from person where id not in (select id from temp);"; myDB.nonQuery(); myDB.Query="drop table temp;"; myDB.nonQuery(); }
private void cleanPeople_Click(object sender, System.EventArgs e) { DBDriver myDB = new DBDriver(); myDB.Query = "create table temp(id int);"; myDB.nonQuery(); myDB.Query = "insert into temp (id) select id from users;"; myDB.nonQuery(); myDB.Query = "insert into temp (id) select id from newUsers;"; myDB.nonQuery(); myDB.Query = "delete from person where id not in (select id from temp);"; myDB.nonQuery(); myDB.Query = "drop table temp;"; myDB.nonQuery(); }
private void Page_Load(object sender, System.EventArgs e) { DBDriver myDB = new DBDriver(); // Put user code to initialize the page here string role = Request.Cookies["user"]["role"]; string userID = Request.Cookies["user"]["id"]; // fill the contact list if (!this.IsPostBack) { if (role.Equals(PMT.User.Security.CLIENT)) { myDB.Query = "select u.userName as userName, u.id as ID\n" + "from users u, clients c\n" + "where u.id = c.managerID\n" + "and c.clientID = @clientID;"; myDB.addParam("@clientID", userID); } else { myDB.Query = "select userName, id from users;"; } DataSet ds2 = new DataSet(); myDB.createAdapter().Fill(ds2); //create a datatable to fill the dropdown list from DataTable dt = ds2.Tables[0]; //fill the Contacts list box ContactsListBox.DataSource = dt.DefaultView; ContactsListBox.DataTextField = "userName"; ContactsListBox.DataValueField = "id"; ContactsListBox.DataBind(); // fill the inbox myDB.Query = "select m.ID messID, u.userName sender, m.subject subject, m.timestamp date, m.ID id from users u, messages m, recipients r" + " where r.recipientID=@me and m.ID=r.messageID and u.ID=m.senderID;"; myDB.addParam("@me", Request.Cookies["user"]["id"]); DataSet ds = new DataSet(); //initialize the data adapter //fill the dataset myDB.createAdapter().Fill(ds); //fill the display grid this.MessagesDataGrid.DataSource = ds; this.MessagesDataGrid.DataBind(); } }
/// <summary> /// Send the message /// </summary> private void SendButton_Click(object sender, System.EventArgs e) { if (!Page.IsValid) { return; } //string from = user.Name; ArrayList toList = new ArrayList(); foreach (ListItem item in ToListBox.Items) { toList.Add(item.Value); } //Message msg = new Message(from, toList, message); string time = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss"); // insert into database DBDriver myDB = new DBDriver(); myDB.Query = "insert into messages (SenderID, Subject, Body, timestamp)\n" + "values (@sender, @subject, @body, @time);"; myDB.addParam("@sender", Request.Cookies["user"]["id"]); myDB.addParam("@subject", this.SubjectTextBox.Text); myDB.addParam("@body", this.MessageTextBox.InnerText); myDB.addParam("@time", time); myDB.nonQuery(); myDB.Query = "select id from messages where timestamp=@time;"; myDB.addParam("@time", time); int mID = Convert.ToInt32(myDB.scalar()); //insert into the recipients table as well for (int i = 0; i < this.ToListBox.Items.Count; i++) { myDB.Query = "insert into recipients (MessageID, RecipientID, Timestamp) values (@id, @recipient, @time);"; myDB.addParam("@id", mID); myDB.addParam("@recipient", this.ToListBox.Items[i].Value); myDB.addParam("@time", time); myDB.nonQuery(); } Server.Transfer(Request.Url.AbsolutePath); }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here DBDriver myDB=new DBDriver(); string mID=Request.QueryString["id"]; myDB.Query="select u.userName sender, m.subject subject, m.timestamp date, m.body body from users u, messages m where m.ID=@mID and u.ID=m.senderID;"; myDB.addParam("@mID", mID); SqlDataReader dr=myDB.createReader(); dr.Read(); this.subjectLabel.Text=Convert.ToString(dr["subject"]); this.senderLabel.Text=Convert.ToString(dr["sender"]); this.dateLabel.Text=Convert.ToString(dr["date"]); this.messageLabel.Text=Convert.ToString(dr["body"]); myDB.close(); }
private void DeveloperDropDownList_SelectedIndexChanged(object sender, System.EventArgs e) { /* * get developer info and display it ... * * */ //initialize the DB object DBDriver myDB = new DBDriver(); //set the appropriate SQL query myDB.Query = "select person.ID, firstName, lastName, competence" + " from person, compLevels" + " where person.ID = compLevels.ID and person.ID=@devID;"; myDB.addParam("@devID", DeveloperDropDownList.SelectedValue); //initialize the datareader SqlDataReader dr = myDB.createReader(); //fill the datareader dr.Read(); this.CancelButton.Visible = true; //reset buttons this.SaveButton.Visible = true; this.CompetenceDropDownList.Visible = true; try { this.devFirstLabel.Text = Convert.ToString(dr["firstName"]); this.devLastLabel.Text = Convert.ToString(dr["lastName"]); this.CompetenceDropDownList.SelectedValue = dr["competence"].ToString(); } catch { this.devFirstLabel.Text = "ERROR"; this.devLastLabel.Text = "ERROR"; } myDB.close(); DeveloperPanel.Visible = true; }
/// <summary> /// Override the original run method defined by the super-class because /// we don't want to run an actual calculation. Plots the data for /// every selected time-step. /// </summary> protected void Run() { ISessionInfo session = m_Database.Controller.GetSessionInfo(m_config.SessionGuid); var timesteps = session.Timesteps.Where( tsi => this.m_config.TimeSteps.Contains(tsi.TimeStepNumber)).ToArray(); int TotCnt = timesteps.Count(); int process = this.DBDriver.MyRank + 1; int processCount = this.DBDriver.Size; this.m_info = this.m_Database.Controller.GetSessionInfo(this.m_config.SessionGuid); GC.Collect(); for (int i = 0; i < timesteps.Length; i++) { var ts = timesteps[i]; double physTime = ts.PhysicalTime; TimestepNumber timestepNo = ts.TimeStepNumber; if (this.GridDat == null || !this.GridDat.Grid.ID.Equals(ts.Grid.ID)) { WriteMessage(process, processCount, "Loading grid ..."); GridCommons grid = DBDriver.LoadGrid(ts.Grid.ID, m_Database); this.GridDat = this.m_Database.Controller.GetInitializationContext(ts).GridData; WriteMessage(process, processCount, " Number of cells: " + this.GridDat.Grid.NoOfUpdateCells); this.CreatePlotter(); } WriteMessage(process, processCount, "Loading timestep ... (" + (i + 1) + " of " + TotCnt + ")"); var fields = DBDriver.LoadFields(ts, this.GridDat, this.m_config.FieldNames); WriteMessage(process, processCount, "Loaded timestep " + timestepNo + ". Plotting..."); PlotCurrentState(fields, physTime, timestepNo); double perc = Math.Round(100.0 * (double)(i + 1) / (double)TotCnt, 1); WriteMessage(process, processCount, "Finished timestep (" + perc + "% of timesteps done)"); // Free memory if possible timesteps[i] = null; GC.Collect(); } }
static void Main(string[] args) { DBDriver db = new DBDriver(@"SQL5016.Smarterasp.net", @"DB_9D003D_cts1_admin", @"cts1CoolDbUser", @"db_9d003d_cts1"); Console.WriteLine("Created Object DBDriver with Connection String: " + db.ConnString); User user = new User(db); try { Console.WriteLine("New Empty User instance: \n" + user); user.Name = "my_new_user_vasya"; user.Password = "******"; user.RealName = "Василий Пупкин"; user.RoleId = 1; user.GroupId = 1; user.Email = "*****@*****.**"; Console.WriteLine("User Created: \n" + (user = user.Create())); Console.WriteLine("Check if User 'my_new_user_vasya' with password '123456' exists: " + user.CheckIfExists()); Console.WriteLine("Login Under User 'my_new_user_vasya' with password '123456'" + user.SignIn()); Console.WriteLine("Get user with this id from database: \n" + (user = user.Get(user.Id))); user.RealName = "Не Василий Не Пупкин"; user.AddContact("skype", "vasya_pupkin"); user.AddContact("twitter", "vasya_twitter"); user.Update(); Console.WriteLine("Update user with current id: \n" + (user = user.Update())); user.ChangePassword("123456789"); Console.WriteLine("Changed Paddword for user with current id: \n" + (user = user.Get(user.Id))); user.Delete(); } catch (Exception e) { throw e; } finally { user.Delete(); } }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if(!Page.IsPostBack) { //fill the datagrid with wannabe users DBDriver myDB=new DBDriver(); myDB.Query="select u.id id, u.username username, u.security security, p.firstname first, p.lastname last from users u, person p where p.id=u.id;"; //initialize the dataset DataSet ds=new DataSet(); //initialize the data adapter //fill the dataset myDB.createAdapter().Fill(ds); //fill the display grid UserDataGrid.DataSource=ds; UserDataGrid.DataBind(); } }
private void CommitButton_Click(object sender, System.EventArgs e) { DBDriver db = new DBDriver(); foreach (DataGridItem itm in DataGrid1.Items) { CheckBox cb = (CheckBox)itm.FindControl("CompleteCheckBox"); if (cb.Enabled) { db.Query = "update tasks set complete=@complete\n" + "where id=@id;"; db.addParam("@complete", cb.Checked?TaskStatus.COMPLETE:TaskStatus.INPROGRESS); db.addParam("@id", itm.Cells[0].Text); db.nonQuery(); } } Server.Transfer(Request.Url.AbsolutePath); }
private void syncCompetenceText() { //initialize the DB object DBDriver myDB = new DBDriver(); //set the appropriate SQL query myDB.Query = "select ID, competence" + " from compLevels" + " where compLevels.ID=@devID;"; myDB.addParam("@devID", DeveloperDropDownList.SelectedValue); //initialize the datareader SqlDataReader dr = myDB.createReader(); //fill the datareader dr.Read(); this.CompetenceDropDownList.SelectedValue = Convert.ToString(dr["competence"]); myDB.close(); }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (!Page.IsPostBack) { //fill the datagrid with wannabe users DBDriver myDB = new DBDriver(); myDB.Query = "select u.id id, u.username username, u.security security, p.firstname first, p.lastname last from users u, person p where p.id=u.id;"; //initialize the dataset DataSet ds = new DataSet(); //initialize the data adapter //fill the dataset myDB.createAdapter().Fill(ds); //fill the display grid UserDataGrid.DataSource = ds; UserDataGrid.DataBind(); } }
private void CommitButton_Click(object sender, System.EventArgs e) { DBDriver db = new DBDriver(); foreach (DataGridItem itm in DataGrid1.Items) { CheckBox cb = (CheckBox)itm.FindControl("CompleteCheckBox"); if(cb.Enabled) { db.Query = "update tasks set complete=@complete\n" + "where id=@id;"; db.addParam("@complete", cb.Checked?TaskStatus.COMPLETE:TaskStatus.INPROGRESS); db.addParam("@id", itm.Cells[0].Text); db.nonQuery(); } } Server.Transfer(Request.Url.AbsolutePath); }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here DBDriver myDB = new DBDriver(); string mID = Request.QueryString["id"]; myDB.Query = "select u.userName sender, m.subject subject, m.timestamp date, m.body body from users u, messages m where m.ID=@mID and u.ID=m.senderID;"; myDB.addParam("@mID", mID); SqlDataReader dr = myDB.createReader(); dr.Read(); this.subjectLabel.Text = Convert.ToString(dr["subject"]); this.senderLabel.Text = Convert.ToString(dr["sender"]); this.dateLabel.Text = Convert.ToString(dr["date"]); this.messageLabel.Text = Convert.ToString(dr["body"]); myDB.close(); }
public static bool Connect() { //Set up mysql bool status = false; string sdriver = ""; Settings.Get <string> ("db.driver", out sdriver); if (!Enum.TryParse <DBDriver>(sdriver, out driver)) { Program.debugMsgs.Enqueue("No database driver has been specified"); //No database has been specified driver = DBDriver.None; } if (driver == DBDriver.MySql) { Settings.Get <string>("db.host", out host); Settings.Get <string>("db.database", out db); Settings.Get <string>("db.username", out username); Settings.Get <string>("db.password", out password); Console.WriteLine("MYSQL Connection Connection Attempt."); MySqlConnection contest = new MySqlConnection(string.Format("Server={0};Database={1};User ID={2};Password={3}", host, db, username, password)); try { contest.Open(); } catch (Exception e) { Console.WriteLine("[E] Connection to DB failed!\n Server will be in low functionality until this is fixed!"); Console.WriteLine("[E] Exception Details:" + e.Message); driver = DBDriver.None; } if (contest.State == System.Data.ConnectionState.Open) { Console.WriteLine("MYSQL Connection Connection Succeded."); status = true; contest.Close(); } } return(status); }
private void Button_Click(object sender, System.EventArgs e) { if (sender.Equals(this.SaveButton)) { //initialize the DB object DBDriver myDB=new DBDriver(); //set the appropriate SQL query myDB.Query="update compLevels" +" set competence=@compLevel" +" where ID=@devID;"; myDB.addParam("@devID", DeveloperDropDownList.SelectedValue); myDB.addParam("@compLevel", CompetenceDropDownList.SelectedValue); myDB.nonQuery(); this.syncCompetenceText();//sync back both inputs to database values. } else syncCompetenceText(); return; }
public static bool Connect () { //Set up mysql bool status = false; string sdriver = ""; Settings.Get<string> ("db.driver", out sdriver); if (!Enum.TryParse<DBDriver>(sdriver,out driver)) { Program.debugMsgs.Enqueue ("No database driver has been specified"); //No database has been specified driver = DBDriver.None; } if (driver == DBDriver.MySql) { Settings.Get<string>("db.host",out host); Settings.Get<string>("db.database",out db); Settings.Get<string>("db.username",out username); Settings.Get<string>("db.password",out password); Console.WriteLine("MYSQL Connection Connection Attempt."); MySqlConnection contest = new MySqlConnection(string.Format("Server={0};Database={1};User ID={2};Password={3}",host,db,username,password)); try { contest.Open(); } catch(Exception e){ Console.WriteLine("[E] Connection to DB failed!\n Server will be in low functionality until this is fixed!"); Console.WriteLine("[E] Exception Details:" + e.Message); driver = DBDriver.None; } if (contest.State == System.Data.ConnectionState.Open) { Console.WriteLine("MYSQL Connection Connection Succeded."); status = true; contest.Close(); } } return status; }
private void CommitButton_Click(object sender, System.EventArgs e) { DBDriver db = new DBDriver(); foreach (DataGridItem itm in DataGrid2.Items) { CheckBox cb = (CheckBox)itm.FindControl("ApproveCheckBox"); if(cb.Enabled) { db.Query = "update tasks\n" + "set complete=@complete, actEndDate=@date\n" + "where id=@id;"; db.addParam("@complete", cb.Checked?TaskStatus.APPROVED:TaskStatus.COMPLETE); db.addParam("@date", cb.Checked?Convert.ToString(DateTime.Now):""); db.addParam("@id", itm.Cells[1].Text); db.nonQuery(); } } Server.Transfer(Request.Url.AbsolutePath); }
private void CommitButton_Click(object sender, System.EventArgs e) { DBDriver db = new DBDriver(); foreach (DataGridItem itm in DataGrid2.Items) { CheckBox cb = (CheckBox)itm.FindControl("ApproveCheckBox"); if (cb.Enabled) { db.Query = "update tasks\n" + "set complete=@complete, actEndDate=@date\n" + "where id=@id;"; db.addParam("@complete", cb.Checked?TaskStatus.APPROVED:TaskStatus.COMPLETE); db.addParam("@date", cb.Checked?Convert.ToString(DateTime.Now):""); db.addParam("@id", itm.Cells[1].Text); db.nonQuery(); } } Server.Transfer(Request.Url.AbsolutePath); }
private void DeveloperDropDownList_SelectedIndexChanged(object sender, System.EventArgs e) { /* * get developer info and display it ... * * */ //initialize the DB object DBDriver myDB=new DBDriver(); //set the appropriate SQL query myDB.Query = "select person.ID, firstName, lastName, competence" + " from person, compLevels" + " where person.ID = compLevels.ID and person.ID=@devID;"; myDB.addParam("@devID", DeveloperDropDownList.SelectedValue); //initialize the datareader SqlDataReader dr = myDB.createReader(); //fill the datareader dr.Read(); this.CancelButton.Visible = true; //reset buttons this.SaveButton.Visible = true; this.CompetenceDropDownList.Visible= true; try { this.devFirstLabel.Text=Convert.ToString(dr["firstName"]); this.devLastLabel.Text=Convert.ToString(dr["lastName"]); this.CompetenceDropDownList.SelectedValue = dr["competence"].ToString(); } catch { this.devFirstLabel.Text="ERROR"; this.devLastLabel.Text="ERROR"; } myDB.close(); DeveloperPanel.Visible = true; }
private void Button_Click(object sender, System.EventArgs e) { if (sender.Equals(this.SaveButton)) { //initialize the DB object DBDriver myDB = new DBDriver(); //set the appropriate SQL query myDB.Query = "update compLevels" + " set competence=@compLevel" + " where ID=@devID;"; myDB.addParam("@devID", DeveloperDropDownList.SelectedValue); myDB.addParam("@compLevel", CompetenceDropDownList.SelectedValue); myDB.nonQuery(); this.syncCompetenceText(); //sync back both inputs to database values. } else { syncCompetenceText(); } return; }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (!Page.IsPostBack) { /// fill drop down list // initialize the DB object DBDriver myDB = new DBDriver(); //set the query to select all projects myDB.Query = "select p.ID as ID, p.lastName as lastName, p.firstName as firstName\n" + "from users u, person p\n" + "where u.security = 'Developer'\n" + "and p.ID = u.ID;"; //create a data set //DataSet ds=new DataSet(); //initialize the data adapter //fill the data set with the data adapter SqlDataReader dr = myDB.createReader(); int i = 1; DeveloperDropDownList.Items.Insert(0, ""); while (dr.Read()) { DeveloperDropDownList.Items.Insert(i, dr["lastName"].ToString() + ", " + dr["firstName"].ToString()); DeveloperDropDownList.Items[i].Value = dr["ID"].ToString(); i++; } myDB.close(); CompetenceDropDownList.Items.Insert(0, "Low"); CompetenceDropDownList.Items[0].Value = "Low"; CompetenceDropDownList.Items.Insert(1, "Medium"); CompetenceDropDownList.Items[1].Value = "Medium"; CompetenceDropDownList.Items.Insert(2, "High"); CompetenceDropDownList.Items[2].Value = "High"; } }
private void Page_Load(object sender, System.EventArgs e) { clientID = Request.Cookies["user"]["id"]; if (!Page.IsPostBack) { // show the projects datagrid DBDriver db = new DBDriver(); db.Query = "select p.ID as projectID, p.Name as projectName, u.ID as managerID, u.userName as managerName\n" + "from projects p, users u, clients c\n" + "where p.ID = c.projectID\n" + "and u.ID = c.managerID\n" + "and c.clientID = @clientID;"; db.addParam("@clientID", clientID); DataSet ds = new DataSet(); db.createAdapter().Fill(ds); DataGrid1.DataSource = ds; DataGrid1.DataBind(); } }
private void Page_Load(object sender, System.EventArgs e) { //initialize the DB object DBDriver myDB=new DBDriver(); //set the appropriate SQL query myDB.Query = "select t.ID as taskID, t.name as name, m.name as moduleName, p.name as projectName,\n" + "t.actEndDate as actEndDate, t.complete as complete, a.dateAss as dateAss, a.devID, a.taskID\n" + "from tasks t, assignments a, modules m, projects p\n" + "where t.ID = a.taskID and a.devID = @devID\n" + "and t.moduleID = m.ID\n" + "and m.projectID = p.ID\n" + "order by p.name, m.name, t.name;"; myDB.addParam("@devID", Request.Cookies["user"]["id"]); //initialize the dataset DataSet ds=new DataSet(); //initialize the data adapter //fill the dataset;this is updated myDB.createAdapter().Fill(ds); //fill the display grid DataGrid1.DataSource=ds; if (!Page.IsPostBack) DataGrid1.DataBind(); }
/// <summary> /// Send the message /// </summary> private void SendButton_Click(object sender, System.EventArgs e) { if (!Page.IsValid) return; //string from = user.Name; ArrayList toList = new ArrayList(); foreach (ListItem item in ToListBox.Items) { toList.Add(item.Value); } //Message msg = new Message(from, toList, message); string time=DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss"); // insert into database DBDriver myDB=new DBDriver(); myDB.Query= "insert into messages (SenderID, Subject, Body, timestamp)\n" + "values (@sender, @subject, @body, @time);"; myDB.addParam("@sender", Request.Cookies["user"]["id"]); myDB.addParam("@subject", this.SubjectTextBox.Text); myDB.addParam("@body", this.MessageTextBox.InnerText); myDB.addParam("@time", time); myDB.nonQuery(); myDB.Query="select id from messages where timestamp=@time;"; myDB.addParam("@time", time); int mID=Convert.ToInt32(myDB.scalar()); //insert into the recipients table as well for(int i=0;i<this.ToListBox.Items.Count;i++) { myDB.Query="insert into recipients (MessageID, RecipientID, Timestamp) values (@id, @recipient, @time);"; myDB.addParam("@id", mID); myDB.addParam("@recipient", this.ToListBox.Items[i].Value); myDB.addParam("@time", time); myDB.nonQuery(); } Server.Transfer(Request.Url.AbsolutePath); }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here string taskID = Request["taskID"]; string error = Request["error"]; if (error != null) { //Response.Write("<script type=\"text/javascript\">alert(\""+ error +"\");</script>"); ErrorLabel.Text = error; } if (taskID != null) AvailDevLabel.Text = "Choose Developer to be assigned to Task " + taskID; // fill available developers data grid //TODO: FINISH THIS // int Threshold = Convert.ToInt32(ThresholdTextBox.Text); DBDriver myDB = new DBDriver(); string s = "select p.ID as ID, p.lastName as lastName, p.firstName as firstName,\n" + "u.username as username, c.competence as competence, count(a.devID) as taskCount\n" + "from person p, compLevels c, assignments a, users u\n" + "where p.ID = u.ID\n" + "and u.security = 'Developer'\n" + "and p.ID = a.devID\n" + "and p.ID = c.ID\n" + "group by p.ID, p.lastName, p.firstName, u.userName, c.competence\n" + "having count(a.devID) < 10" // set to 10 for testing + "order by p.lastName;"; // if(Threshold != -1 ) // s +="having count(a.devID) < @Threshold"; // // s += "order by p.lastName;"; myDB.Query = s; // if( Threshold != -1 ) // myDB.addParam( "@Threshold", Threshold ); DataSet ds = new DataSet(); myDB.createAdapter().Fill(ds); DataGrid1.DataSource = ds; DataGrid1.DataBind(); // fill assignments data grid DBDriver myDB2 = new DBDriver(); s = "select assignments.taskID as taskID, users.ID as devID, users.username as username, tasks.name as taskName, \n" + "modules.name as moduleName, projects.name as projectName, assignments.dateAss as date, tasks.complete as complete\n" + "from assignments, users, tasks, modules, projects\n" + "where users.ID = assignments.devID\n" + "and users.security = 'Developer'\n" + "and assignments.taskID = tasks.ID\n" + "and tasks.moduleID = modules.ID\n" + "and modules.projectID = projects.ID\n" + "and projects.managerID = @mgrID \n" + "order by projects.name, modules.name, tasks.name, users.username;"; myDB2.Query = s; myDB2.addParam("@mgrID", Request.Cookies["user"]["id"]); DataSet ads = new DataSet(); myDB2.createAdapter().Fill(ads); DataGrid2.DataSource = ads; if( !Page.IsPostBack ) DataGrid2.DataBind(); }
private void cleanMail_Click(object sender, System.EventArgs e) { DBDriver myDB=new DBDriver(); myDB.Query="delete from messages where ID not in (select messageID from recipients);"; myDB.nonQuery(); }
/// <summary> /// Saves a session info object to a file on the disk. /// </summary> /// <param name="session">The session to be saved.</param> public void SaveSessionInfo(ISessionInfo session) { DBDriver.SaveSessionInfo(session); }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (!this.IsPostBack) { role = Request.Cookies["user"]["role"]; userID = Request.Cookies["user"]["id"]; if (role.Equals(PMT.User.Security.PROJECT_MANAGER)) { // get all projectes assigned to a project manager DataSet ds = Project.getProjectsDataSet(userID); //create a datatable to fill the dropdown list from DataTable dt=new DataTable(); dt=ds.Tables[0]; //fill the dropdown list ProjectDropDownList.DataSource=dt.DefaultView; ProjectDropDownList.DataTextField="name"; ProjectDropDownList.DataValueField="ID"; ProjectDropDownList.DataBind(); ProjectDropDownList.Items.Insert(0,""); enableModuleControls(false); enableTaskControls(false); } else if (role.Equals(PMT.User.Security.DEVELOPER)) { // get all tasks assigned to a developer DBDriver db = new DBDriver(); db.Query = "select t.id, t.name from assignments a, tasks t \n" +"where a.devID = @devID and t.id = a.taskID"; db.addParam("@devID", userID); DataSet ds = new DataSet(); db.createAdapter().Fill(ds); DataTable dt = new DataTable(); dt = ds.Tables[0]; // display tasks in the drop down list TaskDropDownList.DataSource=dt.DefaultView; TaskDropDownList.DataTextField="name"; TaskDropDownList.DataValueField="id"; TaskDropDownList.DataBind(); TaskDropDownList.Items.Insert(0,""); enableModuleControls(false); enableProjectControls(false); } else if (role.Equals(PMT.User.Security.CLIENT)) { // get all projectes assigned to a client DBDriver db = new DBDriver(); db.Query = "select * from projects p, clients c\n" + "where p.id = c.projectID\n" + "and c.clientID = @id;"; db.addParam("@id", userID); DataSet ds = new DataSet(); db.createAdapter().Fill(ds); //create a datatable to fill the dropdown list from DataTable dt=new DataTable(); dt=ds.Tables[0]; //fill the dropdown list ProjectDropDownList.DataSource=dt.DefaultView; ProjectDropDownList.DataTextField="name"; ProjectDropDownList.DataValueField="ID"; ProjectDropDownList.DataBind(); ProjectDropDownList.Items.Insert(0,""); enableModuleControls(false); enableTaskControls(false); } } ReportPanel.Visible = false; }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if(!Page.IsPostBack) { /// fill drop down list // initialize the DB object DBDriver myDB=new DBDriver(); //set the query to select all projects myDB.Query = "select p.ID as ID, p.lastName as lastName, p.firstName as firstName\n" + "from users u, person p\n" + "where u.security = 'Developer'\n" + "and p.ID = u.ID;"; //create a data set //DataSet ds=new DataSet(); //initialize the data adapter //fill the data set with the data adapter SqlDataReader dr = myDB.createReader(); int i = 1; DeveloperDropDownList.Items.Insert(0,""); while( dr.Read() ) { DeveloperDropDownList.Items.Insert(i,dr["lastName"].ToString() + ", " + dr["firstName"].ToString()); DeveloperDropDownList.Items[i].Value = dr["ID"].ToString(); i++; } myDB.close(); CompetenceDropDownList.Items.Insert(0,"Low"); CompetenceDropDownList.Items[0].Value= "Low"; CompetenceDropDownList.Items.Insert(1,"Medium"); CompetenceDropDownList.Items[1].Value= "Medium"; CompetenceDropDownList.Items.Insert(2,"High"); CompetenceDropDownList.Items[2].Value= "High"; } }
private void syncCompetenceText() { //initialize the DB object DBDriver myDB=new DBDriver(); //set the appropriate SQL query myDB.Query="select ID, competence" +" from compLevels" +" where compLevels.ID=@devID;"; myDB.addParam("@devID", DeveloperDropDownList.SelectedValue); //initialize the datareader SqlDataReader dr = myDB.createReader(); //fill the datareader dr.Read(); this.CompetenceDropDownList.SelectedValue = Convert.ToString(dr["competence"]); myDB.close(); }
private void Page_Load(object sender, System.EventArgs e) { DBDriver myDB=new DBDriver(); // Put user code to initialize the page here string role = Request.Cookies["user"]["role"]; string userID = Request.Cookies["user"]["id"]; // fill the contact list if (!this.IsPostBack) { if (role.Equals(PMT.User.Security.CLIENT)) { myDB.Query= "select u.userName as userName, u.id as ID\n" + "from users u, clients c\n" + "where u.id = c.managerID\n" + "and c.clientID = @clientID;"; myDB.addParam("@clientID", userID); } else { myDB.Query="select userName, id from users;"; } DataSet ds2=new DataSet(); myDB.createAdapter().Fill(ds2); //create a datatable to fill the dropdown list from DataTable dt=ds2.Tables[0]; //fill the Contacts list box ContactsListBox.DataSource=dt.DefaultView; ContactsListBox.DataTextField="userName"; ContactsListBox.DataValueField="id"; ContactsListBox.DataBind(); // fill the inbox myDB.Query="select m.ID messID, u.userName sender, m.subject subject, m.timestamp date, m.ID id from users u, messages m, recipients r" +" where r.recipientID=@me and m.ID=r.messageID and u.ID=m.senderID;"; myDB.addParam("@me", Request.Cookies["user"]["id"]); DataSet ds=new DataSet(); //initialize the data adapter //fill the dataset myDB.createAdapter().Fill(ds); //fill the display grid this.MessagesDataGrid.DataSource=ds; this.MessagesDataGrid.DataBind(); } }
private void MessagesDataGrid_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { //add appropriate warning popup and Database delete statement here string delID=this.MessagesDataGrid.Items[e.Item.ItemIndex].Cells[0].Text; DBDriver myDB=new DBDriver(); myDB.Query="delete from recipients where recipientID=@rID and MessageID=@mID;"; myDB.addParam("@rID", Request.Cookies["user"]["id"]); myDB.addParam("@mID", delID); myDB.nonQuery(); Response.Redirect(Request.Url.AbsolutePath); }