我正在VS中创建我的第一个应用程序,但出现此错误CS7036 在(private void upd_Click,private void ajout_Click)
('upd_Click')的消息 (严重性代码说明项目文件行删除状态 错误CS7036在指定的参数中,没有一个与“ Form1.update”的强制形式参数“ newlastpoint”相对应)
和('ajout_Click') (严重性代码说明项目文件行删除状态 错误CS7036在指定的参数中,没有一个与“ Form1.add”的强制性形式参数“ lastpoint”相对应)
}
private void add(string name, string date, string somme, string points, string dateins, string facteur, string point, string lotmonth, string lastpoint)
{
string sql = "INSERT INTO amicale(name,date,somme,points,dateins,facteur,point,lotmonth,lastpoint) VALUES(@PNAME,@DATE,@SOMME,@POINTS,@DATEINS,@FACTEUR,@POINT,@LOTMONTH,@LASTPOINT)";
cmd = new SqlCommand(sql, con);
cmd.Parameters.AddWithValue("@PNAME", name);
cmd.Parameters.AddWithValue("@DATE", date);
cmd.Parameters.AddWithValue("@SOMME", somme);
cmd.Parameters.AddWithValue("@POINTS", points);
cmd.Parameters.AddWithValue("@DATEINS", dateins);
cmd.Parameters.AddWithValue("@FACTEUR", facteur);
cmd.Parameters.AddWithValue("@POINT", point);
//cmd.Parameters.AddWithValue("@LOT", lot);
cmd.Parameters.AddWithValue("@LOTMONTH", lotmonth);
cmd.Parameters.AddWithValue("@LASTPOINT", lastpoint);
try
{
con.Open();
if (cmd.ExecuteNonQuery() > 0)
{
MessageBox.Show("Inserted");
}
con.Close();
//actualiser
retrieve();
} catch (Exception ex)
{
MessageBox.Show(ex.Message);
con.Close();
}
}
//collectionner et selectionner
private void retrieve()
{
dataGridView1.Rows.Clear();
//sql stmt
string sql = "SELECT * FROM amicale";
cmd = new SqlCommand(sql, con);
//ouvrir con, retrouver, remplire DGVIEW
try
{
con.Open();
adapter = new SqlDataAdapter(cmd);
adapter.Fill(dt);
//loop
foreach (DataRow row in dt.Rows)
{
dataGridView1.Rows.Add(row[0], row[0], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10]);
}
//dataGridView1.DataSource = dt;
con.Close();
//effacer DT
dt.Rows.Clear();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
con.Close();
}
}
private void update(int id, string newname, string newdate, string newsomme, string newpoints, string newdateins, string newfacteur, string newpoint, string newlotmonth, string newlastpoint)
{
//sql stmt
string sql = "UPDATE amicale SET name='" + newname + "', date='" + newdate + "', somme='" + newsomme + "',points='" + newpoints + "', dateins='" + newdateins + "', facteur='" + newfacteur + "',point='" + newpoint + "', lotmonth='" + newlotmonth + "', lastpoint='" + newlastpoint + "' WHERE id=" + id + "";
cmd = new SqlCommand(sql, con);
//ouvrir con , mise a jour,collectionner DGVIEW
try
{
con.Open();
adapter = new SqlDataAdapter(cmd);
adapter.UpdateCommand = con.CreateCommand();
adapter.UpdateCommand.CommandText = sql;
if (adapter.UpdateCommand.ExecuteNonQuery()>0)
{
nametxt.Text = "";
datetxt.Text = "";
MessageBox.Show("successfully updated");
}
con.Close();
//retcollecter
retrieve();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
con.Close();
}
}
private void delete(int id)
{
string sql = "DELETE FROM amicale WHERE id= " + id + "";
cmd = new SqlCommand(sql, con);
// ouvrir con, executer suppression, fermer con
try
{
con.Open();
adapter.DeleteCommand = con.CreateCommand();
adapter.DeleteCommand.CommandText = sql;
//comfirmation
if(MessageBox.Show("are you sure ??", "deleted",MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
if(cmd.ExecuteNonQuery()>0)
{
nametxt.Text = "";
MessageBox.Show("successfully deleted");
}
}
con.Close();
//recollectionner
retrieve();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
con.Close();
}
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void label6_Click(object sender, EventArgs e)
{
}
private void label7_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
{
nametxt.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
datetxt.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
sommetxt.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
pointstxt.Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
dateinstxt.Text = dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
facteurtxt.Text = dataGridView1.SelectedRows[0].Cells[6].Value.ToString();
pointtxt.Text = dataGridView1.SelectedRows[0].Cells[7].Value.ToString();
lotmonthtxt.Text = dataGridView1.SelectedRows[0].Cells[8].Value.ToString();
lastpointtxt.Text = dataGridView1.SelectedRows[0].Cells[9].Value.ToString();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void إضافة_Click(object sender, EventArgs e)
{
}
private void recollect_Click(object sender, EventArgs e)
{
retrieve();
}
private void button3_Click(object sender, EventArgs e)
{
int id = Convert.ToInt16(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
delete(id);
}
private void clear_Click(object sender, EventArgs e)
{
nametxt.Text = "";
datetxt.Text = "";
sommetxt.Text = "";
pointstxt.Text = "";
dateinstxt.Text = "";
facteurtxt.Text = "";
pointtxt.Text = "";
lotmonthtxt.Text = "";
lastpointtxt.Text = "";
dataGridView1.Rows.Clear();
}
private void lastpointtxt_TextChanged(object sender, EventArgs e)
{
}
private void upd_Click(object sender, EventArgs e)
{
int id = Convert.ToInt16(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
update(id, nametxt.Text, datetxt.Text, sommetxt.Text, pointstxt.Text, facteurtxt.Text, pointtxt.Text, lotmonthtxt.Text, lastpointtxt.Text);
}
private void ajout_Click(object sender, EventArgs e)
{
add(nametxt.Text, datetxt.Text, sommetxt.Text, pointstxt.Text, facteurtxt.Text, pointtxt.Text, lotmonthtxt.Text, lastpointtxt.Text);
}
}
}