Esempio n. 1
0
        /// <summary>
        /// List of Account Groups
        /// </summary>
        /// <returns>List of Groups</returns>
        public List <eSunSpeedDomain.AccountGroupModel> GetListofAccountsGroups()
        {
            List <eSunSpeedDomain.AccountGroupModel> lstAccountGroups = new List <eSunSpeedDomain.AccountGroupModel>();

            eSunSpeedDomain.AccountGroupModel accountGroup;

            string Query = "SELECT DISTINCT AG_ID,CanDelete,GroupName,AliasName,primary, UnderGroup FROM AccountGroups where UnderGroup<>''";

            System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject());

            while (dr.Read())
            {
                accountGroup = new eSunSpeedDomain.AccountGroupModel();

                accountGroup.GroupId    = Convert.ToInt32(dr["AG_ID"]);
                accountGroup.CanDelete  = Convert.ToBoolean(dr["CanDelete"]);
                accountGroup.GroupName  = dr["GroupName"].ToString();
                accountGroup.AliasName  = dr["AliasName"].ToString();
                accountGroup.UnderGroup = dr["UnderGroup"].ToString();
                accountGroup.Primary    = dr["Primary"].ToString();

                lstAccountGroups.Add(accountGroup);
            }

            return(lstAccountGroups);
        }
Esempio n. 2
0
        /// <summary>
        /// Modified Account Group
        /// </summary>
        /// <param name="objAccountGroup"></param>
        /// <returns>True/False</returns>
        public bool UpdateAccountGroup(eSunSpeedDomain.AccountGroupModel objAccountGroup)
        {
            string Query     = string.Empty;
            bool   isUpdated = true;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();


                paramCollection.Add(new DBParameter("@GroupName", objAccountGroup.GroupName));
                paramCollection.Add(new DBParameter("@AliasName", objAccountGroup.AliasName));
                paramCollection.Add(new DBParameter("@Primary", objAccountGroup.Primary));
                paramCollection.Add(new DBParameter("@UnderGroup", objAccountGroup.UnderGroup));
                paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                paramCollection.Add(new DBParameter("@GroupId", objAccountGroup.GroupId));

                Query = "UPDATE AccountGroups SET [GroupName]=@GroupName,[AliasName]=@AliasName,[Primary]=@Primay,[UnderGroup]=@UnderGroup,[ModifiedBy]=@ModifiedBy " +
                        "WHERE [AG_ID]=@GroupId";



                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    isUpdated = true;
                }
            }
            catch (Exception ex)
            {
                isUpdated = false;
                throw ex;
            }

            return(isUpdated);
        }
Esempio n. 3
0
        /// <summary>
        /// Save Account Group
        /// </summary>
        /// <param name="objAccountGrp"></param>
        /// <returns>True/False</returns>
        public bool SaveAccountGroup(eSunSpeedDomain.AccountGroupModel objAccountGrp)
        {
            string Query = string.Empty;

            DBParameterCollection paramCollection = new DBParameterCollection();

            paramCollection.Add(new DBParameter("@GroupName", objAccountGrp.GroupName));
            paramCollection.Add(new DBParameter("@AliasName", objAccountGrp.AliasName));
            paramCollection.Add(new DBParameter("@Primary", objAccountGrp.Primary));
            paramCollection.Add(new DBParameter("@UnderGroup", objAccountGrp.UnderGroup));
            paramCollection.Add(new DBParameter("@CreatedBy", objAccountGrp.CreatedBy));

            Query = "INSERT INTO AccountGroups(`AG_ID`,`GroupName`,`AliasName`,`Primary`,`UnderGroup`,`CreatedBy`) VALUES (2,@GroupName,@AliasName,@Primary,@UnderGroup,@CreatedBy)";

            return(_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0);
        }
Esempio n. 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //TODO: 1. Check whether the group name exists or not
            //2. if exist then do not allow to save with the same group name
            //3. Prompt user to change the group name as it already exists

            if (tbxGroupName.Text.Equals(string.Empty))
            {
                MessageBox.Show("Group Name can not be blank!");
                return;
            }

            if (accObj.IsGroupExists(tbxGroupName.Text.Trim()))
            {
                MessageBox.Show("Group Name already Exists!", "SunSpeed", MessageBoxButtons.RetryCancel);
                // cbxUnderGrp.Focus();
                return;
            }

            eSunSpeedDomain.AccountGroupModel objAccGroup = new eSunSpeedDomain.AccountGroupModel();

            objAccGroup.GroupName = tbxGroupName.Text;

            objAccGroup.AliasName = tbxAliasname.Text;
            objAccGroup.Primary   = cbxPrimarygroup.SelectedItem.ToString();

            objAccGroup.UnderGroup = cbxPrimarygroup.SelectedItem.ToString().Equals("Yes") ? "" : cbxUndergroup.SelectedItem.ToString();

            objAccGroup.CreatedBy = "Admin";

            string message = string.Empty;

            bool isSuccess = accObj.SaveAccountGroup(objAccGroup);

            if (isSuccess)
            {
                MessageBox.Show("Saved Successfully!");
            }

            //List<eSunSpeedDomain.AccountGroupModel> lstGroups = accObj.GetListofAccountsGroups();
            //dgvList.DataSource = lstGroups;

            //Dialogs.PopUPDialog d = new Dialogs.PopUPDialog("Saved Successfully!");
            //d.ShowDialog();
        }