1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
|
private void checkBox_UpdateDealerID_CheckedChanged ( object sender, EventArgs e )
{
int lot;
if ((label6.Text != string.Empty))
{
if ((int.TryParse(textBox_lotNo.Text, out lot)))
{
decimal price;
if (decimal.TryParse(textBox1.Text, out price))
{
string NameofItem;
NameofItem = textBox_FilmName.Text;
Int32 Dealer_ID;
Dealer_ID = Convert.ToInt32(textBox_DealerID.Text);
DateTime DateOfPurchase;
DateOfPurchase = dateTimePicker_DateOfPurchase.Value;
string Typefilm;
Typefilm = comboBox_Type.SelectedValue.ToString();
string Language1;
Language1 = comboBox_Language.SelectedValue.ToString();
string YearOFRease;
YearOFRease = comboBox_YearOfRelease.SelectedValue.ToString();
string FilmCategory;
FilmCategory = comboBox_FilmCategory.SelectedValue.ToString();
string Actors_Name;
Actors_Name = textBox_ActorNames.Text;
string Actress_Name;
Actress_Name = textBox_ActressName.Text;
string Producer_Name;
Producer_Name = textBox_ProducerName.Text;
string Director_Name;
Director_Name = textBox_directorName.Text;
string StoryWriter_Name;
StoryWriter_Name = textBox_StoryWriterName.Text;
string ScriptWriter_Name;
ScriptWriter_Name = textBox_ScriptwriterName.Text;
decimal Price;
Price = Convert.ToDecimal(textBox1.Text);
Int32 lotNo;
lotNo = Convert.ToInt32(textBox_lotNo.Text);
Update_textBox_DealerID(NameofItem, Dealer_ID, DateOfPurchase, Typefilm, Language1, YearOFRease, FilmCategory, Actors_Name, Actress_Name, Producer_Name, Director_Name, StoryWriter_Name, ScriptWriter_Name, Price, lotNo);
Show_Distinct_Film_Name();
}
else
{
MessageBox.Show("Please enter a Price of the Item", "Item Price is required", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("please enter the lot no of the product", "Lot No is required", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show ( "Please select a Film/Music Album Name which you want to Edit/Update", "Click on the Film/Music Album Name", MessageBoxButtons.OK, MessageBoxIcon.Error );
}
}
private void Update_textBox_DealerID(string NameofItem, int Dealer_ID, DateTime DateOfPurchase, string Typefilm, string Language1, string YearOFRease, string FilmCategory, string Actors_Name, string Actress_Name, string Producer_Name, string Director_Name, string StoryWriter_Name, string ScriptWriter_Name, decimal Price, int lotNo)
{
using (SqlConnection con = new SqlConnection(connectionstring.Connection))
{
string query = "update Table_FilmDetail set Dealer_ID=@parameter1 where NameofItem=@parameter2 and DateOfPurchase=@paramDateOfPurchase and Typefilm=@paramTypefilm and Language1=@paramLanguage1 and YearOFRease=@paramYearOFRease and FilmCategory=@paramFilmCategory and Actors_Name=@paramActors_Name and Producer_Name=@paramProducer_Name Director_Name=@paramDirector_Name and StoryWriter_Name=@paramStoryWriter_Name and ScriptWriter_Name=@paramScriptWriter_Name and Price=@paramPrice and lotNo=@paramlotNo";
using (SqlCommand cmd = new SqlCommand(query, con))
{
cmd.Parameters.AddWithValue("@parameter1", Dealer_ID);
cmd.Parameters.AddWithValue("@parameter2", NameofItem);
cmd.Parameters.AddWithValue("@paramDateOfPurchase", DateOfPurchase);
cmd.Parameters.AddWithValue("@paramTypefilm", Typefilm);
cmd.Parameters.AddWithValue("@paramLanguage1", Language1);
cmd.Parameters.AddWithValue("@paramYearOFRease", YearOFRease);
cmd.Parameters.AddWithValue("@paramFilmCategory", FilmCategory);
cmd.Parameters.AddWithValue("@paramActors_Name", Actors_Name);
cmd.Parameters.AddWithValue("@paramProducer_Name", Producer_Name);
cmd.Parameters.AddWithValue("@paramDirector_Name", Director_Name);
cmd.Parameters.AddWithValue("@paramStoryWriter_Name", StoryWriter_Name);
cmd.Parameters.AddWithValue("@paramScriptWriter_Name", ScriptWriter_Name);
cmd.Parameters.AddWithValue("@paramPrice", Price);
cmd.Parameters.AddWithValue("@paramlotNo", lotNo);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
MessageBox.Show("Updated");
}
}
}
|