Name1









How do I use Name1
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: Form1.cs Copy
133         private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
134         {
135             try
136             {
137                 int index = e.RowIndex;
138                 DataGridViewRow selectedRow = dataGridView1.Rows[index];
139                 Name1 = selectedRow.Cells[0].Value.ToString();
140                 Nickname = selectedRow.Cells[1].Value.ToString();
141                 PhoneNumber = selectedRow.Cells[2].Value.ToString();
142                 MobileNumber = selectedRow.Cells[3].Value.ToString();
143                 EmailAddress = selectedRow.Cells[4].Value.ToString();
144                 HomeAddress = selectedRow.Cells[5].Value.ToString();
145                 Company = selectedRow.Cells[6].Value.ToString();
146                 Position = selectedRow.Cells[7].Value.ToString();
147                 GroupName = selectedRow.Cells[8].Value.ToString();
148                 Website = selectedRow.Cells[9].Value.ToString();
149                 FacebookAccount = selectedRow.Cells[10].Value.ToString();
150
151                 frm_prev a = new frm_prev(Name1,Nickname,PhoneNumber,MobileNumber,EmailAddress,HomeAddress,Company,Position,GroupName,Website,FacebookAccount);
152                 a.ShowDialog();
153                 loadData();
154
155             }
156             catch (Exception er)
157             {
158             }
159         }
File name: frm_prev.cs Copy
27         public frm_prev(string name, string nickname, string phonenumber,string mobilenumber,string emailadd,string homeadd,string comp,string post,string group,string web,string fb)
28         {
29             Name1 =name;
30             Nickname = nickname;
31             PhoneNumber= phonenumber;
32             MobileNumber=mobilenumber;
33             EmailAddress=emailadd;
34             HomeAddress = homeadd ;
35             Company = comp;
36             Position= post;
37             GroupName=group;
38             Website= web;
39             FacebookAccount=fb;
40
41             InitializeComponent();
42         }
File name: frm_prev.cs Copy
44         private void frm_prev_Load(object sender, EventArgs e)
45         {
46             label1.Text = "Name : " + Name1;
47             label2.Text = "Nickname : " + Nickname;
48             label3.Text = "Phone Number : " + PhoneNumber;
49             label4.Text = "Mobile Number : " + MobileNumber;
50             label5.Text = "Email Address : " + EmailAddress;
51             label6.Text = "Home Address : " + HomeAddress;
52             label7.Text = "Company : " + Company;
53             label8.Text = "Position : " + Position;
54             label9.Text = "Group : " + GroupName;
55             label10.Text = "Website : " + Website;
56             label11.Text = "Facebook Account : " + FacebookAccount;
57         }
File name: frm_prev.cs Copy
59         private void button1_Click(object sender, EventArgs e)
60         {
61             frm_update a = new frm_update(Name1, Nickname, PhoneNumber, MobileNumber, EmailAddress, HomeAddress, Company, Position, GroupName, Website, FacebookAccount);
62             a.ShowDialog();
63             this.Close();
64         }
File name: frm_update.cs Copy
34         public frm_update(string name, string nickname, string phonenumber, string mobilenumber, string emailadd, string homeadd, string comp, string post, string group, string web, string fb)
35         {
36             Name1 = name;
37             Nickname = nickname;
38             PhoneNumber = phonenumber;
39             MobileNumber = mobilenumber;
40             EmailAddress = emailadd;
41             HomeAddress = homeadd;
42             Company = comp;
43             Position = post;
44             GroupName = group;
45             Website = web;
46             FacebookAccount = fb;
47
48             InitializeComponent();
49         }
File name: frm_update.cs Copy
51         private void frm_update_Load(object sender, EventArgs e)
52         {
53             textBox1.Text = Name1;
54             textBox2.Text = Nickname;
55             textBox3.Text = PhoneNumber;
56             textBox4.Text = MobileNumber;
57             textBox5.Text = EmailAddress;
58             textBox6.Text = HomeAddress;
59             textBox7.Text = Company;
60             textBox8.Text = Position;
61             textBox9.Text = GroupName;
62             textBox10.Text = Website;
63             textBox11.Text = FacebookAccount;
64         }
File name: frm_update.cs Copy
66         private void button1_Click(object sender, EventArgs e)
67         {
68               DialogResult result2 = MessageBox.Show("Are you sure you want to update "+textBox1.Text+"'s information?",
69     " System Notification",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
70               if (result2 == DialogResult.OK)
71               {
72                   string connectionString = @"server=localhost;user=root;database=phonedirectory;port=3306;password=;";
73                   MySqlConnection connection = null;
74                   try
75                   {
76                       connection = new MySqlConnection(connectionString);
77                       connection.Open();
78                       MySqlCommand cmd = new MySqlCommand();
79                       cmd.Connection = connection;
80                       cmd.CommandText = "UPDATE `directory` SET `Name` = '" + textBox1.Text + "',`Nickname` = '" + textBox2.Text + "',`PhoneNumber` = '" + textBox3.Text + "',`MobileNumber` = '" + textBox4.Text + "',`EmailAddress` = '" + textBox5.Text + "',`HomeAddress` = '" + textBox6.Text + "',`Company` = '" + textBox7.Text + "',`Position` = '" + textBox7.Text + "',`GroupName` = '" + textBox8.Text + "',`Website` = '" + textBox9.Text + "',`FacebookAccount` = '" + textBox10.Text +
81                           "' WHERE `directory`.`Name` = '" + Name1 + "' and `Nickname` = '" + Nickname + "' and `PhoneNumber` = '" + PhoneNumber +
82                           "' and `MobileNumber` = '" + MobileNumber + "' and `EmailAddress` = '" + EmailAddress + "' and `HomeAddress` = '" + HomeAddress +
83                           "' and `Company` = '" + Company + "' and `Position` = '" + Position + "' and `FacebookAccount` = '" + FacebookAccount + "'";
84                       cmd.ExecuteNonQuery();
85
86                       if (connection != null)
87                           connection.Close();
88                       MessageBox.Show("Information successfully updated", " System Informtaion");
89                   }
90                   catch (Exception er)
91                   {
92                       MessageBox.Show(er.Message);
93                   }
94
95                   finally
96                   {
97                       if (connection != null)
98                           connection.Close();
99                   }
100               } this.Close();
101
102         }
File name: frm_update.cs Copy
104         private void button2_Click(object sender, EventArgs e)
105         {
106               DialogResult result2 = MessageBox.Show("Are you sure you want to delete "+textBox1.Text+"'s information?",
107     " System Notification",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
108               if (result2 == DialogResult.OK)
109               {
110                   string connectionString = @"server=localhost;user=root;database=phonedirectory;port=3306;password=;";
111                   MySqlConnection connection = null;
112                   try
113                   {
114                       connection = new MySqlConnection(connectionString);
115                       connection.Open();
116                       MySqlCommand cmd = new MySqlCommand();
117                       cmd.Connection = connection;
118                       cmd.CommandText = "UPDATE `directory` SET `Remarks` = 'Deleted' WHERE `directory`.`Name` = '" + Name1 +
119                           "' and `Nickname` = '" + Nickname +
120                           "' and `PhoneNumber` = '" + PhoneNumber +
121                           "' and `MobileNumber` = '" + MobileNumber +
122                           "' and `EmailAddress` = '" + EmailAddress +
123                           "' and `HomeAddress` = '" + HomeAddress +
124                           "' and `Company` = '" + Company +
125                           "' and `Position` = '" + Position +
126                           "' and `FacebookAccount` = '" + FacebookAccount + "'";
127                       cmd.ExecuteNonQuery();
128
129                       if (connection != null)
130                           connection.Close();
131                       MessageBox.Show("Information successfully updated", " System Informtaion");
132                   }
133                   catch (Exception er)
134                   {
135                       MessageBox.Show(er.Message);
136                   }
137
138                   finally
139                   {
140                       if (connection != null)
141                           connection.Close();
142                   }
143               }
144               this.Close();
145         }

Name1 116 lượt xem

Gõ tìm kiếm nhanh...