private void btnDeleteDepartment_Click(object sender, EventArgs e) { try { if (tableDepartment.SelectedRows.Count > 0) { DialogResult dialogResult = new DialogResult(); FrmError frmMessage = new FrmError("ELIMINAR ESTE REGISTRO?"); dialogResult = frmMessage.ShowDialog(); if (dialogResult == DialogResult.OK) { //llenamos los campos objEntity.IdDepartment = Convert.ToInt32(tableDepartment.CurrentRow.Cells[1].Value.ToString()); objBusiness.DeleteDepartment(objEntity); FrmSuccess.mensajeConfirmacion("REGISTRO ELIMINADO"); //actualizamos la tabla ShowDepartments(""); } } else { MessageBox.Show("Seleccione el departamento a eliminar!! ", "Algo no anda bien"); } } catch (Exception erro) { MessageBox.Show("Seleccione el departamento a eliminar!! ", " Algo no anda bien" + erro.Message); } }
private void btnSaveClient_Click(object sender, EventArgs e) { if (update == false) { try { _entitiesCustomer.CustomerName = txtNameClient.Text; _entitiesCustomer.ClientLastName = txtLastNameClient.Text; _entitiesCustomer.ClientMaternalSurname = txtMothersLastNameClient.Text; _entitiesCustomer.DniClient = Convert.ToInt32(txtDniClient.Text); _entitiesCustomer.CustomerEmail = txtEmailClient.Text; _entitiesCustomer.PhoneClient = Convert.ToInt32(txtPhoneClient.Text); _entitiesCustomer.CustomerCivilStatus = cmbCivilStatusClient.SelectedItem.ToString(); _entitiesCustomer.CustomerGender = cmbGenderClient.SelectedItem.ToString(); _entitiesCustomer.CustomerAddress = txtAddressClient.Text; _entitiesCustomer.CustomerRegistrationDate = Convert.ToDateTime(dtDateAdmissionClient.Text); _objCustomer.InsertCustomer(_entitiesCustomer); frmSuccess = new FrmSuccess("CLIENTE REGISTRADO!"); frmSuccess.ShowDialog(); Close(); } catch (Exception ex) { MessageBox.Show("No se logro guardar el registro. " + ex.Message, "Valla, algo no anda bien"); } } if (update == true) { try { _entitiesCustomer.IdClient = Convert.ToInt32(txtIdClient.Text); _entitiesCustomer.CustomerName = txtNameClient.Text; _entitiesCustomer.ClientLastName = txtLastNameClient.Text; _entitiesCustomer.ClientMaternalSurname = txtMothersLastNameClient.Text; _entitiesCustomer.DniClient = Convert.ToInt32(txtDniClient.Text); _entitiesCustomer.CustomerEmail = txtEmailClient.Text; _entitiesCustomer.PhoneClient = Convert.ToInt32(txtPhoneClient.Text); _entitiesCustomer.CustomerCivilStatus = cmbCivilStatusClient.SelectedItem.ToString(); _entitiesCustomer.CustomerGender = cmbGenderClient.SelectedItem.ToString(); _entitiesCustomer.CustomerAddress = txtAddressClient.Text; _entitiesCustomer.CustomerRegistrationDate = Convert.ToDateTime(dtDateAdmissionClient.Text); _objCustomer.UpdateCustomer(_entitiesCustomer); frmSuccess = new FrmSuccess("CLIENTE ACTUALIZADO!"); frmSuccess.ShowDialog(); Close(); update = false; } catch (Exception ex) { MessageBox.Show("No se logro actualizar el registro. " + ex.Message, "Valla, algo no anda bien"); } } }
private void btnSave_Click(object sender, EventArgs e) { try { Purchases pur = new Purchases(); pur.IdEmployee = frmMain.idEmpleado; pur.IdProvider = (int)cbProveedor.SelectedValue; pur.IdWarehouse = (int)cbBodega.SelectedValue; pur.Factura = txtNoFactura.Text; pur.EntryDate = DateTime.Now; pur.PurchaseDate = dtFechaFactura.DateTime; if (pursCont.AddOrUpdatePurchases(pur)) { foreach (DetallesGrd x in listProd) { DetailPurchase det = new DetailPurchase(); det.IdProduct = x.IdProducto; det.Quantity = x.Cantidad; det.Cost = x.Costo; det.IVA = x.IVA; det.Desc = x.Desc; det.IdPurchases = pur.IdPurchases; detPurCont.AddOrUpdateDetailPurchase(det); Kardex kard = new Kardex(); kard.IdDocument = pur.IdPurchases; kard.Document = "Compra"; kard.IdProducto = x.IdProducto; kard.EntryAmount = x.Cantidad; kard.OutputAmount = 0; kard.Stock = kardCont.GetStockActual(x.IdProducto) + x.Cantidad; kard.IdWarehouse = pur.IdWarehouse; kardCont.AddOrUpdateClient(kard); CostingAverage costAver = new CostingAverage(); costAver.IdKardex = kard.IdKardex; costAver.Cost = costAveCont.getCalcularPromedioSimple(x.IdProducto); costAveCont.AddOrUpdateCostingAverage(costAver); CostingWeighted costWeig = new CostingWeighted(); costWeig.IdKardex = kard.IdKardex; costWeig.Cost = 0; cosWeiCont.AddOrUpdateCostingWeighted(costWeig); } } FrmSuccess.ConfirmacionFrom("Guardado Correctamente."); Limpiar(); } catch (Exception ex) { MessageBox.Show("ocurrio un error al guardar."); Limpiar(); } }
private void btnSaveUser_Click(object sender, EventArgs e) { if (update == false) { try { //llenamos nuestra entidad con los campos del formulario _entitiesUserManagement.IdEmployee = Convert.ToInt32(cmbNameEmployee.SelectedValue); _entitiesUserManagement.UserName = txtNameUser.Text; _entitiesUserManagement.IdRol = (cmbRolUser.SelectedIndex + 1); //la contraseña no se enviara desde el input porque la misma sera la misma para //todos los nuevos usuarios 123456789 luego se le pedira a cada usuario que //personalice su contraseña. //_entitiesUserManagement.Password = txtPassword.Text; _objUserManagement.InsertUser(_entitiesUserManagement); frmSuccess = new FrmSuccess("USUARIO GUARDADO!"); frmSuccess.ShowDialog(); Close(); } catch (Exception ex) { MessageBox.Show("No se logro guardar el registro. " + ex.Message); } } if (update == true) { try { _entitiesUserManagement.IdEmployee = Convert.ToInt32(cmbNameEmployee.SelectedValue); _entitiesUserManagement.UserName = txtNameUser.Text; _entitiesUserManagement.IdRol = (cmbRolUser.SelectedIndex + 1); _entitiesUserManagement.IdUser = Convert.ToInt32(txtIdUser.Text); _objUserManagement.UpdateUser(_entitiesUserManagement); frmSuccess = new FrmSuccess("USUARIO ACTUALIZADO!"); frmSuccess.ShowDialog(); Close(); update = false; } catch (Exception ex) { MessageBox.Show("No se logro actualizar el registro. " + ex.Message, "Valla, algo no anda bien"); } } }
private void btnEdit_Click(object sender, EventArgs e) { if (spIdCountry.Value > 0) { Country country = new Country(); RellenarPais(ref country); CountryController contCont = new CountryController(); if (contCont.AddOrUpdateCountry(country)) { FrmSuccess.ConfirmacionFrom("Editado"); limpiar(); } else { MessageBox.Show("ocurrio un error al guardar."); } } }
private void btnSave_Click(object sender, EventArgs e) { if (spIdProduct.Value == 0) { Product prod = new Product(); RellenarPrducto(ref prod); ProductController prodCont = new ProductController(); if (prodCont.AddOrUpdateProduct(prod)) { FrmSuccess.ConfirmacionFrom("Guardado"); limpiar(); } else { MessageBox.Show("ocurrio un error al guardar."); } } }
private void btnEdit_Click(object sender, EventArgs e) { if (spIdMarca.Value > 0) { Brand bran = new Brand(); RellenarMarca(ref bran); BrandController empCont = new BrandController(); if (empCont.AddOrUpdateEmployee(bran)) { FrmSuccess.ConfirmacionFrom("Editado"); //MessageBox.Show("Se edito correctamente."); Limpiar(); } else { MessageBox.Show("ocurrio un error al editar."); } } }
private void btnSaveDepartment_Click(object sender, EventArgs e) { if (editDepartment == false)//si es falso procedemos a guardar { try { //llenamos los campos a insertar objEntity.NameDepartment = txtNameDepartment.Text.ToUpper().Trim(); objBusiness.InsertDepartment(objEntity); FrmSuccess.mensajeConfirmacion("Registro Guardado Exitosamente..."); CleanTextBoxes(); //actualizamos la tabla ShowDepartments(""); } catch (Exception ex) { MessageBox.Show("" + ex.Message); } } if (editDepartment == true)//si Editarse es <true> { try { //llenamos los campos a insertar objEntity.IdDepartment = Convert.ToInt32(idDepartment.Trim()); objEntity.NameDepartment = txtNameDepartment.Text.ToUpper().Trim(); objBusiness.UpdateDepartment(objEntity); FrmSuccess.mensajeConfirmacion("Se Actualizo el Registro"); CleanTextBoxes(); //actualizamos la tabla ShowDepartments(""); editDepartment = false; } catch (Exception ex) { MessageBox.Show("No se logro EDITAR el registro. " + ex); } } }
private void btnEdit_Click(object sender, EventArgs e) { if (spIdProveedor.Value > 0) { Provider prov = new Provider(); RellenarProvider(ref prov); ProviderControlles provCont = new ProviderControlles(); if (provCont.AddOrUpdateEmployee(prov)) { FrmSuccess.ConfirmacionFrom("Editado"); //MessageBox.Show("Se edito correctamente."); Limpiar(); } else { MessageBox.Show("ocurrio un error al editar."); } } }
private void btnEdit_Click(object sender, EventArgs e) { if (spIdAlmacen.Value > 0) { Warehouse oWarehouse = new Warehouse(); RellenarAlmacen(ref oWarehouse); WarehouseController wareCont = new WarehouseController(); if (wareCont.AddOrUpdateWarehouse(oWarehouse)) { FrmSuccess.ConfirmacionFrom("Editado"); //MessageBox.Show("Se edito correctamente."); Limpiar(); } else { MessageBox.Show("ocurrio un error al editar."); } } }
private void btnEdit_Click(object sender, EventArgs e) { if (spIdProduct.Value > 0) { Product prod = new Product(); RellenarPrducto(ref prod); ProductController prodCont = new ProductController(); if (prodCont.AddOrUpdateProduct(prod)) { FrmSuccess.ConfirmacionFrom("Editado"); //MessageBox.Show("Se edito correctamente."); limpiar(); } else { MessageBox.Show("ocurrio un error al editar."); } } }
private void btnEdit_Click(object sender, EventArgs e) { if (spIdClient.Value > 0) { if (isClienteValido()) { Client client = new Client(); RellanarClinte(ref client); ClientController clientCont = new ClientController(); if (clientCont.AddOrUpdateClient(client)) { FrmSuccess.ConfirmacionFrom("Editado"); limpiar(); } else { MessageBox.Show("ocurrio un error al editar."); } } } }
private void btnEdit_Click(object sender, EventArgs e) { if (spIdEmpleado.Value > 0) { if (isEmpleadoValido()) { Employee emp = new Employee(); RellenarEmpleado(ref emp); EmployeeController empCont = new EmployeeController(); if (empCont.AddOrUpdateEmployee(emp)) { FrmSuccess.ConfirmacionFrom("Editado"); //MessageBox.Show("Se edito correctamente."); Limpiar(); } else { MessageBox.Show("ocurrio un error al editar."); } } } }
private void btnSave_Click(object sender, EventArgs e) { if (spIdUsuario.Value == 0) { if (isUsuarioValido()) { UserController userCont = new UserController(); TempUser userTemp = new TempUser(); RellenarUsuario(ref userTemp); if (userCont.addUser(userTemp)) { FrmSuccess.ConfirmacionFrom("Guardado"); //MessageBox.Show("Se guardo correctamente."); Limpiar(); } else { MessageBox.Show("ocurrio un error al guardar."); } } } }
private void btnSave_Click(object sender, EventArgs e) { if (update == false) { try {/* * //quiero que tenga el valor del id * cmbCivilStatus.ValueMember = "CivilStatus"; * //pero quiero que el usuario vea el nombre * cmbDepartment.DisplayMember = "CivilStatus"; * * //quiero que tenga el valor del id * cmbSex.ValueMember = "Sex"; * //pero quiero que el usuario vea el nombre * cmbSex.DisplayMember = "Sex";*/ _entities.NameEmployee = txtNameEmployee.Text; _entities.LastName = txtLastName.Text; _entities.MothersLastName = txtMothersLastName.Text; _entities.Dni = Convert.ToInt32(txtDni.Text); _entities.Email = txtEmail.Text; _entities.Phone = Convert.ToInt32(txtPhone.Text); _entities.CivilStatus = cmbCivilStatus.SelectedItem.ToString(); _entities.Sex = cmbSex.SelectedItem.ToString(); _entities.IdDepartment = Convert.ToInt32(cmbDepartment.SelectedValue); _entities.AddressEmployee = txtAddress.Text; _entities.DateOfAdmission = Convert.ToDateTime(dtDateAdmission.Text); _objBusines.InsertEmployee(_entities); frmSuccess = new FrmSuccess("EMPLEADO GUARDADO!"); frmSuccess.ShowDialog(); Close(); } catch (Exception ex) { MessageBox.Show("No se logro guardar el registro. " + ex.Message); } } if (update == true) { try { _entities.IdEmployee = Convert.ToInt32(txtIdEmployee.Text); _entities.NameEmployee = txtNameEmployee.Text; _entities.LastName = txtLastName.Text; _entities.MothersLastName = txtMothersLastName.Text; _entities.Dni = Convert.ToInt32(txtDni.Text); _entities.Email = txtEmail.Text; _entities.Phone = Convert.ToInt32(txtPhone.Text); _entities.CivilStatus = cmbCivilStatus.SelectedItem.ToString(); _entities.Sex = cmbSex.SelectedItem.ToString(); _entities.IdDepartment = Convert.ToInt32(cmbDepartment.SelectedValue); _entities.AddressEmployee = txtAddress.Text; _entities.DateOfAdmission = Convert.ToDateTime(dtDateAdmission.Text); _objBusines.UpdateEmployee(_entities); frmSuccess = new FrmSuccess("EMPLEADO ACTUALIZADO!"); frmSuccess.ShowDialog(); Close(); update = false; } catch (Exception ex) { MessageBox.Show("No se logro actualizar el registro. " + ex.Message, "Valla, algo no anda bien"); } } }
//evento-metodo- que se encarga de enviar la venta para el insert a la base de datos private void pbApplySale_Click(object sender, EventArgs e) { //realizamos la instancia de nuestra entidad y nuetro negocio. N_Sales applySale = new N_Sales(); N_SalesConcepts applySaleConcepts = new N_SalesConcepts(); E_Sales entitySale = new E_Sales(); E_SalesConcepts entitySaleConcept; try { string noNumber = txtIdCliente.Text; int number = 0; //si el cliente no existe en la venta le agregamos un valor por defecto a nuestro cliente //validamos de que la cadena sea un numero if (!int.TryParse(noNumber, out number)) { txtIdCliente.Text = "1003"; } //validamos de que el datagridview(tabla) tenga datos. if (dgvTableSales.Rows.Count == 0) { txtQuantityToSell.Focus(); lblCodeProduct.Text = "CODIGO PRODUCTO"; lblCodeProduct.ForeColor = Color.DarkGray; return; } //le pasamos los valores a nuestra entidad entitySale.IdUser = SessionUsers.IdUser; entitySale.IdClient = Int32.Parse(txtIdCliente.Text); entitySale.Total = decimal.Parse(txtTotalToPay.Text); entitySale.DateOfSale = DateTime.Now; //realizamos el envio de los datos para la insercion a la base de datos int idSale = applySale.GenerarateSalesInsert(entitySale); //si el insert se realiza exitosamente en la tabla ventas //se realizara el segundo insert a la tabla detalle de venta. if (idSale > 0) { //creamos la lista que contendra nuestra entidad E_SalesConcepts List <E_SalesConcepts> list_SalesConcepts = new List <E_SalesConcepts>(); //creamos un ciclo para recorrer cada celda de la tabla(datagridview sales) foreach (DataGridViewRow rows in dgvTableSales.Rows) { //creamos el objeto entitySaleConcept = new E_SalesConcepts(); //el tomamos el ultimo id insertado entitySaleConcept.IdSale = idSale; //buscamos en la celda a utilizar para el id del producto entitySaleConcept.IdProduct = Int32.Parse(rows.Cells[6].Value.ToString()); //buscamos en la celda a utilizar para el precio del producto entitySaleConcept.SalePrice = decimal.Parse(rows.Cells[4].Value.ToString()); //buscamos en la celda a utilizar para el total del producto. entitySaleConcept.Amount = Int32.Parse(rows.Cells[2].Value.ToString()); //llenamos la lista con nuestra entidad list_SalesConcepts.Add(entitySaleConcept); } //realizamos el segundo insert //insert a la tabla detalle de venta if (list_SalesConcepts.Count > 0) { applySaleConcepts.GenerarateSaleConceptInsert(list_SalesConcepts); //else error } //venta exitosa formSuccess = new FrmSuccess("Venta Exitosa!"); formSuccess.ShowDialog(); //luego de completar la venta limpiamos la tabla venta. //dgvTableSales.DataSource = ""; dgvTableSales.Columns.Clear(); CalculateTotal(); //limpiamos todos los campos de la venta searchDNI.Text = ""; lblCustomer.Text = "Cliente al contado"; lblAddressCustomer.Text = "Direccion Del Cliente"; } else { formErro = new FrmError("Error en la venta."); formErro.ShowDialog(); return; } } catch (Exception ex) { MessageBox.Show("algo no anda bien..." + ex); } }
private void btnSavePassword_Click(object sender, EventArgs e) { if (txtOldPassword.Text == "" || string.IsNullOrEmpty(txtOldPassword.Text)) { if (txtOldPassword.Text != "") { lblErroOldPassword.Visible = false; } lblErroOldPassword.ForeColor = System.Drawing.Color.Red; lblErroOldPassword.Visible = true; lblErroOldPassword.Text = "Campos Obligatorios"; txtOldPassword.Focus(); return; } if (txtPasswordNew.Text == "" || string.IsNullOrEmpty(txtPasswordNew.Text)) { if (!string.IsNullOrEmpty(txtOldPassword.Text)) { lblErroOldPassword.Visible = false; } if (txtPasswordNew.Text != "") { lblEerroPass.Visible = false; } lblEerroPass.ForeColor = System.Drawing.Color.Red; lblEerroPass.Visible = true; lblEerroPass.Text = "Campos Obligatorios"; txtPasswordNew.Focus(); return; } if (txtPasswordNew.Text != txtPasswordRepeat.Text) { if (txtPasswordNew.Text != "") { lblEerroPass.Visible = false; } lblErroPasswordRepeat.ForeColor = System.Drawing.Color.Red; lblErroPasswordRepeat.Visible = true; lblErroPasswordRepeat.Text = "Contraseñas NO Coinciden"; txtPasswordNew.Text = ""; txtPasswordNew.Focus(); return; } //encriptamos el password. string passwordOld = CapaDatos.EncryptPassword.GetSHA256(txtOldPassword.Text); string passwordNew = CapaDatos.EncryptPassword.GetSHA256(txtPasswordNew.Text); usersEntities = users.LoginValidate(SessionUsers.UserName, passwordOld); if (usersEntities == null) { lblErroOldPassword.ForeColor = System.Drawing.Color.Red; lblErroOldPassword.Visible = true; lblErroOldPassword.Text = "La Contraseña No Es Valida"; txtOldPassword.Focus(); } else { lblErroOldPassword.Visible = false; try { int passwordChanged = users.UpdatePassword(SessionUsers.IdUser, passwordNew); if (passwordChanged == 1) { Close(); FrmSuccess frmSuccess = new FrmSuccess("Contraseña Actualizada"); frmSuccess.ShowDialog(); } } catch (Exception es) { MessageBox.Show("error " + es.Message); } } }