Пример #1
0
        private void InitializeConstructor()
        {
            ObjMaster = new AttributesBO();
            this.SetProperties((INavigation)ObjMaster);
            this.InitializeForm(this.Name);
            this.Shown      += new EventHandler(frmAttribute_Shown);
            this.FormClosed += new FormClosedEventHandler(frmAttribute_FormClosed);
            //txtShortCutKey.Enabled = false;
            //txtShortCutKey.Text = "";
            this.KeyDown += new KeyEventHandler(frmAttribute_KeyDown);

            ObjMaster.SearchConditions = c => c.Id > 0;
            grdAttributes.MasterTemplate.ShowRowHeaderColumn = false;



            grdAttributes.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
            grdAttributes.AllowAddNewRow      = false;
            grdAttributes.ShowRowHeaderColumn = false;
            grdAttributes.ShowGroupPanel      = false;


            grdAttributes.TableElement.AlternatingRowColor = Color.AliceBlue;



            grdAttributes.RowsChanging     += new GridViewCollectionChangingEventHandler(grdAttributes_RowsChanging);
            grdAttributes.CommandCellClick += new CommandCellClickEventHandler(grid_CommandCellClick);
            OnNew();
            txtAtrributeName.Focus();
            //this.Load += new EventHandler(frmAttributes_Load);
        }
Пример #2
0
        private void grdAttributes_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
        {
            if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove)
            {
                if (this.CanDelete == false)
                {
                    // ENUtils.ShowMessage("Permission Denied");
                    e.Cancel = true;
                }
                else
                {
                    if (grdAttributes.CurrentRow == null)
                    {
                        return;
                    }
                    AttributesBO objMaster = new AttributesBO();

                    try
                    {
                        objMaster.GetByPrimaryKey(grdAttributes.CurrentRow.Cells["Id"].Value.ToInt());
                        if (objMaster.Current != null)
                        {
                            // string Name = objMaster.Current.Name.ToStr();
                            // string ShortName = objMaster.Current.ShortName.ToStr();
                            // bool IsDefaultCheck = Convert.ToBoolean(ObjMaster.Current.IsDefault);

                            objMaster.Delete(objMaster.Current);

                            OnNew();
                        }
                    }
                    catch (Exception ex)
                    {
                        if (objMaster.Errors.Count > 0)
                        {
                            ENUtils.ShowMessage(objMaster.ShowErrors());
                        }
                        else
                        {
                            ENUtils.ShowMessage(ex.Message);
                        }
                        e.Cancel = true;
                    }
                }
            }
        }