HBM.GeneralManagement.Department.IsDuplicateName C# (CSharp) Method

IsDuplicateName() public method

public IsDuplicateName ( ) : bool
return bool
        public bool IsDuplicateName()
        {
            return (new DepartmentsDAO()).IsDuplicateTypeName(this);
        }

Usage Example

Exemplo n.º 1
0
        protected void gvDepartment_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            dsData = Session[Constants.SESSION_DEPARTMENT] as DataSet;
            ASPxGridView gridView = sender as ASPxGridView;
            DataRow      row      = dsData.Tables[0].NewRow();
            Random       rd       = new Random();

            e.NewValues["DepartmentId"] = rd.Next();
            e.NewValues["StatusId"]     = (int)Enums.HBMStatus.Active;
            e.NewValues["CompanyId"]    = SessionHandler.CurrentCompanyId;
            e.NewValues["CreatedUser"]  = SessionHandler.LoggedUser.UsersId;

            IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator();

            enumerator.Reset();
            while (enumerator.MoveNext())
            {
                if (enumerator.Key.ToString() != "Count")
                {
                    row[enumerator.Key.ToString()] = enumerator.Value == null ? DBNull.Value : enumerator.Value;
                }
            }
            gridView.CancelEdit();
            e.Cancel = true;

            dsData.Tables[0].Rows.Add(row);

            departments.DepartmentName = e.NewValues["DepartmentName"].ToString();

            if (!departments.IsDuplicateName())
            {
                if (departments.Save(dsData))
                {
                    this.LoadDepartments();
                }
            }
            else
            {
                throw new System.Exception(Messages.Duplicate_record);
            }
        }