Exemplo n.º 1
0
        private void FillOLV()
        {
            try
            {
                ovlRowMaterial.Clear();
                List <ListViewColumnsInfo> list = new List <ListViewColumnsInfo>();
                list.Add(new ListViewColumnsInfo()
                {
                    ColumnSize = 100, Header = helper.GetMemberName((RowMaterialModel c) => c.RowHedarName), Visible = true
                });
                list.Add(new ListViewColumnsInfo()
                {
                    ColumnSize = 300, Header = helper.GetMemberName((RowMaterialModel c) => c.RowMaterialName), Visible = true
                });
                list.Add(new ListViewColumnsInfo()
                {
                    ColumnSize = 100, Header = helper.GetMemberName((RowMaterialModel c) => c.MeasurmentName), Visible = true
                });
                list.Add(new ListViewColumnsInfo()
                {
                    ColumnSize = 55, Header = helper.GetMemberName((RowMaterialModel c) => c.IsActive), Visible = true
                });
                list.Add(new ListViewColumnsInfo()
                {
                    ColumnSize = 50, Header = helper.GetMemberName((RowMaterialModel c) => c.Update), Visible = true, IsButton = true
                });
                list.Add(new ListViewColumnsInfo()
                {
                    ColumnSize = 50, Header = helper.GetMemberName((RowMaterialModel c) => c.Delete), Visible = true, IsButton = true
                });
                helper.GenerateListView(ovlRowMaterial, list);
                this.ovlRowMaterial.ButtonClick += delegate(object sender, CellClickEventArgs e)
                {
                    switch (e.ColumnIndex)
                    {
                    case 4:
                        FrmAddEditRowMaterial addEmployee = new FrmAddEditRowMaterial(e.Model as RowMaterialModel);
                        AddEdit(addEmployee);
                        break;

                    case 5:
                        var          model  = e.Model as RowMaterialModel;
                        DialogResult result = MessageBox.Show(String.Format("Are you sure? you want to delete row material => {0}", model.RowMaterialName), "Delete!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (result.Equals(DialogResult.Yes))
                        {
                            reciever.Delete(model);
                            RefreshList();
                        }
                        break;
                    }
                };
            }
            catch (Exception err) { err.GetBaseException(); }
        }