Presentation is loading. Please wait.

Presentation is loading. Please wait.

Session on.Net. Content Concept of.Net FrameWork.Net FrameWork Architecture.Net IDE Overview NameSpaces Exception Handling Creating Solutions & Projects.

Similar presentations


Presentation on theme: "Session on.Net. Content Concept of.Net FrameWork.Net FrameWork Architecture.Net IDE Overview NameSpaces Exception Handling Creating Solutions & Projects."— Presentation transcript:

1 Session on.Net

2 Content Concept of.Net FrameWork.Net FrameWork Architecture.Net IDE Overview NameSpaces Exception Handling Creating Solutions & Projects Creating WinForms –MDI & Child Form Windows Common Controls –TextBox –Label –Command Button –List Box –Combo Box –Radio Button –ToolTips –List View –Tree View –Context Menu Strip (Sub Menu) –Menu Strip (Menu) –Tool Strip (Tool Bar) –Data Grid View –Track Bar –Container Controls Splitter Tab Control Panel Group Box ADO.Net (Using Oracle DAAB)

3 Concept of.Net Framework. Net Framework consists of three components 1..Net Framework Class Library 2.ASP.Net 3.Common Language Runtime (CLR)

4 .Net Framework Architecture VB.NetC# VC++.Net Others Compiler Security Threading MSIL & Metadata Compiler COM Marshaler Exception Manager Garbage Collector Native Code Jit Compiler Class Loader.Net Framework Class Library C L R

5 .Net IDE Overview

6 NameSpaces FileName_1.cs Namespaces Namespace_1 { Class class_1 { } Class Class_2 { } FileName_2.cs Namespaces Namespace_1 { Class class_3 { } Class Class_4 { } NameSpace consists of collection of other Name Spaces & Classes defined in it. Main.cs Using Namespace_1 Namespace main { class clsMain { class_1 c1 = new class_1; }

7 Exception Handling Calling Method private void button6_Click(object sender, EventArgs e) { Try { Method_1(); } Catch { //Log exception } Finally { //Your Code } Called Method Private void Method_1() { Try { //Your Code } Catch { throw; } Finally { //Your Code }

8 Creating Solutions & Projects

9 Creating WinForms

10

11 MDI & Child Form

12 private void subMenu1ToolStripMenuItem_Click(object sender, EventArgs e) { Form1 frmChildForm = new Form1(); frmChildForm.MdiParent = this; frmChildForm.WindowState = FormWindowState.Maximized; frmChildForm.Icon = this.Icon; frmChildForm.Show(); }

13 Controls - TextBox Properties –Anchor –Name –Text –MaxLength –Visible Events –Click –Key Press –Enter –Leave

14 Controls - Label Properties –Anchor –Name –Text –Auto Size –Visible

15 Controls – Command Button Properties –Anchor –Name –Text –Visible –Image Events –Click private void button2_Click(object sender, EventArgs e) { TextBox1.Text=“Button Clicked”; }

16 Controls – ListBox Properties –Anchor –Name –Items –Visible –Selection Mode (One, MultiSimple, MultiExtended) Events –SelectedIndexChanged Methods –Add –Insert –Remove Example: private void ListBox1 _SelectedIndexChanged(object sender, EventArgs e) { label1.Text = ListBox1.SelectedItem.ToString(); } private void Add_Click(object sender, EventArgs e) { ListBox1.Items.Add(“Added"); } private void Remove_Click(object sender, EventArgs e) { ListBox1.Items.Remove(ListBox1.SelectedItem); } private void Insert_Click(object sender, EventArgs e) { ListBox1.Items.Insert(ListBox1.SelectedIndex, “Something"); }

17 Controls – ComboBox Properties –Anchor –Name –Items –Visible –DropDownStyle (Simple, DropDown, DropDownList) Events –SelectedIndexChanged Methods –Add –Insert –Remove Example: private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e) { label1.Text = ComboBox1.SelectedItem.ToString(); } private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e) { label1.Text = ComboBox1.SelectedItem.ToString(); } private void Add_Click(object sender, EventArgs e) { ComboBox1.Items.Add(“Added"); } private void Remove_Click(object sender, EventArgs e) { ComboBox1.Items.Remove(ComboBox1.SelectedItem); } private void Insert_Click(object sender, EventArgs e) { ComboBox1.Items.Insert(ComboBox1.SelectedIndex, “Something"); }

18 Controls – Radio Button Properties –Anchor –Name –Text –Visible –Checked Events –CheckedChanged Example: private void radioButton1_CheckedChanged(object sender, EventArgs e) { label1.Text = radioButton1.Text; } private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e) { if(radioButton1.Checked) { //Do Something…. }

19 Controls – ToolTips Properties –Name Run time toolTip1.SetToolTip(ControlName, Value);

20 Controls – Context Menu Strip

21 private void ListBox1_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { contextMenuStrip1.Show(lb, e.X, e.Y); }

22 Controls – Context Menu Strip

23 Controls – Menu Strip

24 Controls – Tool Bar

25

26 Controls – Data Grid View

27 Binding Data to Data Grid View Control OleDbConnection conn = new OleDbConnection(sConnectionString)) conn.Open(); OleDbDataAdapter objAdapter1 = new OleDbDataAdapter("SELECT * FROM [Table_Name]", conn); objDataset1 = new DataSet(); objAdapter1.Fill(objDataset1, "Sample1"); gv.DataSource = objDataset1.Tables[0].DefaultView; Getting the value from each cell private void GridView1_CellClick(object sender, DataGridViewCellEventArgs e) { label1.Text = GridView1[e.ColumnIndex, e.RowIndex].Value.ToString(); OR label1.Text = gv.Rows[0].Cells[2].Value.ToString(); } Changing/Updating the value of each cell private void GridView1_CellClick(object sender, DataGridViewCellEventArgs e) { gv[e.ColumnIndex, e.RowIndex].Value = 10; } Adding Row in the Grid private void btnAdd_Click(object sender, EventArgs e) { //Make the Property “AllowUserToAddRow=False” gv.RowCount += 1; OR gv.Rows.Add(); gv[0, gv.RowCount-1].Value = “Something”; gv[1, gv.RowCount-1].Value = “Something”; }

28 Controls – Data Grid View Deleting Row from Data Grid View Private Int32 intRow =0; private void btnDelete_Click(object sender, EventArgs e) { if (intRow > 0) { gv.Rows.RemoveAt(intRow); intRow = gv.RowCount - 1; } else gv.RowCount = 0; } private void gv_RowEnter(object sender, DataGridViewCellEventArgs e) { intRow = e.RowIndex; }

29 Controls – Data Grid View

30 Controls – Track Bar Properties Name Minimum Maximum Value Orientation Horizontal Vertical Tick Style None Top Left Bottom Right Both Events Scroll Example: private void trackBar1_Scroll(object sender, EventArgs e) { // Your Code }

31 Controls – Track Bar

32 Controls – Splitter Properties Name Orientation None Horizontal Vertical BoarderStyle None FixedSingle Fixed3D

33 Controls – TabControl Properties –Name –TabPages

34 Controls – Panel Properties –Name –AutoScroll True False –BorderStyle None FixedSingle Fixed3D

35 Controls – Group Box Properties –Name –Text

36 Controls – ListView Properties –Name –Columns –Items –CheckBox –View Large Icon Small Icon Detail List

37 Controls – ListView

38

39

40 Adding new items in ListView private void btnAdd_Click(object sender, EventArgs e) { ListViewItem itm = new ListViewItem("asdf"); itm.SubItems.Add("SubItem-2"); itm.SubItems.Add("SubItem-3"); itm.SubItems.Add("SubItem-4"); itm.SubItems.Add("SubItem-5"); itm.SubItems.Add("SubItem-6"); lv.Items.Add(itm); } Deleting items from ListView private void btnDelete_Click(object sender, EventArgs e) { if (lv.SelectedItems.Count > 0) lv.SelectedItems[0].Remove(); } Updating items in ListView private void btnUpdate_Click(object sender, EventArgs e) { if (lv.SelectedItems.Count > 0) { lv.SelectedItems[0].SubItems[0].Text = "Update"; lv.SelectedItems[0].SubItems[1].Text = txtLV.Text; lv.SelectedItems[0].SubItems[2].Text = txtLV.Text; } Clear all the items in ListView private void btnClear_Click(object sender, EventArgs e) { lv.Items.Clear(); }

41 ADO.Net Data Access in ADO.NET relies on two components: DataSet and Data Provider. DataSet –The dataset is a disconnected, in-memory representation of data. –It can be considered as a local copy of the relevant portions of the database. –The DataSet is persisted in memory and the data in it can be manipulated and updated independent of –the database. –When the use of this DataSet is finished, changes can be made back to the central database for –updating. –The data in DataSet can be loaded from any valid data source like Microsoft SQL server database, an –Oracle database or from a Microsoft Access database. Data Provider The Data Provider is responsible for providing and maintaining the connection to the database. Each DataProvider consists of the following component classes: –The Connection object which provides a connection to the database –The Command object which is used to execute a command ExecuteNonQuery: Executes commands that have no return values such as INSERT, UPDATE or DELETE ExecuteScalar: Returns a single value from a database query ExecuteReader: Returns a result set by way of a DataReader object –The DataReader object which provides a forward-only, read only, connected recordset –The DataAdapter object which populates a disconnected DataSet with data and performs update

42 ADO.Net - OleDB Using System.Data; Using System.Data.Oledb; OleDbConnection cn = new OleDbConnection(“Connection String”); OleDbDataAdapter da = new OleDbDataAdapter(“Select * from table”,cn); DataSet ds = new DataSet(); Da.Fill(ds,”TableName”); Gv.DataSource = ds.Tables[“TableName”].DataView; Foreach(Datarow dr in ds.Tables[“TableName”].Rows) { x = dr["Employee id"].ToString(); }

43 ADO.Net - DataView private void FilterRow() { objDataset1.Tables[0].DefaultView.RowFilter = ""; objDataset1.Tables[0].DefaultView.RowFilter = "Year >= " + trackBar1.Value.ToString() + " and Year <= " + trackBar2.Value.ToString(); gv.DataSource = objDataset1.Tables[0].DefaultView; OR DataView dv = new DataView(); dv = objDataset1.Tables[0].DefaultView; dv.RowFilter = “Condition”; }

44 ADO.Net – Command Object Using System.Data; Using System.Data.Oledb; OleDbConnection cn = new OleDbConnection(“Connection String”); cn.Open(); OleDbCommand cmd = new OleDbCommand("Select * from TableName", cn); cmd.ExecuteNonQuery(); cmd.ExecuteReader(); cmd.ExecuteScalar();

45 ADO.Net – Using Oracle DAAB public OracleDataReaderHelper SearchAftermarketDetail(AftermarketCustomerBO aftermarketBO) { OracleDataReaderHelper oracleDataReader; OracleParameter[] param = new OracleParameter[4]; param[0] = new OracleParameter("v_customercode", OracleDbType.Varchar2); param[0].Value = aftermarketBO.CUSTOMER_CODE; param[1] = new OracleParameter("v_customername", OracleDbType.Varchar2); param[1].Value = aftermarketBO.CUSTOMER_NAME; param[2] = new OracleParameter("v_engrpno", OracleDbType.Varchar2); param[2].Value = aftermarketBO.ENGG_PART_NO; param[3] = new OracleParameter("sys_refcursor", OracleDbType.RefCursor); param[3].Direction = ParameterDirection.Output; oracleDataReader = OracleDataAccess.ExecuteReader(mConnectionString, CommandType.StoredProcedure, "PKG_WCPS_AFTERMARKET_CUSTOMER.SP_Searchaftermarket", param); return oracleDataReader; }

46 ADO.Net – Using Oracle DAAB public Boolean ModifyAftermarket(AftermarketCustomerBO aftermarketBO, out int value) { OracleParameter[] param = new OracleParameter[2]; param[0] = new OracleParameter("v_last_modified_by", OracleDbType.Int32, ParameterDirection.Input); param[0].Value = aftermarketBO.LAST_MODIFIED_BY; param[1] = new OracleParameter("v_flag", OracleDbType.Int32, ParameterDirection.Output); OracleDataAccess.ExecuteScalar(mConnectionString, CommandType.StoredProcedure, “sp_Name", param); flag = Convert.ToInt32(param[1].Value); return retValue; }

47 ADO.Net – Using Oracle DAAB public Boolean CreateAftermarket(AftermarketCustomerBO aftermarketCustomerBO, out Int32 v_flag,out Int32 v_eng) { OracleParameter[] param = new OracleParameter[5]; param[0] = new OracleParameter("v_CUSTOMER_CODE", OracleDbType.Varchar2); param[0].Value = aftermarketCustomerBO.CUSTOMER_CODE; param[1] = new OracleParameter("v_ENGG_PART_NO", OracleDbType.Varchar2); param[2] = new OracleParameter("v_ccode", OracleDbType.Int32, 10); param[2].Direction = ParameterDirection.Output; param[3] = new OracleParameter("v_flag", OracleDbType.Int32, 10); param[3].Direction = ParameterDirection.Output; param[4] = new OracleParameter("v_eng", OracleDbType.Int32, 10); param[4].Direction = ParameterDirection.Output; OracleDataAccess.ExecuteNonQuery(mConnectionString, CommandType.StoredProcedure, “sp_name", param); v_flag = Convert.ToInt32(param[3].Value.ToString()); v_eng = Convert.ToInt32(param[4].Value.ToString()); return retValue; }

48 ADO.Net – Using Oracle DAAB public List GetReportServiceCenterID(PaymentBO paymentBO) { OracleDataReader oracleDataReader = null; OracleDataReaderHelper drh = null; List PaymentReport = new List (); PaymentBO PayReport; drh = orderDAL.GetReportServiceCenterID(paymentBO); oracleDataReader = drh.GetReader(); while (oracleDataReader.Read()) { PayReport = new PaymentBO(); PayReport.TotalClaim = Convert.ToInt32(oracleDataReader["TotalCliam"]); PayReport.TotalLabourAmount = Convert.ToDecimal(oracleDataReader["TotalLabourAmount"]); PayReport.TotalAmount = Convert.ToDecimal(oracleDataReader["TotalAmount"]); PaymentReport.Add(PayReport); } return PaymentReport; }


Download ppt "Session on.Net. Content Concept of.Net FrameWork.Net FrameWork Architecture.Net IDE Overview NameSpaces Exception Handling Creating Solutions & Projects."

Similar presentations


Ads by Google