Ejemplo n.º 1
0
        private void SelectEmployeeButton_Click(object sender, System.EventArgs e)
        {
            Database    db    = HostApplicationServices.WorkingDatabase;
            Editor      ed    = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Transaction trans = db.TransactionManager.StartTransaction();

            this.Hide();
            try
            {
                PromptEntityOptions prEnt    = new PromptEntityOptions("Select an Employee");
                PromptEntityResult  prEntRes = ed.GetEntity(prEnt);
                if (prEntRes.Status != PromptStatus.OK)
                {
                    this.Show();
                    return;
                }

                ArrayList saEmployeeList = new ArrayList();

                AsdkClass1.ListEmployee(prEntRes.ObjectId, saEmployeeList);
                if (saEmployeeList.Count == 4)
                {
                    tb_Name.Text     = saEmployeeList[0].ToString();
                    tb_Salary.Text   = saEmployeeList[1].ToString();
                    tb_Division.Text = saEmployeeList[2].ToString();
                }
            }
            finally
            {
                this.Show();
                trans.Dispose();
            }
        }
Ejemplo n.º 2
0
        private void SelectEmployeeButton_Click(object sender, System.EventArgs e)
        {
            Database db = HostApplicationServices.WorkingDatabase;
            Editor   ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            this.Hide();
            try
            {
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    PromptEntityOptions prEnt    = new PromptEntityOptions("Select an Employee");
                    PromptEntityResult  prEntRes = ed.GetEntity(prEnt);
                    if (prEntRes.Status != PromptStatus.OK)
                    {
                        throw new System.Exception("Error or User Cancelled");
                    }

                    ArrayList saEmployeeList = new ArrayList();

                    AsdkClass1.ListEmployee(prEntRes.ObjectId, saEmployeeList);
                    if (saEmployeeList.Count == 4)
                    {
                        tb_Name.Text     = saEmployeeList[0].ToString();
                        tb_Salary.Text   = saEmployeeList[1].ToString();
                        tb_Division.Text = saEmployeeList[2].ToString();
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Error Creating Employee: " + ex.Message);
            }
            finally
            {
                this.Show();
            }
        }