public static string GetAllUpdate(Control control, string prefix = "input_") { string field, value, resultfield, resultvalue, result, namecontrol, data, ismd5; result = ""; foreach (Control inputcontrol in control.Controls) { if (inputcontrol.Name.Length > prefix.Length) { namecontrol = inputcontrol.Name.Substring(0, prefix.Length); if (namecontrol == prefix) { ismd5 = inputcontrol.Name.Substring((prefix.Length - 1), 5); if (ismd5.ToLower() == "_md5_") { field = "`" + inputcontrol.Name.Substring((prefix.Length + 4)) + "`,"; value = "'" + Hash.MD5(inputcontrol.Text) + "',"; } else if (inputcontrol is DateTimePicker) { DateTimePicker dateTimePicker = inputcontrol as DateTimePicker; field = "`" + inputcontrol.Name.Substring(prefix.Length) + "`,"; value = "'" + dateTimePicker.Value.ToString("yyyy-MM-dd") + "',"; } else { field = "`" + inputcontrol.Name.Substring(prefix.Length) + "`,"; value = "'" + MySql.EscapeString(inputcontrol.Text) + "',"; } resultfield = field.Substring(0, field.Length - 1); resultvalue = value.Substring(0, value.Length - 1); result += resultfield + " = " + resultvalue + ", "; } } } data = result.Substring(0, result.Length - 2); return(data); }
private void button1_Click(object sender, EventArgs e) { MySql.Reader("select * from t_user where username= '******'"); Function.Pesan.Info(MySql.ReaderData[3]); }