//method for editing data from the database private void EdittoolStripButton46_Click(object sender, EventArgs e) { if (psitionidtext.Text == "") { MessageBox.Show("Please Insert Possition ID"); } else { var updatpossition = new Possition() { ID = Convert.ToInt32(psitionidtext.Text), Department = textEdit4.Text, Branch = textEdit3.Text, PossitionName = textEdit2.Text, Remarks = textEdit1.Text }; var uppossitionBiz = new PossitionsBiz(); if (MessageBox.Show("are you sure you want to Edit this file ?", "Confirm Updating", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { var result = uppossitionBiz.Update(updatpossition); if (result.Status) { MessageBox.Show("Successfuly Updated"); clearpo(); } else { MessageBox.Show("Update faild." + result.Message); } } } }
public void AutoComplete() { Possition po = mo.Possitions.Create(); var pos = mo.Possitions; foreach (var p in pos) { autodata.Add(p.ID.ToString()); } psitionidtext.MaskBox.AutoCompleteSource = AutoCompleteSource.CustomSource; psitionidtext.MaskBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend; psitionidtext.MaskBox.AutoCompleteCustomSource = autodata; }
// method for feaching data from the database public void fechfromdatabase() { if (psitionidtext.Text == "") { } else { int ids = Convert.ToInt32(psitionidtext.Text); Possition cm = mo.Possitions.Create(); var popl = from z in mo.Possitions where z.ID == ids select z; foreach (var p in popl) { textEdit4.Text = p.Department; textEdit3.Text = p.Branch; textEdit2.Text = p.PossitionName; textEdit1.Text = p.Remarks; } } }
// method for saving data to the database private void SavetoolStripButton45_Click(object sender, EventArgs e) { var possitons = new Possition() { Department = textEdit4.Text, Branch = textEdit3.Text, PossitionName = textEdit2.Text, Remarks = textEdit1.Text }; var PossitionBiz = new PossitionsBiz(); var result = PossitionBiz.Add(possitons); if (result.Status) { MessageBox.Show("Successfully saved."); clearpo(); } else { MessageBox.Show("Save failed. " + result.Message); } }