private void button_Restore_Click(object sender, EventArgs e) { ShoplinqDataContext data = new ShoplinqDataContext(); if (this.dataGridView_Restore.RowCount > 0 && this.dataGridView_Restore.SelectedRows.Count > 0) { foreach (DataGridViewRow row in this.dataGridView_Restore.SelectedRows) { RecycleBin deltable; deltable = (RecycleBin)row.DataBoundItem; data.RecycleBins.DeleteAllOnSubmit(data.RecycleBins.Where(s => s.Id == deltable.Id)); ShopTable rb = new ShopTable(); rb.Id = deltable.Id; rb.stuff = deltable.stuff; rb.company = deltable.company; rb.price = deltable.price; rb.exp = deltable.exp; data.ShopTables.InsertOnSubmit(rb); } } data.SubmitChanges(); List <RecycleBin> listrb = new List <RecycleBin>(); listrb = data.RecycleBins.ToList(); dataGridView_Restore.DataSource = listrb; }
private void Button_Add_Click(object sender, EventArgs e) { if (textBox_Id.Text != "" && TextBox_Stuff.Text != "" && TextBox_Company.Text != "" && textBox_Price.Text != "" && maskedTextBox_Exp.Text != "") { ShopTable sh = new ShopTable(); sh.Id = int.Parse(textBox_Id.Text); sh.stuff = TextBox_Stuff.Text; sh.company = TextBox_Company.Text; sh.price = Int32.Parse(textBox_Price.Text); sh.exp = DateTime.Parse(maskedTextBox_Exp.Text); ShoplinqDataContext data = new ShoplinqDataContext(); data.ShopTables.InsertOnSubmit(sh); data.SubmitChanges(); MessageBox.Show("کالا اضافه شد"); } if (textBox_Id.Text == "") { textBox_Id.BackColor = Color.Yellow; } else { textBox_Id.BackColor = Color.White; } if (TextBox_Stuff.Text == "") { TextBox_Stuff.BackColor = Color.Yellow; } else { TextBox_Stuff.BackColor = Color.White; } if (TextBox_Company.Text == "") { TextBox_Company.BackColor = Color.Yellow; } else { TextBox_Company.BackColor = Color.White; } if (textBox_Price.Text == "") { textBox_Price.BackColor = Color.Yellow; } else { textBox_Price.BackColor = Color.White; } if (maskedTextBox_Exp.Text == " / /") { maskedTextBox_Exp.BackColor = Color.Yellow; } else { maskedTextBox_Exp.BackColor = Color.White; } }
partial void UpdateShopTable(ShopTable instance);
partial void DeleteShopTable(ShopTable instance);
partial void InsertShopTable(ShopTable instance);