Exemplo n.º 1
0
        protected void gvReturns_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("starnular"))
            {
                this.msnMessage.Visible = false;
                GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
                string      _nc = e.CommandArgument.ToString();
                //string selectedValue = ((DropDownList)row.FindControl("dwEmployees")).SelectedValue;
                //if (string.IsNullOrEmpty(selectedValue) || selectedValue.Equals("-1"))
                // {
                //   this.msnMessage.LoadMessage("Seleccione el empleado encargado de la marcación para la liquidación No." + _noLiq, ucMessage.MessageType.Error);
                //}
                //else
                {
                    //str1 = string.Empty;
                    try
                    {
                        //   str1 = Picking.finalizePicking(this._user._usv_co, _noLiq);
                        //validar finanzas si es que no se puede anular este documento porque ya esta haciando utilizada como medio de pago
                        int validafinanzas = Returns_Hdr.FValidaNC(_nc);


                        if (validafinanzas == 0)
                        {
                            Returns_Hdr.sbeanularnc(_nc, _user._bas_id);
                            this.msnMessage.LoadMessage("Se Anulo la Nota de Credito No." + _nc + ".", ucMessage.MessageType.Information);
                            this.refreshGridView();
                        }
                        else
                        {
                            msnMessage.LoadMessage("No se puede Anular esta N/C; porque ha sido utilizada por FINANZAS.", UserControl.ucMessage.MessageType.Error);
                        }

                        // Async
                        //Log_Transaction.registerUserInfo(_user, "END PICKING:" + _noLiq);
                    }
                    catch (Exception ex)
                    {
                        this.msnMessage.LoadMessage("Error realizando la Anulacion de NC No." + _nc + "; Detalle: " + ex.Message, ucMessage.MessageType.Error);
                    }
                }
            }
        }
        /// <summary>
        /// Realizar la devolucion de articulos cargados en la grilla
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btReturnArticles_Click(object sender, EventArgs e)
        {
            ///
            try
            {
                /// Lista de artículos a devolver
                List <Returns_Dtl> lstArticlesReturned = new List <Returns_Dtl>();

                /// Lista de articulos a realizar el cambio de storage
                List <Transaction_det> itemsTransDetails = new List <Transaction_det>();

                /// Bandera de que si existieron elementos que enviar
                Decimal bandera = -1;
                /// Numero de articulos a mover de storage
                //int noLinea = 0;
                Boolean moveArticles = false;

                ///
                DataView dv = ((DataView)Session[_nameSessionArtsRet]);

                // Existen articulos que mover de storage
                Decimal articlesToMove = dv.Table.AsEnumerable().Count(x => x.Field <Boolean>("checked") == true);

                if (articlesToMove > 0)
                {
                    //
                    if (string.IsNullOrEmpty(dwStorages.SelectedValue))
                    {
                        dwStorages.Focus();
                        msnMessage.LoadMessage("> Seleccione el area o storage a donde se enviaran los artículos seleccionados.", UserControl.ucMessage.MessageType.Information);
                    }
                    else
                    {
                        moveArticles = true;
                    }
                }
                else
                {
                    moveArticles = true;
                }

                ///
                if (dv != null && dv.Table.Rows.Count > 0 && moveArticles == true)
                {
                    ///
                    foreach (DataRow drow in dv.Table.Rows)
                    {
                        //
                        string invo = drow["idv_invoice"].ToString();
                        //
                        string art = drow["idv_article"].ToString();
                        //
                        string size = drow["idv_size"].ToString();
                        //
                        Decimal qty = Convert.ToDecimal(drow["idn_qty"]);
                        //
                        String calidad = drow["calidad"].ToString();

                        Boolean ck = drow["checked"].Equals("") ? false : (Boolean)drow["checked"];
                        //
                        if (ck)
                        {
                            Returns_Dtl objReturned = new Returns_Dtl(invo, art, size, qty, dwStorages.SelectedValue, calidad);
                            /// Agregar el objeto a la lista generica
                            lstArticlesReturned.Add(objReturned);
                            ///
                            //itemsTransDetails.Add(new Transaction_det(noLinea, art, size, Convert.ToInt16(qty), 0, 0));
                            // Aumentar el numero de linea.
                            //noLinea++;
                        }
                        else
                        {
                            Returns_Dtl objReturned = new Returns_Dtl(invo, art, size, qty, "", calidad);
                            /// Agregar el objeto a la lista generica
                            lstArticlesReturned.Add(objReturned);
                        }
                        ///
                        bandera = 1;
                    }
                }
                ///
                if (bandera > 0)
                {
                    //if (string.IsNullOrEmpty(_user._usv_warehouse) || _user._usv_warehouse.Equals("%%"))
                    //{
                    //    ///
                    //    msnMessage.LoadMessage(" > Usted no esta asociado a ninguna bodega, la devoluci&oacute;n no podrá ser realizAQUARELLA.", UserControl.ucMessage.MessageType.Error);
                    //}
                    //else
                    //{
                    // Devolucion
                    string[] results = Returns_Hdr.saveReturnOrder(hdIdCoordinator.Value, dwStorages.SelectedValue, lstArticlesReturned, _user._bas_id);

                    if (results != null)
                    {
                        //
                        string url = _pageReportArtsReturned + "?noReturn=" + results[0];    // + "&st=" + Constants.StatusReturnForAprob;

                        // Async
                        //Log_Transaction.registerUserInfo(_user, "CREATE RETURN_HDR:" + results[0] + " USER:"******"location.href='" + url + "'";
                            System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel3, Page.GetType(), "click", winAlert, true);
                            ///
                            this.cleanForm();
                            msnMessage.LoadMessage(" > La Devoluci&oacute;n Se Ha Realizado Correctamente : " + results[0] + "<br /> > <a href='" + url + "' target='Blank'>Ver Reporte Devolución</a>", UserControl.ucMessage.MessageType.Information);
                        }
                        catch
                        {
                            //
                            msnMessage.LoadMessage(" > La Devoluci&oacute;n No Se Ha Realizado Correctamente." + results[0] + "<br /> > El reporte de la devoluci&oacute;n no se ha generado; <a href='" + url + "' target='Blank'>Ver Reporte Devolucion</a>", UserControl.ucMessage.MessageType.Error);
                        }

                        /*finally
                         * {
                         *  /// Movimiento de storage
                         *  if (noLinea > 0)
                         *  {
                         *      String resultado = "";
                         *      String storageOut = results[2];
                         *      String storageIn = dwStorages.SelectedValue;
                         *      String refDoc = "1000";
                         *
                         *
                         *      //Insertar en base de datos el documento.
                         *      resultado = STOCKTANSFERSTORAGE.SaveTransfer(_user._usv_co, storageOut, storageIn, refDoc, Bata.Aquarella.BLL.Util.ValuesDB.acronymStatusFinalized, itemsTransDetails).Trim();
                         *      //
                         *      if (!resultado.Equals("0 - 0"))
                         *      {
                         *          msnMessage.LoadMessage(msnMessage.Message + "<br /> > Éxito al cambiar de Storage los artículos seleccionados; Nuevos Documentos : " + resultado + ".", UserControl.ucMessage.MessageType.Information);
                         *      }
                         *      else
                         *      {
                         *          msnMessage.LoadMessage(msnMessage.Message + "<br /> > ERROR al realizar el intercambio de storages hacia : " + dwStorages.SelectedItem.Text, UserControl.ucMessage.MessageType.Error);
                         *      }
                         *  }
                         *  else
                         *  {
                         *      msnMessage.LoadMessage(msnMessage.Message + "<br /> >Sin artículos seleccionados que mover de area o Storage.", UserControl.ucMessage.MessageType.Error);
                         *  }
                         * }*/
                    }
                    else
                    {
                        ///
                        msnMessage.LoadMessage(" > La Devoluci&oacute;n No Se Ha Realizado Correctamente.", UserControl.ucMessage.MessageType.Error);
                    }
                    //}
                }
            }
            catch
            {
                ///
                msnMessage.LoadMessage(" > Ha ocurrido un error y la devoluci&oacute;n no se ha realizado correctamente.", UserControl.ucMessage.MessageType.Error);
            }
        }
        public void PopulateValueCrystalReportI()
        {
            if (Session[_nombreSession] == null)
            {
                //**crear nota de credito la copia
                string  nc_id = Returns_Hdr.ejecuta_duplica_nc(_user._bas_id, Convert.ToDecimal(_noReturn));
                DataSet ds_nc = Returns_Hdr.getRetunrHdr(nc_id);

                // Cosultar la cabecera de la factura
                DataTable dtReturnHdr = new DataTable();

                if (string.IsNullOrEmpty(_status))
                {
                    //dtReturnHdr = Returns_Hdr.getRetunrHdr(_user._usv_co, _noReturn);
                    dtReturnHdr = ds_nc.Tables[0].Copy();
                }
                else if (_status.Equals(Constants.StatusReturnForAprob))
                {
                    dtReturnHdr = Returns_Hdr.getRetunrHdrDea(_user._usv_co, _noReturn);
                }

                if (dtReturnHdr.Rows.Count > 0)
                {
                    /// Crear el array list con el cual se le va a pasar toda la informacion al archivo de crystal
                    articlesReturnedValues = new ArrayList();

                    //
                    string idCoordinador = Convert.ToString(dtReturnHdr.Rows[0]["Not_BasId"]);
                    //
                    string coordEmail = Convert.ToString(dtReturnHdr.Rows[0]["Bas_Correo"]);
                    //
                    string nameCoord = Convert.ToString(dtReturnHdr.Rows[0]["nombres"]);
                    //
                    string coordDocument = Convert.ToString(dtReturnHdr.Rows[0]["Documento"]);
                    //
                    string coordAdress = Convert.ToString(dtReturnHdr.Rows[0]["Bas_Direccion"]);
                    //
                    string coordPhone = Convert.ToString(dtReturnHdr.Rows[0]["Bas_Telefono"]);
                    //
                    string coordUbication = Convert.ToString(dtReturnHdr.Rows[0]["ubicacion"]);
                    //
                    DateTime dateReturn = Convert.ToDateTime(dtReturnHdr.Rows[0]["Not_Fecha"]);
                    //
                    string rhvTransaction = "";// dtReturnHdr.Rows[0]["rhv_transaction"].ToString();
                    //
                    string rhnPerson = dtReturnHdr.Rows[0]["Not_BasId"].ToString();
                    //
                    string rhnEmployee = "";      // dtReturnHdr.Rows[0]["rhn_employee"].ToString();
                    //PERCEPCION
                    Decimal percepcion = 0;       //Convert.ToDecimal(dtReturnHdr.Rows[0]["percepcion"]);
                    //
                    Decimal porc_percepcion = 0;  //Convert.ToDecimal(dtReturnHdr.Rows[0]["porc_percepcion"]);

                    string _direccionfiscal = ""; //dtReturnHdr.Rows[0]["direccionf"].ToString();

                    // Id Bodega, para consultar la info de la bodega donde se genera la factura
                    //string stvWarehouse = "";// dtReturnHdr.Rows[0]["stv_warehouse"].ToString();
                    String mcpConcepto    = dtReturnHdr.Rows[0]["Con_Descripcion"].ToString();
                    String varNotaCredito = dtReturnHdr.Rows[0]["notaCredito"].ToString();

                    decimal varSubTotal = Convert.ToDecimal(dtReturnHdr.Rows[0]["SUBTOTAL"]);
                    decimal varIGV      = Convert.ToDecimal(dtReturnHdr.Rows[0]["IGV"]);
                    decimal varTotal    = Convert.ToDecimal(dtReturnHdr.Rows[0]["TOTAL"]);

                    ///
                    //warehouses objW = new warehouses(_user._usv_co, stvWarehouse);
                    //DataTable dtInfoWarehouse = objW.getWarehouseByPk();

                    string wavDescription = "";
                    string wavAddress     = "";
                    string wavPhone       = "";
                    string wavUbication   = "";
                    //
                    //if (dtInfoWarehouse != null && dtInfoWarehouse.Rows.Count > 0)
                    //{
                    ///
                    wavDescription = dtReturnHdr.Rows[0]["Alm_Descripcion"].ToString().ToUpper();
                    wavAddress     = dtReturnHdr.Rows[0]["Alm_Direccion"].ToString();
                    wavPhone       = dtReturnHdr.Rows[0]["Alm_Telefono"].ToString();
                    wavUbication   = "";// dtReturnHdr.Rows[0]["ubication"].ToString();
                    //}

                    // Consultar los datos de la persona a quien se le facturo
                    //DataTable dtInfoPersonInvoiced = Basic_Data.searchPerson(_user._usv_co, "-1", "", rhnPerson, "", "").Tables[0];

                    string facturadoDestinatario = "";
                    string facturadoUbicacion    = "";
                    string facturadoTelefono     = "";

                    ///
                    //if (dtInfoPersonInvoiced != null && dtInfoPersonInvoiced.Rows.Count > 0)
                    // {
                    ///
                    facturadoDestinatario = dtReturnHdr.Rows[0]["nombres"].ToString();
                    facturadoUbicacion    = dtReturnHdr.Rows[0]["ubicacion"].ToString();
                    facturadoTelefono     = dtReturnHdr.Rows[0]["Bas_Telefono"].ToString();
                    // }

                    // DETALLE DE LA DEVOLUCION
                    //DataTable dtReturnDtl = Returns_Dtl.getRetunrDtl(_user._usv_co, _noReturn);
                    DataTable dtReturnDtl = new DataTable();
                    dtReturnDtl = ds_nc.Tables[1].Copy();

                    //
                    foreach (DataRow drLine in dtReturnDtl.Rows)
                    {
                        //
                        string rhvInvoice = drLine["ven_id"].ToString();
                        //
                        string article = drLine["Not_Det_ArtId"].ToString();
                        //
                        string articleName = drLine["articulo"].ToString();
                        //
                        string articleColor = drLine["color"].ToString();
                        //
                        string size = drLine["Not_Det_TalId"].ToString();
                        //
                        decimal qty = Convert.ToDecimal(drLine["Not_Det_Cantidad"]);
                        //
                        decimal sellPrice = Convert.ToDecimal(drLine["Not_Det_Precio"]);
                        //
                        decimal disscountLin = 0;// Convert.ToDecimal(drLine["rdn_disscount_lin"]);
                        //
                        decimal commision = Convert.ToDecimal(drLine["Not_Det_ComisionM"]);
                        //
                        decimal handling = 0;     // Convert.ToDecimal(drLine["rdn_handling"]);
                        //
                        decimal disscountGen = 0; // Convert.ToDecimal(drLine["rdn_disscount_gen"]);
                        //
                        decimal taxes = Convert.ToDecimal(drLine["igvm"]);

                        DateTime FecEmisionFactura = Convert.ToDateTime(drLine["FecEmisionFactura"]);

                        //
                        ReporteDevolucion objAR = new ReporteDevolucion(idCoordinador, coordEmail, nameCoord,
                                                                        coordDocument, coordAdress, coordPhone, coordUbication, facturadoDestinatario,
                                                                        facturadoUbicacion, facturadoTelefono, wavDescription, wavAddress,
                                                                        wavPhone, wavUbication, _user._usv_co, _noReturn, dateReturn, rhvTransaction,
                                                                        rhnPerson, rhnEmployee, rhvInvoice, article, articleName, articleColor, size, qty, sellPrice, disscountLin,
                                                                        commision, handling, disscountGen, taxes, mcpConcepto, FecEmisionFactura, varNotaCredito, varSubTotal, varIGV, varTotal, percepcion, porc_percepcion, _direccionfiscal);

                        // Adicionar el nuevo objeto al arreglo
                        articlesReturnedValues.Add(objAR);
                    }
                }
                //
                Session[_nombreSession] = articlesReturnedValues;
            }
            else
            {
                articlesReturnedValues = (ArrayList)Session[_nombreSession];
            }
        }
Exemplo n.º 4
0
 protected void initGrid(string co, string _startDate, string _endDate, string ware, string area)
 {
     this.Session[this._nameSessionData] = (object)Returns_Hdr.getReturnsByDate(_startDate, _endDate).Tables[0];
     this.gvReturns.DataSourceID         = this.odsReturns.ID;
     this.gvReturns.DataBind();
 }