added double clikc and population to the edit form
This commit is contained in:
parent
e7e8f5a944
commit
9155095a3e
@ -56,7 +56,44 @@ namespace Database3
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public DataSet GetStudents(string StuID)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// open connection
|
||||||
|
myConn.Open();
|
||||||
|
//clear any parameters
|
||||||
|
cmdString.Parameters.Clear();
|
||||||
|
// command
|
||||||
|
cmdString.Connection = myConn;
|
||||||
|
cmdString.CommandType = CommandType.StoredProcedure;
|
||||||
|
cmdString.CommandTimeout = 1500;
|
||||||
|
cmdString.CommandText = "GetByStudentIDS";
|
||||||
|
// Define input parameter
|
||||||
|
cmdString.Parameters.Add("@studentid", SqlDbType.VarChar, 6).Value = StuID;
|
||||||
|
// adapter and dataset
|
||||||
|
SqlDataAdapter aAdapter = new SqlDataAdapter();
|
||||||
|
aAdapter.SelectCommand = cmdString;
|
||||||
|
DataSet aDataSet = new DataSet();
|
||||||
|
|
||||||
|
// fill adapter
|
||||||
|
aAdapter.Fill(aDataSet);
|
||||||
|
|
||||||
|
// return dataSet
|
||||||
|
return aDataSet;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new ArgumentException(ex.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
myConn.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
1
Database3/frmEdit.Designer.cs
generated
1
Database3/frmEdit.Designer.cs
generated
@ -214,6 +214,7 @@ namespace Database3
|
|||||||
this.Controls.Add(this.lblDisStuID);
|
this.Controls.Add(this.lblDisStuID);
|
||||||
this.Name = "frmEdit";
|
this.Name = "frmEdit";
|
||||||
this.Text = "frmEdit";
|
this.Text = "frmEdit";
|
||||||
|
this.Load += new System.EventHandler(this.frmEdit_Load);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using System.Windows.Forms;
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Database3
|
namespace Database3
|
||||||
{
|
{
|
||||||
@ -8,5 +10,35 @@ namespace Database3
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void frmEdit_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// txtStuID.Text = frmSearch.myID;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
DataSet ds = new DataSet();
|
||||||
|
StudentDataTier stuDT = new StudentDataTier();
|
||||||
|
|
||||||
|
ds = stuDT.GetStudents(frmSearch.myID.ToString());
|
||||||
|
|
||||||
|
if (ds.Tables[0].Rows.Count > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
txtStuID.Text = ds.Tables[0].Rows[0]["student_id"].ToString();
|
||||||
|
txtStuID.Enabled = false;
|
||||||
|
txtfname.Text = ds.Tables[0].Rows[0]["fname"].ToString();
|
||||||
|
txtlname.Text = ds.Tables[0].Rows[0]["lname"].ToString();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
// Do Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
10
Database3/frmSearch.Designer.cs
generated
10
Database3/frmSearch.Designer.cs
generated
@ -70,31 +70,31 @@
|
|||||||
//
|
//
|
||||||
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripSeparator1, this.cmuSearch, this.cmuEdit, this.cmuDelete });
|
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripSeparator1, this.cmuSearch, this.cmuEdit, this.cmuDelete });
|
||||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||||
this.contextMenuStrip1.Size = new System.Drawing.Size(110, 76);
|
this.contextMenuStrip1.Size = new System.Drawing.Size(153, 98);
|
||||||
//
|
//
|
||||||
// toolStripSeparator1
|
// toolStripSeparator1
|
||||||
//
|
//
|
||||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||||
this.toolStripSeparator1.Size = new System.Drawing.Size(106, 6);
|
this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
|
||||||
//
|
//
|
||||||
// cmuSearch
|
// cmuSearch
|
||||||
//
|
//
|
||||||
this.cmuSearch.Name = "cmuSearch";
|
this.cmuSearch.Name = "cmuSearch";
|
||||||
this.cmuSearch.Size = new System.Drawing.Size(109, 22);
|
this.cmuSearch.Size = new System.Drawing.Size(152, 22);
|
||||||
this.cmuSearch.Text = "Search";
|
this.cmuSearch.Text = "Search";
|
||||||
this.cmuSearch.Click += new System.EventHandler(this.cmuSearch_Click);
|
this.cmuSearch.Click += new System.EventHandler(this.cmuSearch_Click);
|
||||||
//
|
//
|
||||||
// cmuEdit
|
// cmuEdit
|
||||||
//
|
//
|
||||||
this.cmuEdit.Name = "cmuEdit";
|
this.cmuEdit.Name = "cmuEdit";
|
||||||
this.cmuEdit.Size = new System.Drawing.Size(109, 22);
|
this.cmuEdit.Size = new System.Drawing.Size(152, 22);
|
||||||
this.cmuEdit.Text = "Edit";
|
this.cmuEdit.Text = "Edit";
|
||||||
this.cmuEdit.Click += new System.EventHandler(this.cmuEdit_Click);
|
this.cmuEdit.Click += new System.EventHandler(this.cmuEdit_Click);
|
||||||
//
|
//
|
||||||
// cmuDelete
|
// cmuDelete
|
||||||
//
|
//
|
||||||
this.cmuDelete.Name = "cmuDelete";
|
this.cmuDelete.Name = "cmuDelete";
|
||||||
this.cmuDelete.Size = new System.Drawing.Size(109, 22);
|
this.cmuDelete.Size = new System.Drawing.Size(152, 22);
|
||||||
this.cmuDelete.Text = "Delete";
|
this.cmuDelete.Text = "Delete";
|
||||||
//
|
//
|
||||||
// lblDislname
|
// lblDislname
|
||||||
|
@ -116,7 +116,7 @@ namespace Database3
|
|||||||
|
|
||||||
private void cmuEdit_Click(object sender, EventArgs e)
|
private void cmuEdit_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
dgvStudents_DoubleClick(sender, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user