Esempio n. 1
0
 public static ClsGroup GetByGroupID(int ID)
 {
     try
     {
         ClsGroup obj = new ClsGroup();
         DataSet  ds  = new Group.DataAccess.ClsGroupDataService().Group_GetByID(ID);
         if (!obj.MapData(ds))
         {
             obj = null;
         }
         return(obj);
     }
     catch (Exception ex)
     {
         VMuktiHelper.ExceptionHandler(ex, "GetByGroupID", "ClsGroup.cs");
         return(null);
     }
 }
        //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");

            }

        }
Esempio n. 3
0
 public static ClsGroup GetByGroupID(int ID)
 {
     try
     {
         ClsGroup obj = new ClsGroup();
         DataSet ds = new Group.DataAccess.ClsGroupDataService().Group_GetByID(ID);
         if (!obj.MapData(ds)) obj = null;
         return obj;
     }
     catch (Exception ex)
     {
         VMuktiHelper.ExceptionHandler(ex, "GetByGroupID", "ClsGroup.cs"); 
         return null;
     }
 }