1) this is my update button coding
int damage = Convert.ToInt16(numericUpDown1.Value);
UGIcon.Open();
cmd = new SqlCommand("select * from purchase", UGIcon);
SqlDataReader s = cmd.ExecuteReader();
while (s.Read())
{
if (toolStripTextBox1.Text != s["cm"].ToString())
{
MessageBox.Show("Please check the name");
}
}
s.Close();
UGIcon.Close();
if (textBox2.Text == "")
{
errorProvider1.SetError(textBox2, "Provide Owner name");
}
else if (textBox3.Text == "")
{
errorProvider1.SetError(textBox3, "Provide Address");
}
else if (numericUpDown2.Value >= damage)
{
MessageBox.Show("check Damage quantity");
}
else if ((maskedTextBox1.Text.Trim().Length <= 10))
{
MessageBox.Show("Provide full phone number");
}
else
{
UGIcon.Open();
cmd = new SqlCommand("update purchase set om='" + textBox2.Text + "', address='" + textBox3.Text + "', phone='" + maskedTextBox1.Text.ToString() + "',baled='" + numericUpDown2.Value + "',paid='" + textBox9.Text + "' where cm='" + toolStripTextBox1.Text + "'", UGIcon);
SqlDataReader dr;
dr = cmd.ExecuteReader();
dr.Close();
MessageBox.Show("Details has been updated sucessfully", "Update Window", MessageBoxButtons.OK, MessageBoxIcon.Information);
UGIcon.Close();
}
}
2)this is my trigger coding
CREATE TRIGGER [dbo].[TR_STORE_]
ON [dbo].[purchase] AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO yarnhis(ref_id,cm,paid,balance,total,[timestamp])
SELECT id,cm,paid,balance,total,GETDATE()
FROM DELETED;
END
3)if i click update button this trigger need to be fired, i dont know where to put the code... help me guys... what method i have to create i dont knw anything, can anyone guide me to execute this.... :)