private void button1_Click(object sender, EventArgs e) { frm_Find_Store f = new frm_Find_Store(); f.Show(); this.Close(); }
private void btn_Add_Click(object sender, EventArgs e) { try { if (edit_or_add == "add") { if (cbo_Type.SelectedIndex == -1 || String.IsNullOrWhiteSpace(txt_Name.Text)) { MessageBox.Show("you must enter at least Type and name"); } else { SqlCommand cmd = new SqlCommand("INSERT INTO [dbo].[Store] ([Sto_ID] ,[Sto_Cat_ID] ,[Capacity] ,[Area] ,[Address] ,[Phone] ,[Name],[Valid]) VALUES(@Sto_ID,@Sto_Cat_ID,@Capacity,@Area,@Address,@Phone,@Name,'True')", Conn); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@Sto_ID", int.Parse(txt_ID.Text)); cmd.Parameters.AddWithValue("@Sto_Cat_ID", cbo_Type.SelectedValue); cmd.Parameters.AddWithValue("@Capacity", txt_Capacity.Text); cmd.Parameters.AddWithValue("@Area", txt_Area.Text); cmd.Parameters.AddWithValue("@Address", txt_Address.Text); cmd.Parameters.AddWithValue("@Phone", txt_Phone.Text); cmd.Parameters.AddWithValue("@Name", txt_Name.Text); if (Conn.State != ConnectionState.Open) { Conn.Open(); } cmd.ExecuteNonQuery(); Conn.Close(); MessageBox.Show("Store is added"); frm_Find_Store f = new frm_Find_Store(); f.Show(); this.Close(); } } else if (edit_or_add == "edit") { SqlCommand cmd = new SqlCommand("UPDATE [dbo].[Store] SET [Sto_Cat_ID] = @Sto_Cat_ID ,[Capacity] = @Capacity ,[Area] = @Area ,[Address] = @Address ,[Phone] = @Phone ,[Name] = @Name WHERE [Sto_ID]=@Sto_ID", Conn); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@Sto_ID", int.Parse(txt_ID.Text)); cmd.Parameters.AddWithValue("@Sto_Cat_ID", cbo_Type.SelectedValue); cmd.Parameters.AddWithValue("@Capacity", txt_Capacity.Text); cmd.Parameters.AddWithValue("@Area", txt_Area.Text); cmd.Parameters.AddWithValue("@Address", txt_Address.Text); cmd.Parameters.AddWithValue("@Phone", txt_Phone.Text); cmd.Parameters.AddWithValue("@Name", txt_Name.Text); if (Conn.State != ConnectionState.Open) { Conn.Open(); } cmd.ExecuteNonQuery(); Conn.Close(); MessageBox.Show("Store is edited"); frm_Find_Store f = new frm_Find_Store(); f.Show(); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void frm_Add_Store_FormClosing(object sender, FormClosingEventArgs e) { frm_Find_Store f = new frm_Find_Store(); f.Show(); }
private void deleteToolStripMenuItem4_Click(object sender, EventArgs e) { frm_Find_Store form_Search_Store = new frm_Find_Store(); form_Search_Store.ShowDialog(); }
private void button4_Click(object sender, EventArgs e) { frm_Find_Store form_Search_Store = new frm_Find_Store(); form_Search_Store.ShowDialog(); }