private void Stock_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (sender != null) { DataGridRow dgr = sender as DataGridRow; // get the obect and then Invoice ID opne the Id in readonly mode dhParty objTodisplay = new dhParty(); objTodisplay = ((dhParty)dgr.Item); if (objTodisplay != null) { objTodisplay.IUpdate = 1; AddPartyViewModel ObjSetToEdit = new AddPartyViewModel(objTodisplay); //objvm.SelectToEdit(new AddPartyViewModel(objTodisplay)); Globalized.LoadThisObject(ObjSetToEdit, "Edit Party '" + objTodisplay.VPartyName + "'", Globalized.AppModuleList.Where(xx => xx.VModuleName == "Party").FirstOrDefault().VShortDescription); } } }
private void SaveTheParty(object sender, RoutedEventArgs e) { try { dhParty objParty = new dhParty(); objParty = (dhParty)grid1.DataContext; objParty.VCity = vCityList.SelectedValue != null?this.vCityList.SelectedValue.ToString() : null; dsGeneral.dtPosPartyDataTable dtParty = iFacede.GetParty(Globalized.ObjDbName, new dhParty()); ObservableCollection <dhParty> listItem = BL.ReflectionUtility.DataTableToObservableCollection <dhParty>(dtParty); string bFound = null; foreach (dhParty item in listItem) { string[] words = item.VPartyName.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] filter = objParty.VPartyName.ToLower().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if ((objParty.IPartyID != null) && (item.IPartyID == objParty.IPartyID)) { continue; } bFound = words.Where(x => filter.Contains(x.ToLower())).FirstOrDefault(); if (bFound != null) { break; } } if (bFound != null) { if (!blUtil.OverrideInformation(objParty.VPartyName, bFound)) { this.vPartyNameTextBox.SelectAll(); this.vPartyNameTextBox.Focus(); return; } } objParty.VPartyadress = objParty.VMarket + " , " + objParty.VArea + " , " + objParty.VDistrict + " , " + objParty.VCity; lblErrorMsg.Visibility = Visibility.Hidden; DataSet dsr = iFacede.InsertUpdateParty(Globalized.ObjDbName, objParty); if (dsr.Tables.Count > 0) { DataTable dtb = dsr.Tables[0]; if (dtb.Rows.Count > 0) { objParty = BL.ReflectionUtility.DataTableToObservableCollection <dhParty>(dtb).FirstOrDefault(); } } if (((dhParty)grid1.DataContext).IUpdate == 1) { Globalized.SetMsg("P02", DataHolders.MsgType.Info); } else { Globalized.SetMsg("P01", DataHolders.MsgType.Info); objParty.IUpdate = 1; AddPartyViewModel ObjSetToEdit = new AddPartyViewModel(objParty); Globalized.LoadThisObject(ObjSetToEdit, "Edit Party '" + objParty.VPartyName + "'", Globalized.AppModuleList.Where(xx => xx.VDisplayName == "Party").FirstOrDefault().VShortDescription); } Globalized.ShowMsg(lblErrorMsg); } catch (Exception ex) { Globalized.GlobalMsg = null; Globalized.SetMsg(ex.Message, MsgType.Error); Globalized.ShowMsg(lblErrorMsg); } }