//To Save New Data private void btnSave_Click(object sender, System.Windows.RoutedEventArgs e) { try { //Disposition Validations if (txtName.Text.Trim() == "") { System.Windows.MessageBox.Show("DispositionName cannot be left Blank ", "-> Please Enter a Name", MessageBoxButton.OK, MessageBoxImage.Information); txtName.Focus(); txtName.Text = txtName.Text.Trim(); return; } ClsDisposition d = new ClsDisposition(); d.DespositionName = txtName.Text.Trim(); d.IsActive = (bool)chkIsActive.IsChecked; d.Description = txtDescription.Text.Trim(); d.CreatedBy = VMuktiAPI.VMuktiInfo.CurrentPeer.ID; if (varState == 0) { d.ID = -1; } else { d.ID = varID; } //call Save() function from Disposition.Business Int64 gID = d.Save(); if (gID <= 0) { System.Windows.MessageBox.Show("Duplicate Entry Found!!", "-> Disposition", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { System.Windows.MessageBox.Show("Record Saved Successfully!!", "-> Disposition", MessageBoxButton.OK, MessageBoxImage.Exclamation); //funSetGrid function is called to set data in Grid funSetGrid(); varState = 0; //FncClearAll function is called to Clear-All data FncClearAll(); } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "btnSave_Click()", "clsDisposition.xaml.cs"); } }
private void btnSave_Click(object sender, System.Windows.RoutedEventArgs e) { try { if (txtName.Text.Trim() == "") { System.Windows.MessageBox.Show("DispositionList Name cannot be left Blank", "-> Please Enter a Name", MessageBoxButton.OK, MessageBoxImage.Information); txtName.Focus(); txtName.Text = txtName.Text.Trim(); return; } string strDispositions = ""; for (int i = 0; i < lstSelectedDispositions.Items.Count; i++) { if (i == 0) { strDispositions = ((ListBoxItem)lstSelectedDispositions.Items[i]).Tag.ToString(); } else { strDispositions = strDispositions + "," + ((ListBoxItem)lstSelectedDispositions.Items[i]).Tag.ToString(); } } ClsDispositionList c = new ClsDispositionList(); if (varState == 0) { c.ID = -1; } else { c.ID = varID; } c.DispositionListName = txtName.Text.Trim(); c.Description = txtDescription.Text.Trim(); c.IsActive = (bool)chkIsActive.IsChecked; c.CreatedBy = VMuktiAPI.VMuktiInfo.CurrentPeer.ID; Int64 gID = c.Save(); if (gID == 0) { System.Windows.MessageBox.Show("Duplicate Entry For DispositionList Is Not Allowed !!", "-> Disposition List", MessageBoxButton.OK, MessageBoxImage.Information); } else { if (varState != 0) { ClsDisposition u1 = new ClsDisposition(); u1.ID = gID; u1.Delete(); } for (int i = 0; i < lstSelectedDispositions.Items.Count; i++) { ClsDisposition u = new ClsDisposition(); u.ID = int.Parse(((ListBoxItem)lstSelectedDispositions.Items[i]).Tag.ToString()); u.DispositionListId = gID; u.Save(); } System.Windows.MessageBox.Show("Record Saved Successfully!!", "-> Disposition List", MessageBoxButton.OK, MessageBoxImage.Exclamation); FnClearAll(); } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "btnSave_Click()", "CtlDispositionList.cs"); } }