public void AñadirUsuarios(int usuario)
        {
            contexto = new ScheduleManagerEntities();
            var query = contexto.Usuarios.FirstOrDefault(u => u.id_usuario == usuario && u.id_cuenta == 1);

            if (query != null)
            {
                UserAddForm forma = new UserAddForm();
                forma.Show();
            }
            else
            {
                MessageBox.Show("No tiene permiso");
            }
        }
        private void OpGrid_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int    logid     = Int32.Parse(OpGrid.Rows[e.RowIndex].Cells[0].Value.ToString());
            string operation = OpGrid.Rows[e.RowIndex].Cells[1].Value.ToString();
            int    opid      = Int32.Parse(OpGrid.Rows[e.RowIndex].Cells[2].Value.ToString());
            int    chid;

            try
            {
                MySqlDataReader reader = DBConnection.getData("SELECT id from user_operations where log_id=" + logid + " and operation ='" + operation + "'and op_id =" + opid + ";");

                if (operation.Equals("Added a new User") && reader.Read())
                {
                    chid = Int32.Parse(reader["id"].ToString());
                    reader.Close();

                    try
                    {
                        MySqlDataReader reader1 = DBConnection.getData("SELECT user_id, u_name, first_name, last_name, password, permission from " +
                                                                       "user , staff  where user_id=" + chid + " and user_id = staff_id;");

                        if (reader1.Read())
                        {
                            string name       = reader1["first_name"].ToString() + " " + reader1["last_name"].ToString();
                            string uname      = reader1["u_name"].ToString();
                            string pass       = Eramake.eCryptography.Decrypt(reader1["password"].ToString());
                            string permission = reader1["permission"].ToString();

                            reader1.Close();
                            UserAddForm uaf = new UserAddForm(name, uname, pass, permission);
                            uaf.Show();
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
        private void EditBT_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                switch (TableBox.SelectedIndex)
                {
                    case 0:
                        var assemblyRow = dataGrid.SelectedItem as AssemblyUnitSpecification;
                        AssemblyUnitSpecificationAddForm assemblyAddForm = new AssemblyUnitSpecificationAddForm();
                        List<string> assemblies = new List<string>()
                    {
                        assemblyRow.Product,
                        assemblyRow.AssemblyUnitSpecificationType,
                        assemblyRow.Quantity.ToString()
                    };
                        assemblyAddForm.Show();
                        assemblyAddForm.ProductCB.Text = assemblyRow.Product;
                        assemblyAddForm.AssemblyUnitSpecificationTB.Text = assemblyRow.AssemblyUnitSpecificationType;
                        assemblyAddForm.QuantityTB.Text = assemblyRow.Quantity.ToString();
                        dBContext.DeleteRow("assemblyunitspecification", assemblies);
                        dataGrid.ItemsSource = dBContext.GetAssemblyUnitSpecification();
                        break;
                    case 1:
                        var equipmentRow = dataGrid.SelectedItem as Equipment;
                        EquipmentAddForm equipmentAddForm = new EquipmentAddForm();
                        List<string> equipments = new List<string>()
                    {
                        equipmentRow.Marking,
                        equipmentRow.EquipmentType,
                        equipmentRow.Characteristics
                    };
                        equipmentAddForm.Show();
                        equipmentAddForm.MarkingTB.Text = equipmentRow.Marking;
                        equipmentAddForm.EquipmentTypeCB.Text = equipmentRow.EquipmentType;
                        equipmentAddForm.CharacteristicTB.Text = equipmentRow.Characteristics;
                        dBContext.DeleteRow("Equipment", equipments);
                        break;
                    case 2:
                        var equipmentTypeRow = dataGrid.SelectedItem as EquipmentType;
                        EquipmentTypeAddForm equipmentTypeAddForm = new EquipmentTypeAddForm();
                        List<string> equipmentTypes = new List<string>()
                    {
                        equipmentTypeRow.TypeOfEquipment,
                    };
                        equipmentTypeAddForm.Show();
                        equipmentTypeAddForm.EquipmentTypeTB.Text = equipmentTypeRow.TypeOfEquipment;
                        dBContext.DeleteRow("EquipmentType", equipmentTypes);
                        break;
                    case 3:
                        var furnitureRow = dataGrid.SelectedItem as Furniture;
                        FurnitureAddForm furnitureAddForm = new FurnitureAddForm();
                        List<string> furnitures = new List<string>()
                    {
                        furnitureRow.VendorCode.ToString(),
                        furnitureRow.Name,
                        furnitureRow.Unit,
                        furnitureRow.Quantity.ToString(),
                        furnitureRow.MainSupplier,
                        furnitureRow.Image,
                        furnitureRow.AccessoriesType,
                        furnitureRow.Price.ToString(),
                        furnitureRow.Weight.ToString()
                    };
                        furnitureAddForm.Show();
                        furnitureAddForm.VendorCodeTB.Text = furnitureRow.VendorCode.ToString();
                        furnitureAddForm.NameTB.Text = furnitureRow.Name;
                        furnitureAddForm.UnitTB.Text = furnitureRow.Unit;
                        furnitureAddForm.QuantityTB.Text = furnitureRow.Quantity.ToString();
                        furnitureAddForm.MainSupplierCB.Text = furnitureRow.MainSupplier;
                        furnitureAddForm.FurnitureImage.Source = null;
                        furnitureAddForm.AccessoriesTypeTB.Text = furnitureRow.AccessoriesType;
                        furnitureAddForm.PriceTB.Text = furnitureRow.Price.ToString();
                        furnitureAddForm.WeightTB.Text = furnitureRow.Weight.ToString();
                        dBContext.DeleteRow("furniture", furnitures);
                        break;
                    case 4:
                        var materialRow = dataGrid.SelectedItem as Material;
                        MaterialAddForm materialAddForm = new MaterialAddForm();
                        List<string> materials = new List<string>()
                    {
                        materialRow.VendorCode.ToString(),
                        materialRow.Name,
                        materialRow.Unit,
                        materialRow.Length.ToString(),
                        materialRow.Quantity.ToString(),
                        materialRow.MaterialType,
                        materialRow.Price.ToString(),
                        materialRow.Gost,
                        materialRow.MainSupplier
                    };
                        materialAddForm.Show();
                        materialAddForm.VendorCodeTB.Text = materialRow.VendorCode.ToString();
                        materialAddForm.NameTB.Text = materialRow.Name;
                        materialAddForm.UnitTB.Text = materialRow.Unit;
                        materialAddForm.LengthTB.Text = materialRow.Length.ToString();
                        materialAddForm.QuantityTB.Text = materialRow.Quantity.ToString();
                        materialAddForm.MaterialTypeTB.Text = materialRow.MaterialType;
                        materialAddForm.PriceTB.Text = materialRow.Price.ToString();
                        materialAddForm.GOSTTB.Text = materialRow.Gost;
                        materialAddForm.MainSupplierCB.Text = materialRow.MainSupplier;
                        dBContext.DeleteRow("material", materials);
                        break;
                    case 5:
                        var materialSpecificationRow = dataGrid.SelectedItem as MaterialSpecification;
                        MaterialSpecificationAddForm materialSpecificationAddForm = new MaterialSpecificationAddForm();
                        List<string> materialSpecifications = new List<string>()
                    {
                        materialSpecificationRow.Product,
                        materialSpecificationRow.Material,
                        materialSpecificationRow.Quantity.ToString(),
                    };
                        materialSpecificationAddForm.Show();
                        materialSpecificationAddForm.ProductCB.Text = materialSpecificationRow.Product;
                        materialSpecificationAddForm.MaterialCB.Text = materialSpecificationRow.Material;
                        materialSpecificationAddForm.QuantityTB.Text = materialSpecificationRow.Quantity.ToString();
                        dBContext.DeleteRow("materialSpecification", materialSpecifications);
                        break;
                    case 6:
                        var operationSpecificationRow = dataGrid.SelectedItem as OperationSpecification;
                        OperationSpecificationAddForm operationSpecificationAddForm = new OperationSpecificationAddForm();
                        List<string> operationSpecifications = new List<string>()
                    {
                        operationSpecificationRow.Product,
                        operationSpecificationRow.Operation,
                        operationSpecificationRow.SerialNumber.ToString(),
                        operationSpecificationRow.EquipmentType,
                        operationSpecificationRow.OperationTime
                    };
                        operationSpecificationAddForm.Show();
                        operationSpecificationAddForm.ProductCB.Text = operationSpecificationRow.Product;
                        operationSpecificationAddForm.OperationTB.Text = operationSpecificationRow.Operation;
                        operationSpecificationAddForm.SerialNumberTB.Text = operationSpecificationRow.SerialNumber.ToString();
                        operationSpecificationAddForm.EquipmentTypeTB.Text = operationSpecificationRow.EquipmentType;
                        operationSpecificationAddForm.EquipmentTypeTB.Text = operationSpecificationRow.OperationTime;
                        dBContext.DeleteRow("operationSpecification", operationSpecifications);
                        break;
                    case 7:
                        var orderRow = dataGrid.SelectedItem as Order;
                        OrderAddForm orderAddForm = new OrderAddForm();
                        List<string> orders = new List<string>()
                    {
                        orderRow.Number.ToString(),
                        orderRow.Date.ToString(),
                        orderRow.OrderName,
                        orderRow.Product,
                        orderRow.Customer,
                        orderRow.ResponsibleManager,
                        orderRow.Price.ToString(),
                        orderRow.PlannedCompletionDate.ToString(),
                        orderRow.OrderingSchemes
                    };
                        orderAddForm.Show();
                        orderAddForm.NumberTB.Text = orderRow.Number.ToString();
                        orderAddForm.DateCalendar.SelectedDate = null;
                        orderAddForm.OrderNameTB.Text = orderRow.OrderName;
                        orderAddForm.ProductCB.Text = orderRow.Product;
                        orderAddForm.CustomerCB.Text = orderRow.Customer;
                        orderAddForm.ResponsibleManagerCB.Text = orderRow.ResponsibleManager;
                        orderAddForm.PriceTB.Text = orderRow.Price.ToString();
                        orderAddForm.PlannedDateCalendar.SelectedDate = null;
                        orderAddForm.SchemeImage.Source = null;
                        dBContext.DeleteRow("booking", orders);
                        break;
                    case 8:
                        var productRow = dataGrid.SelectedItem as Product;
                        ProductAddForm productAddForm = new ProductAddForm();
                        List<string> products = new List<string>()
                    {
                        productRow.Name,
                        productRow.Dimensions,
                    };
                        productAddForm.Show();
                        productAddForm.NameTB.Text = productRow.Name;
                        productAddForm.DimesionsTB.Text = productRow.Dimensions;
                        dBContext.DeleteRow("product", products);
                        break;
                    case 9:
                        var specificationFurnitureRow = dataGrid.SelectedItem as SpecificationFurniture;
                        SpecificationFurnitureAddForm specificationFurnitureAddForm = new SpecificationFurnitureAddForm();
                        List<string> specificationFurnitures = new List<string>()
                    {
                        specificationFurnitureRow.Product,
                        specificationFurnitureRow.Furniture,
                        specificationFurnitureRow.Quantity.ToString()
                    };
                        specificationFurnitureAddForm.Show();
                        specificationFurnitureAddForm.ProductCB.Text = specificationFurnitureRow.Product;
                        specificationFurnitureAddForm.FurnitureCB.Text = specificationFurnitureRow.Furniture;
                        specificationFurnitureAddForm.QuantityTB.Text = specificationFurnitureRow.Quantity.ToString();
                        dBContext.DeleteRow("specificationFurniture", specificationFurnitures);
                        break;
                    case 10:
                        var supplierRow = dataGrid.SelectedItem as Supplier;
                        SupplierAddForm supplierAddForm = new SupplierAddForm();
                        List<string> suppliers = new List<string>()
                    {
                        supplierRow.Name,
                        supplierRow.Adress,
                        supplierRow.DeliveryPeriod.ToString()
                    };
                        supplierAddForm.Show();
                        supplierAddForm.NameTB.Text = supplierRow.Name;
                        supplierAddForm.AdressTB.Text = supplierRow.Adress;
                        supplierAddForm.DeliveryPeriodCalendar.SelectedDate = null;
                        dBContext.DeleteRow("supplier", suppliers);
                        break;
                    case 11:
                        var userRow = dataGrid.SelectedItem as Classes.User;
                        UserAddForm userAddForm = new UserAddForm();
                        List<string> users = new List<string>()
                    {
                        userRow.LastName,
                        userRow.FirstName,
                        userRow.Login,
                        userRow.Password,
                        userRow.Role
                    };
                        userAddForm.Show();
                        userAddForm.LastNameTB.Text = userRow.LastName;
                        userAddForm.FirstNameTB.Text = userRow.FirstName;
                        userAddForm.LoginTB.Text = userRow.Login;
                        userAddForm.PasswordTB.Text = userRow.Password;
                        userAddForm.RoleCB.Text = userRow.Role;
                        dBContext.DeleteRow("user", users);
                        break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageBox.Show("Выберите строку!");
            }

        }
Exemple #4
0
        public void ShowAddForm(int index)
        {
            switch (index)
            {
            case 0:
                AssemblyUnitSpecificationAddForm assemblyUnitSpecificationAddForm = new AssemblyUnitSpecificationAddForm();
                assemblyUnitSpecificationAddForm.Show();
                break;

            case 1:
                EquipmentAddForm equipmentAddForm = new EquipmentAddForm();
                equipmentAddForm.Show();
                break;

            case 2:
                EquipmentTypeAddForm equipmentTypeAddForm = new EquipmentTypeAddForm();
                equipmentTypeAddForm.Show();
                break;

            case 3:
                FurnitureAddForm furnitureAddForm = new FurnitureAddForm();
                furnitureAddForm.Show();
                break;

            case 4:
                MaterialAddForm materialAddForm = new MaterialAddForm();
                materialAddForm.Show();
                break;

            case 5:
                MaterialSpecificationAddForm materialSpecificationForm = new MaterialSpecificationAddForm();
                materialSpecificationForm.Show();
                break;

            case 6:
                OperationSpecificationAddForm operationSpecificationForm = new OperationSpecificationAddForm();
                operationSpecificationForm.Show();
                break;

            case 7:
                OrderAddForm orderAddForm = new OrderAddForm();
                orderAddForm.Show();
                break;

            case 8:
                ProductAddForm productAddForm = new ProductAddForm();
                productAddForm.Show();
                break;

            case 9:
                SpecificationFurnitureAddForm specificationFurnitureAddForm = new SpecificationFurnitureAddForm();
                specificationFurnitureAddForm.Show();
                break;

            case 10:
                SupplierAddForm supplierAddForm = new SupplierAddForm();
                supplierAddForm.Show();
                break;

            case 11:
                UserAddForm userAddForm = new UserAddForm();
                userAddForm.Show();
                break;
            }
        }
Exemple #5
0
 private void cuentaToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //Abrir una nueva de ventana de UserAddForm
     objForma.Show();
 }
        private void OpGrid_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int    logid     = Int32.Parse(OpGrid.Rows[e.RowIndex].Cells[0].Value.ToString());
            string operation = OpGrid.Rows[e.RowIndex].Cells[1].Value.ToString();
            int    opid      = Int32.Parse(OpGrid.Rows[e.RowIndex].Cells[2].Value.ToString());
            int    chid;

            try
            {
                MySqlDataReader reader = DBConnection.getData("SELECT id from user_operations where log_id=" + logid + " and operation ='" + operation + "'and op_id =" + opid + ";");

                if (operation.Equals("Added a new User") && reader.Read())
                {
                    chid = Int32.Parse(reader["id"].ToString());
                    reader.Close();

                    try
                    {
                        MySqlDataReader reader1 = DBConnection.getData("SELECT user_id, u_name, first_name, last_name, password, permission from " +
                                                                       "user , staff  where user_id=" + chid + " and user_id = staff_id;");

                        while (reader1.Read())
                        {
                            string name       = reader1["first_name"].ToString() + " " + reader1["last_name"].ToString();
                            string uname      = reader1["u_name"].ToString();
                            string pass       = Eramake.eCryptography.Decrypt(reader1["password"].ToString());
                            string permission = reader1["permission"].ToString();


                            UserAddForm uaf = new UserAddForm(name, uname, pass, permission);
                            uaf.Show();
                        }
                        reader1.Close();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
                else if (operation.Equals("Added a new Project") && reader.Read())
                {
                    chid = Int32.Parse(reader["id"].ToString());
                    reader.Close();

                    try
                    {
                        MySqlDataReader reader1 = DBConnection.getData("SELECT p.proj_name, c.name, p.description, p.proj_cat_id, p.proj_sub_cat_id, p.support_terms, p.visit_terms, p.warranty_terms from " +
                                                                       "project p , client c  where p.proj_id=" + chid + " and p.client_id = c.client_id;");

                        while (reader1.Read())
                        {
                            string            pname        = reader1["proj_name"].ToString();
                            string            clientname   = reader1["name"].ToString();
                            string            description  = reader1["description"].ToString();
                            string            supporttrms  = reader1["support_terms"].ToString();
                            string            visittrms    = reader1["visit_terms"].ToString();
                            string            warrantytrms = reader1["warranty_terms"].ToString();
                            int               catid        = int.Parse(reader1["proj_cat_id"].ToString());
                            int               subcatid     = int.Parse(reader1["proj_sub_cat_id"].ToString());
                            UpdateProjectForm upf          = new UpdateProjectForm(pname, clientname, description, supporttrms, visittrms, warrantytrms, catid, subcatid);
                            upf.Show();
                        }
                        reader1.Close();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
                else if (operation.Equals("Added a new Client") && reader.Read())
                {
                    chid = Int32.Parse(reader["id"].ToString());
                    reader.Close();

                    try
                    {
                        MySqlDataReader reader1 = DBConnection.getData("SELECT name, address, phone_mobile, phone_office, fax, email FROM" +
                                                                       " client where client_id = " + chid + " ; ");

                        while (reader1.Read())
                        {
                            string           name         = reader1["name"].ToString();
                            string           address      = reader1["address"].ToString();
                            string           phone_mob    = reader1["phone_mobile"].ToString();
                            string           phone_office = reader1["phone_office"].ToString();
                            string           fax          = reader1["fax"].ToString();
                            string           email        = reader1["email"].ToString();
                            AddNewClientForm anc          = new AddNewClientForm(name, address, phone_mob, phone_office, fax, email);
                            anc.Show();
                        }
                        reader1.Close();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }