コード例 #1
0
ファイル: CtlUserInfo.xaml.cs プロジェクト: xiaoliukai/VMukti
 void CtlGrid_btnDeleteClicked(int RowID)
 {
     try
     {
         varID = Convert.ToInt32(objUserCollection[RowID].ID);
         if (System.Windows.MessageBox.Show("Do You Really Want To Delete This Record ?", "Delete User", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
         {
             ClsUser.Delete(varID);
             System.Windows.MessageBox.Show("Record Deleted!!", "User Deleted", MessageBoxButton.OK, MessageBoxImage.Information);
             funSetGrid();
         }
     }
     catch (Exception ex)
     {
         VMuktiHelper.ExceptionHandler(ex, "CtlGrid_btnDeleteClicked", "CtlUserInfo.xaml.cs");
     }
 }
コード例 #2
0
        //To save new Record
        private void btnGroupSave_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                //Validations for group
                #region GroupName Validation
                if (txtName.Text.Trim() == "")
                {
                    MessageBox.Show("Group Name Can't be left Blank ", "-> Please Enter a Name", MessageBoxButton.OK, MessageBoxImage.Information);
                    txtName.Focus();
                    txtName.Text = txtName.Text.Trim();
                    return;
                }

                #endregion


                string strUsers = "";

                for (int i = 0; i < lstSelectedAgents.Items.Count; i++)
                {
                    if (i == 0)
                    {
                        strUsers = ((ListBoxItem)lstSelectedAgents.Items[i]).Tag.ToString();
                    }
                    else
                    {
                        strUsers = strUsers + "," + ((ListBoxItem)lstSelectedAgents.Items[i]).Tag.ToString();
                    }
                }

                int      GetId = 0;
                ClsGroup c     = new ClsGroup();

                if (varState == 0)
                {
                    c.ID = -1;
                }
                else
                {
                    c.ID = varID;
                }

                c.GroupName   = txtName.Text.Trim();
                c.Description = txtDescription.Text.Trim();
                c.IsActive    = (bool)chkIsActive.IsChecked;
                c.CreatedBy   = VMuktiAPI.VMuktiInfo.CurrentPeer.ID;
                //Function to save new record
                int gID = c.Save();

                if (gID == 0)
                {
                    MessageBox.Show("User Group With Same Name is Not Allowed", "-> User Group", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                else
                {
                    if (varState != 0)
                    {
                        ClsUser u1 = new ClsUser();
                        u1.ID = gID;
                        u1.Delete();
                    }

                    for (int i = 0; i < lstSelectedAgents.Items.Count; i++)
                    {
                        ClsUser u = new ClsUser();
                        u.ID = int.Parse(((ListBoxItem)lstSelectedAgents.Items[i]).Tag.ToString());
                        //u.AgentName = ((ListBoxItem)lstSelectedAgents.Items[i]).Content.ToString();
                        u.GroupId = gID;
                        //Function to Save record in usergroup
                        u.Save();
                    }

                    System.Windows.MessageBox.Show("Record Saved Successfully!!");
                    FncClearAll();
                    //set data in grid
                    funSetGrid();
                    //set data in listboxes
                    funSetComboboxes();
                }
            }
            catch (Exception ex)
            {
                VMuktiHelper.ExceptionHandler(ex, "btnGroupSave_Click", "ctlUserGroup.xaml.cs");
            }
        }