private void Btn_Save_Click(object sender, EventArgs e) { try { if (Cmb_Word.Text.Trim() == "") { throw new Exception("لطفا لغت مورد نظر را وارد کنید!"); } if (txt_Defination.Text.Trim() == "") { throw new Exception("لطفا معنی لغت مورد نظر را وارد کنید!"); } var query = from w in db.Tbl_Words where w.English_Word.Trim() == Cmb_Word.Text.Trim() && w.User_Name.Trim() == online_Username select w; if (query.Count() == 0) //Insert { Tbl_Word word = new Tbl_Word(); word.English_Word = Cmb_Word.Text.Trim(); word.Persian_Word = txt_Defination.Text.Trim(); word.User_Name = online_Username; word.Word_Situation = "M_0"; word.Insert_Date = DateTime.Now; db.Tbl_Words.InsertOnSubmit(word); db.SubmitChanges(); txt_Unread.Text = (Convert.ToInt32(txt_Unread.Text) + 1).ToString(); } else //Update { query.First().Persian_Word = txt_Defination.Text.Trim(); query.First().Word_Situation = "M_1"; query.First().Insert_Date = DateTime.Now; db.SubmitChanges(); } Cmb_Word.Text = ""; txt_Defination.Clear(); Word_Numers(); Cmb_Word.Focus(); } catch (Exception ex) { mesg.Warning("توجه", ex.Message); } }
partial void DeleteTbl_Word(Tbl_Word instance);
partial void UpdateTbl_Word(Tbl_Word instance);
partial void InsertTbl_Word(Tbl_Word instance);
private void detach_Tbl_Words(Tbl_Word entity) { this.SendPropertyChanging(); entity.Tbl_User = null; }
private void attach_Tbl_Words(Tbl_Word entity) { this.SendPropertyChanging(); entity.Tbl_User = this; }