Min









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

Featured Snippets


File name: ClassBLL.cs Copy
191         public int CheckLogin(string name, string pass)
192         {
193             SqlConnection con = da.GetConnect();
194             SqlCommand cmd = new SqlCommand("select *from Users Where Username='"+name+"' and Password='"+pass+"'",con);
195             con.Open();
196             SqlDataReader dr = cmd.ExecuteReader();
197             if (dr.Read())
198             {
199                 if (dr[2].ToString() == "admin")
200                 {
201                     return 1;
202                 }
203                 else
204                 {
205                     return 2;
206                 }
207             }
208             else
209             {
210                 return -1;
211             }
212         }
File name: FormPhanQuyen.cs Copy
25         private void dgvUsers_RowEnter(object sender, DataGridViewCellEventArgs e)
26         {
27             dong = e.RowIndex;
28             txtTenDangNhap.Text = dgvUsers.Rows[dong].Cells[0].Value.ToString();
29             txtMatKhau.Text = dgvUsers.Rows[dong].Cells[1].Value.ToString();
30             if (dgvUsers.Rows[dong].Cells[2].Value.ToString() == "admin")
31             {
32                 cmbQuyen.SelectedIndex = 1;
33             }
34             else
35             {
36                 cmbQuyen.SelectedIndex = 0;
37             }
38         }
File name: frmLogin.cs Copy
66         private void btLog_Click(object sender, EventArgs e)
67         {
68             try
69             {
70                 if (txtdangnhap.Text == "" || txtmatkhau.Text == "")
71                 {
72                     MessageBox.Show("Bạn chưa điền đầy đủ thông tin", "Có lỗi xảy ra!");
73                     txtdangnhap.Focus();
74                     return;
75                 }
76                     if(txtdangnhap.Text=="admin" && txtmatkhau.Text=="admin")
77                     {
78                         if (MessageBox.Show("Chào mừng bạn đã đến với mục quản lý dành cho giáo viên", "Thông báo", MessageBoxButtons.OK) == DialogResult.OK)
79                         {
80                             this.Hide();
81                             frmQuanLy_Admin admin = new frmQuanLy_Admin();
82                             admin.ShowDialog();
83
84                         }
85
86                     }
87                 else
88                 {
89                     SqlConnection con = new SqlConnection("server=.\\SQLEXPRESS;database=QL_Thitracnghiem;integrated security=true");
90                     con.Open();
91                     SqlCommand cmd = new SqlCommand("Select MatKhau from THISINH where TenDangNhap ='" + txtdangnhap.Text + "'", con);
92                     SqlDataReader reader = cmd.ExecuteReader();
93                     reader.Read();
94                     if (txtmatkhau.Text == reader.GetValue(0).ToString())
95                     {
96                         MessageBox.Show("Bạn đã đăng nhập thành công!", "Thành công");
97                         reader.Close();
98                         con.Close();
99                         this.Close();
100                         frmLuaChon frmChon = new frmLuaChon();
101                         frmChon.ShowDialog();
102                         this.Hide();
103
104                     }
105                     else
106                     {
107                         MessageBox.Show("Sai Mật Khẩu");
108                         txtmatkhau.Focus();
109                     }
110                     reader.Close();
111                     con.Close();
112                 }
113
114             }
115
116             catch (Exception)
117             {
118
119                 MessageBox.Show("Tên đăng nhập và mật khẩu không hợp lệ","Có lỗi xảy ra");
120                 txtdangnhap.Focus();
121
122             }
123         }
File name: frmQuanLy_Admin.cs Copy
14         public frmQuanLy_Admin()
15         {
16             InitializeComponent();
17         }
File name: Lichsuthi.cs Copy
97         void timkiemtheodiemthapnhat()
98         {
99             try
100             {
101                 sqlcmd = new SqlCommand("select ketqua.mats,HOTEN,NGAYTHI,SOCAUDUNG,SOCAUSAI,DIEM FROM THISINHTHI,KETQUA WHERE THISINHTHI.MATS=KETQUA.MATS and ketqua.diem=(select min(diem) from ketqua)", sqlcon);
102                 SqlDataReader sqlreader = sqlcmd.ExecuteReader();
103                 listView1.Items.Clear();
104                 while (sqlreader.Read())
105                 {
106                     ListViewItem lvitem = new ListViewItem();
107                     lvitem.Text = sqlreader["MATS"].ToString();
108                     lvitem.SubItems.Add(sqlreader["HOTEN"].ToString().Trim());
109                     lvitem.SubItems.Add(sqlreader["NGAYTHI"].ToString().Trim());
110                     lvitem.SubItems.Add(sqlreader["SOCAUDUNG"].ToString().Trim());
111                     lvitem.SubItems.Add(sqlreader["SOCAUSAI"].ToString().Trim());
112                     lvitem.SubItems.Add(sqlreader["DIEM"].ToString().Trim());
113                     listView1.Items.Add(lvitem);
114                 }
115                 sqlreader.Close();
116             }
117             catch
118             {
119                 MessageBox.Show("Bạn làm sai thao tác");
120
121             }
122         }
File name: JumpAndRunMovement.cs Copy
29     void FixedUpdate()
30     {
31         if( m_PhotonView.isMine == false )
32         {
33             return;
34         }
35
36         UpdateMovement();
37         UpdateJumping();
38     }
File name: OnAwakePhysicsSettings.cs Copy
10     public void Awake()
11     {
12         if (!photonView.isMine)
13         {
14             Rigidbody attachedRigidbody = GetComponent();
15             if (attachedRigidbody != null)
16             {
17                 attachedRigidbody.isKinematic = true;
18             }
19             else
20             {
21                 Rigidbody2D attachedRigidbody2d = GetComponent();
22                 if (attachedRigidbody2d != null)
23                 {
24                     attachedRigidbody2d.isKinematic = true;
25                 }
26             }
27         }
28     }
File name: ClickAndDrag.cs Copy
11  void Update ()
12  {
13         if (!photonView.isMine)
14         {
15             return;
16         }
17
18      InputToEvent input = Camera.main.GetComponent();
19      if (input == null) return;
20         if (!following)
21         {
22             if (input.Dragging)
23             {
24                 camOnPress = this.transform.position;
25                 following = true;
26             }
27             else
28             {
29                 return;
30             }
31         }
32         else
33         {
34             if (input.Dragging)
35             {
36                 Vector3 target = camOnPress - (new Vector3(input.DragVector.x, 0, input.DragVector.y) * factor);
37                 this.transform.position = Vector3.Lerp(this.transform.position, target, Time.deltaTime*.5f);
38             }
39             else
40             {
41                 camOnPress = Vector3.zero;
42                 following = false;
43             }
44         }
45  }
File name: OnClickRequestOwnership.cs Copy
8     public void OnClick()
9     {
10         if( Input.GetKey( KeyCode.LeftShift ) || Input.GetKey( KeyCode.RightShift ) )
11         {
12             Vector3 colVector = new Vector3( Random.Range( 0.0f, 1.0f ), Random.Range( 0.0f, 1.0f ), Random.Range( 0.0f, 1.0f ) );
13             this.photonView.RPC( "ColorRpc", PhotonTargets.AllBufferedViaServer, colVector );
14         }
15         else
16         {
17             if( this.photonView.ownerId == PhotonNetwork.player.ID )
18             {
19                 Debug.Log( "Not requesting ownership. Already mine." );
20                 return;
21             }
22
23             this.photonView.RequestOwnership();
24         }
25     }
File name: ChatGui.cs Copy
103     public void OnGUI()
104     {
105         if (!this.IsVisible)
106         {
107             return;
108         }
109
110         GUI.skin.label.wordWrap = true;
111         //GUI.skin.button.richText = true; // this allows toolbar buttons to have bold/colored text. nice to indicate new msgs
112         //GUILayout.Button("lala"); // as richText, html tags could be in text
113
114
115         if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
116         {
117             if ("ChatInput".Equals(GUI.GetNameOfFocusedControl()))
118             {
119                 // focus on input -> submit it
120                 GuiSendsMsg();
121                 return; // showing the now modified list would result in an error. to avoid this, we just skip this single frame
122             }
123             else
124             {
125                 // assign focus to input
126                 GUI.FocusControl("ChatInput");
127             }
128         }
129
130         GUI.SetNextControlName("");
131         GUILayout.BeginArea(this.GuiRect);
132
133         GUILayout.FlexibleSpace();
134
135         if (this.chatClient.State != ChatState.ConnectedToFrontEnd)
136         {
137             GUILayout.Label("Not in chat yet.");
138         }
139         else
140         {
141             List channels = new List(this.chatClient.PublicChannels.Keys); // this could be cached
142             int countOfPublicChannels = channels.Count;
143             channels.AddRange(this.chatClient.PrivateChannels.Keys);
144
145             if (channels.Count > 0)
146             {
147                 int previouslySelectedChannelIndex = this.selectedChannelIndex;
148                 int channelIndex = channels.IndexOf(this.selectedChannelName);
149                 this.selectedChannelIndex = (channelIndex >= 0) ? channelIndex : 0;
150
151                 this.selectedChannelIndex = GUILayout.Toolbar(this.selectedChannelIndex, channels.ToArray(), GUILayout.ExpandWidth(false));
152                 this.scrollPos = GUILayout.BeginScrollView(this.scrollPos);
153
154                 this.doingPrivateChat = (this.selectedChannelIndex >= countOfPublicChannels);
155                 this.selectedChannelName = channels[this.selectedChannelIndex];
156
157                 if (this.selectedChannelIndex != previouslySelectedChannelIndex)
158                 {
159                     // changed channel -> scroll down, if private: pre-fill "to" field with target user's name
160                     this.scrollPos.y = float.MaxValue;
161                     if (this.doingPrivateChat)
162                     {
163                         string[] pieces = this.selectedChannelName.Split(new char[] {':'}, 3);
164                         this.userIdInput = pieces[1];
165                     }
166                 }
167
168                 GUILayout.Label(ChatGui.WelcomeText);
169
170                 if (this.chatClient.TryGetChannel(selectedChannelName, this.doingPrivateChat, out this.selectedChannel))
171                 {
172                     for (int i = 0; i < this.selectedChannel.Messages.Count; i++)
173                     {
174                         string sender = this.selectedChannel.Senders[i];
175                         object message = this.selectedChannel.Messages[i];
176                         GUILayout.Label(string.Format("{0}: {1}", sender, message));
177                     }
178                 }
179
180                 GUILayout.EndScrollView();
181             }
182         }
183
184
185         GUILayout.BeginHorizontal();
186         if (doingPrivateChat)
187         {
188             GUILayout.Label("to:", GUILayout.ExpandWidth(false));
189             GUI.SetNextControlName("WhisperTo");
190             this.userIdInput = GUILayout.TextField(this.userIdInput, GUILayout.MinWidth(100), GUILayout.ExpandWidth(false));
191             string focussed = GUI.GetNameOfFocusedControl();
192             if (focussed.Equals("WhisperTo"))
193             {
194                 if (this.userIdInput.Equals("username"))
195                 {
196                     this.userIdInput = "";
197                 }
198             }
199             else if (string.IsNullOrEmpty(this.userIdInput))
200             {
201                 this.userIdInput = "username";
202             }
203
204         }
205         GUI.SetNextControlName("ChatInput");
206         inputLine = GUILayout.TextField(inputLine);
207         if (GUILayout.Button("Send", GUILayout.ExpandWidth(false)))
208         {
209             GuiSendsMsg();
210         }
211         GUILayout.EndHorizontal();
212         GUILayout.EndArea();
213     }

Download file with original file name:Min

Min 134 lượt xem

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