Exemple #1
0
        private void btnRemitosVarios_Click(object sender, EventArgs e)
        {
            if (!WAutorizado)
            {
                WProceso = 2;
                Clave frm = new Clave();
                frm.Show(this);
                return;
            }

            WAutorizado = false;

            Process.Start(@"\\193.168.0.2\g$\vb\Net\RemitosVarios\Ejecutable\RemitosVarios.exe", "1");
        }
Exemple #2
0
        private void BtRemito_Click(object sender, EventArgs e)
        {
            if (!WAutorizado)
            {
                WProceso = 1;
                Clave frm = new Clave();
                frm.Show(this);
                return;
            }

            WAutorizado = false;

            try
            {
                // En caso de que no se hayan seleccionado las filas completas y solo una celda o fila de manera parcial.
                if (DGV_Muestra.SelectedCells.Count > 0)
                {
                    foreach (DataGridViewCell celda in DGV_Muestra.SelectedCells)
                    {
                        DGV_Muestra.Rows[celda.RowIndex].Selected = true;
                    }
                }

                DataTable     _dt       = new DataTable();
                List <string> sinEnsayo = new List <string>();
                List <string> errorLote = new List <string>();

                int    cantidad    = (DGV_Muestra.SelectedRows.Count - 1);
                string cliente     = DGV_Muestra.SelectedRows[cantidad].Cells[7].Value.ToString(); //Cliente
                string _CodCliente = DGV_Muestra.SelectedRows[cantidad].Cells[8].Value.ToString();

                //Filtro para clientes identicos
                for (int i = 0; i < DGV_Muestra.SelectedRows.Count; i++)
                {
                    if (DGV_Muestra.SelectedRows[i].Cells[7].Value.ToString() != cliente)
                    {
                        throw new Exception("Los clientes son distintos");
                    }
                }

                //Verifico que se ML y valor medio mayor a 100 (Verifico que se haya hecho actualizar laboratiori)
                for (int i = 0; i < DGV_Muestra.SelectedRows.Count; i++)
                {
                    int valor = int.Parse(DGV_Muestra.SelectedRows[i].Cells[3].Value.ToString().Substring(3, 3));

                    if (DGV_Muestra.SelectedRows[i].Cells[3].Value.ToString().StartsWith("ML") &&
                        valor >= 100)
                    {
                        string _id = DGV_Muestra.SelectedRows[i].Cells[0].Value.ToString();
                        if (!CS.VerificarEnsayo2(_id))
                        {
                            throw new Exception("La muestra " + DGV_Muestra.SelectedRows[i].Cells[3].Value.ToString().Trim() + " no posee ensayo");
                        }
                        //sinEnsayo.Add(DGV_Muestra.SelectedRows[i].Cells[3].Value.ToString());
                    }
                }

                //Verifico que no tengan número de remito
                string numero_remito = DGV_Muestra.SelectedRows[0].Cells[12].Value.ToString();
                string[,] HojasDeSeguridad = new string[DGV_Muestra.SelectedRows.Count, 2];

                for (int i = 0; i < DGV_Muestra.SelectedRows.Count; i++)
                {
                    if (DGV_Muestra.SelectedRows[i].Cells[12].Value.ToString() != numero_remito)
                    {
                        throw new Exception("El numero de remito es diferente");
                    }
                    HojasDeSeguridad[i, 0] = DGV_Muestra.SelectedRows[i].Cells["DescriCliente"].Value.ToString().Trim();

                    HojasDeSeguridad[i, 1] = DGV_Muestra.SelectedRows[i].Cells["Codigo"].Value.ToString().Trim();
                }

                if (numero_remito != "" && numero_remito != "0")
                {
                    _dt = CS.BuscarListaRemito(numero_remito, _CodCliente);

                    foreach (DataRow row in _dt.Rows)
                    {
                        if (row["Producto"].ToString().Replace("-", "").Trim() != "")
                        {
                            DataRow datarow = CS.TraerPeligroso(row["Producto"].ToString()); //CS.ListarPeligroso(_id);
                            string  WPeligrosoI = "", WPeligrosoII = "";

                            if (datarow != null)
                            {
                                if (datarow["DescriOnu"].ToString().Trim() != "")
                                {
                                    WPeligrosoI = datarow["DescriOnu"].ToString().Trim();
                                }
                                if (datarow["Clase"].ToString().Trim() != "")
                                {
                                    WPeligrosoII = "Clase: " + datarow["Clase"].ToString().Trim() + "  ";
                                }
                                if (datarow["Naciones"].ToString().Trim() != "")
                                {
                                    WPeligrosoII += "N.ONU: " + datarow["Naciones"].ToString().Trim() + "  ";
                                }
                                if (datarow["Embalaje"].ToString().Trim() != "")
                                {
                                    WPeligrosoII += "Grupo de Embalaje: " + datarow["Embalaje"].ToString().Trim() + "  ";
                                }
                                if (datarow["Intervencion"].ToString().Trim() != "")
                                {
                                    WPeligrosoII += "N. Intervención: " + datarow["Intervencion"].ToString().Trim() + "  ";
                                }
                            }

                            row["Peligroso"]   = WPeligrosoI.Trim();
                            row["PeligrosoII"] = WPeligrosoII.Trim();
                        }
                    }

                    DataRow datacliente1 = CS.BuscarCliente(cliente);

                    string WPedido = DGV_Muestra.SelectedRows[0].Cells["Pedido"].Value.ToString();

                    string WDirEntrega = _TraerDireccionEntregaPorPedido(WPedido, _CodCliente);

                    if (WDirEntrega.Trim() == "")
                    {
                        throw new Exception("No se encuentra dirección de Entrega de Cliente");
                    }

                    string   CodClient1       = datacliente1[0].ToString();
                    string   DirClient1       = datacliente1[1].ToString();
                    string   LocalidadClient1 = datacliente1[2].ToString();
                    string   Cuit1            = datacliente1[3].ToString();
                    string   DirEntrega1      = WDirEntrega; //datacliente1[4].ToString();
                    string[] WDatosRemito     = _BuscarDatosRemito(WPedido, numero_remito);

                    ImpreRemito impre_1 = new ImpreRemito(_dt, DirEntrega1, CodClient1, DirClient1, LocalidadClient1, Cuit1, cliente, HojasDeSeguridad, WDatosRemito);
                    impre_1.ShowDialog();
                    goto finalizado;
                    //goto Error;
                }

                //Se valido la totalidad de las variables, ahora se va a modificar la/s base/s
                int[] Lotes = new int[DGV_Muestra.SelectedRows.Count];

                string[,] Peligroso = new string[DGV_Muestra.SelectedRows.Count, 2];

                string[] Codigos = new string[DGV_Muestra.SelectedRows.Count];

                for (int i = 0; i < DGV_Muestra.SelectedRows.Count; i++)
                {
                    string cod = DGV_Muestra.SelectedRows[i].Cells[3].Value.ToString();

                    if (DGV_Muestra.SelectedRows[i].Cells[3].Value.ToString().Length < 12)
                    {
                        string codigo = cod.Substring(0, 2) + "-00" + cod.Substring(3, 7);
                        cod = codigo;
                    }
                    Codigos[i] = cod;
                    int    _id    = int.Parse(DGV_Muestra.SelectedRows[i].Cells[0].Value.ToString());
                    string pedido = DGV_Muestra.SelectedRows[i].Cells[1].Value.ToString();

                    // Se busca lote para el Codigo solicitado en caso de que no sea un ML.
                    // Falta definir el

                    if (cod.StartsWith("DY"))
                    {
                        cod = Conexion._FormatearCodigoProducto(cod);
                    }


                    string cant = DGV_Muestra.SelectedRows[i].Cells[5].Value.ToString().Trim();

                    cant = cant.Replace(",", ".");

                    cant = cant.StartsWith(".") ? "0" + cant : cant;

                    if (DGV_Muestra.SelectedRows[i].Cells[3].Value.ToString().StartsWith("YQ") || DGV_Muestra.SelectedRows[i].Cells[3].Value.ToString().StartsWith("YF"))
                    {
                        if (Double.Parse(cant.Replace(".", ",")) >= 20)
                        {
                            int _lote1 = int.Parse(CS.BuscarLote1(cod, pedido));

                            if (_lote1 == 0)
                            {
                                throw new Exception("La Muestra para " + DGV_Muestra.SelectedRows[i].Cells[3].Value.ToString().Trim() + " no posee lote");
                            }

                            Lotes[i] = _lote1;
                        }
                    }
                    else
                    {
                        if (!DGV_Muestra.SelectedRows[i].Cells[3].Value.ToString().StartsWith("ML") && !DGV_Muestra.SelectedRows[i].Cells[3].Value.ToString().StartsWith("YP"))
                        {
                            int _lote1 = int.Parse(CS.BuscarLote1(cod, pedido));

                            if (_lote1 == 0)
                            {
                                throw new Exception("La Muestra para " + DGV_Muestra.SelectedRows[i].Cells[3].Value.ToString().Trim() + " no posee lote");
                            }

                            Lotes[i] = _lote1;
                        }
                    }



                    DataRow datarow = CS.TraerPeligroso(cod); //CS.ListarPeligroso(_id);
                    string  WPeligrosoI = "", WPeligrosoII = "";

                    if (datarow != null)
                    {
                        if (datarow["DescriOnu"].ToString().Trim() != "")
                        {
                            WPeligrosoI = datarow["DescriOnu"].ToString().Trim();
                        }
                        if (datarow["Clase"].ToString().Trim() != "")
                        {
                            WPeligrosoII = "Clase: " + datarow["Clase"].ToString().Trim() + "  ";
                        }
                        if (datarow["Naciones"].ToString().Trim() != "")
                        {
                            WPeligrosoII += "N.ONU: " + datarow["Naciones"].ToString().Trim() + " ";
                        }
                        if (datarow["Embalaje"].ToString().Trim() != "")
                        {
                            WPeligrosoII += "Grupo de Embalaje: " + datarow["Embalaje"].ToString().Trim() + " ";
                        }
                        if (datarow["Intervencion"].ToString().Trim() != "")
                        {
                            WPeligrosoII += "N. Intervención: " + datarow["Intervencion"].ToString().Trim() + " ";
                        }
                    }

                    Peligroso[i, 0] = WPeligrosoI.Trim();  //datarow[0].ToString();
                    Peligroso[i, 1] = WPeligrosoII.Trim(); //datarow[1].ToString();
                }


                //cargo el nombre cliente
                DataRow datacliente = CS.BuscarCliente(cliente);

                string _Pedido = DGV_Muestra.SelectedRows[0].Cells["Pedido"].Value.ToString();

                string _DirEntrega = _TraerDireccionEntregaPorPedido(_Pedido, _CodCliente);

                if (_DirEntrega.Trim() == "")
                {
                    throw new Exception("No se encuentra dirección de Entrega de Cliente");
                }

                string CodClient       = datacliente[0].ToString();
                string DirClient       = datacliente[1].ToString();
                string LocalidadClient = datacliente[2].ToString();
                string Cuit            = datacliente[3].ToString();
                string DirEntrega      = _DirEntrega; //datacliente[4].ToString();

                string datos = numero_remito + ";" + cliente;
                AgregarColumnasRemito(_dt);



                for (int i = 0; i < DGV_Muestra.SelectedRows.Count; i++)
                {
                    if (Lotes[i] == 0)
                    {
                        Lotes[i] = int.Parse(DGV_Muestra.SelectedRows[i].Cells["Lote2"].Value.ToString());

                        if (Lotes[i] == 0)
                        {
                            Lotes[i] = int.Parse(DGV_Muestra.SelectedRows[i].Cells["Lote1"].Value.ToString());
                        }
                    }

                    DataRow newRow = _dt.NewRow();
                    newRow["Descripcion"]     = DGV_Muestra.SelectedRows[i].Cells["DescriCliente"].Value.ToString();
                    newRow["Cantidad"]        = DGV_Muestra.SelectedRows[i].Cells["Cantidad"].Value.ToString();
                    newRow["Muestra"]         = DGV_Muestra.SelectedRows[i].Cells["Id"].Value.ToString();
                    newRow["Partida"]         = Lotes[i];
                    newRow["Pedido"]          = DGV_Muestra.SelectedRows[i].Cells["Pedido"].Value.ToString();
                    newRow["Codigo"]          = Codigos[i];
                    newRow["Codigo_Original"] = DGV_Muestra.SelectedRows[i].Cells["Codigo"].Value.ToString();
                    newRow["Peligroso"]       = Peligroso[i, 0];
                    newRow["PeligrosoII"]     = Peligroso[i, 1];

                    HojasDeSeguridad[i, 0] = DGV_Muestra.SelectedRows[i].Cells["DescriCliente"].Value.ToString().Trim();

                    HojasDeSeguridad[i, 1] = DGV_Muestra.SelectedRows[i].Cells["Codigo"].Value.ToString().Trim();

                    _dt.Rows.Add(newRow);
                }


                Remito remito = new Remito(datos, _dt, errorLote, sinEnsayo, DirEntrega, CodClient, DirClient, LocalidadClient, Cuit, cliente, HojasDeSeguridad);
                remito.ShowDialog();
            }

            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finalizado :;
        }
Exemple #3
0
        private void BT_Guardar_Click(object sender, EventArgs e)
        {
            //GB_Prove.Visible = false;
            try
            {
                if (!WAutorizado)
                {
                    Clave frm = new Clave();
                    frm.Show(this);
                    return;
                }

                WAutorizado = false;

                if (TB_CodProveedor.Text == "")
                {
                    throw new Exception("Se debe ingresar el proveedor que desea evaluar");
                }

                if (TB_Mes.Text == "")
                {
                    throw new Exception("Se debe ingresar el mes de la evaluación");
                }

                if (TB_Año.Text == "")
                {
                    throw new Exception("Se debe ingresar el año de la evaluación");
                }

                if (CB_Sec1.Text != "")
                {
                    if ((CB_Calif11.Text == "") || (CB_Calif12.Text == "") || (CB_Calif13.Text == "") || (CB_Calif14.Text == ""))
                    {
                        throw new Exception("Se debe calificar todos los parametros del sector");
                    }
                }

                if (CB_Sec2.Text != "")
                {
                    if ((CB_Calif21.Text == "") || (CB_Calif22.Text == "") || (CB_Calif23.Text == "") || (CB_Calif24.Text == ""))
                    {
                        throw new Exception("Se debe calificar todos los parametros del sector");
                    }
                }

                if (CB_Sec3.Text != "")
                {
                    if ((CB_Calif31.Text == "") || (CB_Calif32.Text == "") || (CB_Calif33.Text == "") || (CB_Calif34.Text == ""))
                    {
                        throw new Exception("Se debe calificar todos los parametros del sector");
                    }
                }

                if ((TB_Promedio1.Text != "0") || (TB_Promedio2.Text != "0") || (TB_Promedio3.Text != "0"))
                {
                    CargarEva();
                    _ActualizarObservacionesProveedor();
                }
                else
                {
                    DialogResult dialogResult = MessageBox.Show("No se ha calificado al proveedor en ningún sector. ¿Desea guardar la evaluación igualmente?", "Guardar evaluación",
                                                                MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        CargarEva();

                        _ActualizarObservacionesProveedor();
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }