コード例 #1
0
 //-------------------Create Query------------------------------------
 public void CreateRole(Cat_Role NewRole)
 {
     entities.cat_Roles.Add(NewRole);
     entities.SaveChanges();
 }
コード例 #2
0
        private void Btn_crear_Click(object sender, EventArgs e)
        {
            string selection = Cbx_Search.Text;

            if (selection == "Employee")
            {
                //crea la instancia para los metodos
                OperacionesDBEmployee Ope = new OperacionesDBEmployee();
                //crea un nuevo objeto empleado y le carga datos
                Employee NewE = new Employee();
                NewE.First_Name = Txb_Datos1.Text;
                NewE.Last_Name  = Txb_Datos2.Text;
                NewE.Mail       = Txb_Datos3.Text;
                NewE.Birth_Date = Convert.ToDateTime(Txb_Datos4.Text);
                NewE.Start_Date = Convert.ToDateTime(Txb_Datos5.Text);
                NewE.Estado     = 1;

                Ope.CreateEmployee(NewE, int.Parse(Txb_Datos6.Text));//manda a crear un empleado
            }
            if (selection == "Company")
            {
                //crea la instancia para los metodos
                var Ope = new OperacionesCompanyDB();
                //crea un nuevo objeto compañia y le carga datos
                Company NewC = new Company();
                NewC.Name        = Txb_Datos1.Text;
                NewC.Description = Txb_Datos2.Text;
                NewC.Start_Date  = Convert.ToDateTime(Txb_Datos3.Text);
                Ope.CreateCompany(NewC);//Crea nueva compañia
            }
            if (selection == "Client")
            {
                //crea la instancia para los metodos
                var Ope = new OperacionesClientDB();
                //Carga el Id de la compañia
                int Company_ID = Convert.ToInt32(Txb_Datos3.Text);
                //crea un nuevo objeto empleado y le carga datos
                Client NewC = new Client();
                NewC.Name        = Txb_Datos1.Text;
                NewC.Description = Txb_Datos2.Text;
                NewC.Estado      = 1;

                Ope.CreateClient(NewC, Company_ID);//manda a crear un cliente
            }
            if (selection == "Project")
            {
                var     Ope       = new OperacionesProjectsDB();
                int     Client_Id = Convert.ToInt32(Txb_Datos3.Text);
                Project NewP      = new Project();
                NewP.Name        = Txb_Datos1.Text;
                NewP.Description = Txb_Datos2.Text;
                NewP.Estado      = 1;

                Ope.CreateProject(NewP, Client_Id);
            }
            if (selection == "Employee_Project")
            {
                var Ope         = new OperacionesEmp_ProjDB();
                int Project_ID  = Convert.ToInt32(Txb_Datos1.Text);
                int Employee_ID = Convert.ToInt32(Txb_Datos2.Text);
                int Cat_Role_ID = Convert.ToInt32(Txb_Datos3.Text);

                Ope.CreateEmployee_Project(Project_ID, Employee_ID, Cat_Role_ID);
            }
            if (selection == "Role")
            {
                var      DbHitss = new OperacionesCat_RoleBD();
                Cat_Role RoleN   = new Cat_Role();
                RoleN.Name        = Txb_Datos1.Text;
                RoleN.Description = Txb_Datos2.Text;
                RoleN.Estado      = 1;

                DbHitss.CreateRole(RoleN);
            }
        }