Esempio n. 1
0
        protected void btnLiberarSoftware_Click(object sender, EventArgs e)
        {
            try
            {
                string Mensaje = string.Empty;

                foreach (GridViewRow gr in gvLiberacionSoftware.Rows)
                {
                    CheckBox chkSeleccionado = (CheckBox)gr.Cells[0].FindControl("chkSelecciona");

                    if (chkSeleccionado.Checked)
                    {
                        string s_idImte = gvLiberacionSoftware.DataKeys[gr.RowIndex].Values["Cve_Asignacion"].ToString();

                        Asignacion_Software asignacionSoftware = new Asignacion_Software();
                        asignacionSoftware.Cve_Asignacion = Convert.ToInt32(s_idImte);

                        BLAsignacion_Software blAsignacionSoftware = new BLAsignacion_Software(asignacionSoftware);
                        asignacionSoftware = blAsignacionSoftware.ObtenAsignacionSoftware();
                        asignacionSoftware.Nombre_Usuario = "Disponible";
                        asignacionSoftware.Area_Solicita  = null;

                        blAsignacionSoftware = new BLAsignacion_Software(asignacionSoftware);
                        Mensaje = blAsignacionSoftware.ActualiaAsignacionSoftware();
                    }
                }

                List <int> idSelected = HttpContext.Current.Session["idSelectedSess"] as List <int>;

                if (idSelected != null)
                {
                    foreach (int item in idSelected)
                    {
                        Asignacion_Software asignacionSoftware = new Asignacion_Software();
                        asignacionSoftware.Cve_Asignacion = item;

                        BLAsignacion_Software blAsignacionSoftware = new BLAsignacion_Software(asignacionSoftware);
                        asignacionSoftware = blAsignacionSoftware.ObtenAsignacionSoftware();
                        asignacionSoftware.Nombre_Usuario = "Disponible";
                        asignacionSoftware.Area_Solicita  = null;

                        blAsignacionSoftware = new BLAsignacion_Software(asignacionSoftware);
                        blAsignacionSoftware.ActualiaAsignacionSoftware();
                    }
                }

                HttpContext.Current.Session["idSelectedSess"] = null;

                if (Mensaje.Equals("La Asignacion de software fue actualizado correctamente"))
                {
                    CambiaEstadoNotificacion("Info", true, "La liberación de software se realizó correctamente");
                    CambiaEstadoNotificacion("Warning", false, string.Empty);

                    if (hdnNuevoUsuario.Value.Equals("1"))
                    {
                        string AreaSolicita = dplAreaSolicita.SelectedItem.Text;
                        LLenaUsuario();
                        llenarArea_Solicita();

                        ddlUsuarioAsignado.SelectedValue = txtUsuarioNuevo.Text;
                        dplAreaSolicita.SelectedValue    = AreaSolicita;
                        pnlNuevoUsuario.Visible          = false;
                        pnlUsuarioAsignado.Visible       = true;
                    }
                    else
                    {
                        ddlUsuarioAsignado_SelectedIndexChanged(sender, e);
                    }

                    LabelInfo.Focus();
                }
            }
            catch (Exception ex)
            {
                CambiaEstadoNotificacion("Info", false, string.Empty);
                CambiaEstadoNotificacion("Warning", true, "Error: " + ex.Message);
                LabelError.Focus();
                HttpContext.Current.Session["idSelectedSess"] = null;
            }
        }
        protected void btnGuardaDetalle_Click(object sender, EventArgs e)
        {
            DateTime?value        = null;
            int?     valueInt     = null;
            decimal? valueDecimal = null;

            try
            {
                if (hdnCve_Asignacion.Value.Equals("0"))
                {
                    if (!this.dplNUmeroLicencia.SelectedItem.Text.Equals("0"))
                    {
                        Asignacion_Software asiSoftware            = new Asignacion_Software();
                        int numeroDeLicencias                      = Convert.ToInt32(dplNUmeroLicencia.SelectedItem.Text);
                        BLAsignacion_Software blAsignacionSoftware = new BLAsignacion_Software(asiSoftware);

                        for (int i = 0; i < numeroDeLicencias; i++)
                        {
                            asiSoftware.Cve_Software      = Convert.ToInt32(hdnCve_Software.Value);
                            asiSoftware.Area_Solicita     = txtAreaSolicitaD.Text.Trim().Equals("") ? null : txtAreaSolicitaD.Text;
                            asiSoftware.Centro_Costo      = txtCentroCostosD.Text.Trim().Equals("") ? null : txtCentroCostosD.Text;
                            asiSoftware.Dolares           = txtDolaresD.Text.Trim().Equals("") ? valueDecimal : Convert.ToDecimal(txtDolaresD.Text);
                            asiSoftware.Fecha_Compra      = txtFechaCompraD.Text.Trim().Equals("") ? value : Convert.ToDateTime(txtFechaCompraD.Text);
                            asiSoftware.Fecha_Vencimiento = txtFechaVencimientoD.Text.Trim().Equals("") ? value : Convert.ToDateTime(txtFechaVencimientoD.Text);
                            asiSoftware.Responsiva        = txtIncluido_ResponsivaD.Text.Trim().Equals("") ? null : txtIncluido_ResponsivaD.Text;

                            int initContador = 4;

                            TextBox textKey = (TextBox)TableDetalle.FindControl("txtKeyR" + initContador);

                            if (textKey != null)
                            {
                                asiSoftware.Key = textKey.Text;
                            }

                            asiSoftware.Lenguaje                  = txtLenguajeD.Text.Equals("") ? null : txtLenguajeD.Text;
                            asiSoftware.Lote_Code                 = txtLoteCodeD.Text.Equals("") ? null : txtLoteCodeD.Text;
                            asiSoftware.Material                  = txtMaterialD.Text.Equals("") ? null : txtMaterialD.Text;
                            asiSoftware.Numero_Factura            = txtNoFacturaD.Text.Trim().Equals("") ? valueInt : Convert.ToInt32(txtNoFacturaD.Text);
                            asiSoftware.Nombre_Usuario            = txtNombreUsuarioD.Text;
                            asiSoftware.Numero_Requisicion_Compra = txtNoRequisicionCompraD.Text.Trim().Equals("") ? valueInt : Convert.ToInt32(txtNoRequisicionCompraD.Text);
                            asiSoftware.Numero_Taejeta            = txtNoTarjetaD.Text.Equals("") ? null : txtNoTarjetaD.Text;
                            asiSoftware.Observaciones             = txtObservacionD.Text.Equals("") ? null : txtObservacionD.Text;
                            asiSoftware.Pesos      = txtPesosD.Text.Trim().Equals("") ? valueDecimal : Convert.ToDecimal(txtPesosD.Text);
                            asiSoftware.Proveedor  = txtProveedorD.Text.Equals("") ? null : txtProveedorD.Text;
                            asiSoftware.Responsiva = txtResponsivaD.Text.Equals("") ? null : txtResponsivaD.Text;
                            asiSoftware.Sucursal   = txtSucursalD.Text.Equals("") ? null : txtSucursalD.Text;

                            blAsignacionSoftware.insertaAsignacionSoftwareNuevo();

                            initContador++;
                        }

                        gvwDetalle.DataSource = blAsignacionSoftware.ObtieneAsignacionSoftware(asiSoftware.Cve_Software);
                        gvwDetalle.DataBind();

                        BLSoftware            oblSoftware            = new BLSoftware();
                        BLAsignacion_Software oblAsiganacionSoftware = new BLAsignacion_Software();

                        List <TotalesSoftware> totalesSoftware =
                            oblSoftware.ObtieneTotalesSoftware(asiSoftware.Cve_Software);

                        grvTotalTipo.DataSource = totalesSoftware;
                        grvTotalTipo.DataBind();

                        InventarioHSC.Model.Software software = oblSoftware.Software(Convert.ToInt32(hdnCve_Software.Value));

                        string xmlData = oblSoftware.xmlDataTotales(totalesSoftware, software.Descripcion);

                        HabilitarBotonAgregarDetalle(true);

                        StringBuilder Clientscript = new StringBuilder();
                        Clientscript.Append("<script>");
                        Clientscript.Append("updateChartTotalesSoftware(\"" + xmlData + "\");");
                        Clientscript.Append("</script>");

                        if (!ClientScript.IsStartupScriptRegistered("udpChart"))
                        {
                            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "udpChart", Clientscript.ToString(), false);
                        }

                        mpeDetalleAsignacion.Hide();
                    }
                    else
                    {
                        LabelInfo.Focus();
                        Warning.Visible   = false;
                        LabelWarning.Text = "";
                        LabelInfo.Text    = "Seleccione el numero de licencias";
                        Info.Visible      = true;
                    }
                }
                else
                {
                    Asignacion_Software asiSoftware = new Asignacion_Software();

                    asiSoftware.Cve_Software        = Convert.ToInt32(hdnCve_Software.Value);
                    asiSoftware.Cve_Asignacion      = Convert.ToInt32(hdnCve_Asignacion.Value);
                    asiSoftware.Area_Solicita       = txtAreaSolicitaD.Text.Trim().Equals("") ? null : txtAreaSolicitaD.Text;
                    asiSoftware.Centro_Costo        = txtCentroCostosD.Text.Trim().Equals("") ? null : txtCentroCostosD.Text;
                    asiSoftware.Dolares             = txtDolaresD.Text.Trim().Equals("") ? valueDecimal : Convert.ToDecimal(txtDolaresD.Text);
                    asiSoftware.Fecha_Compra        = txtFechaCompraD.Text.Trim().Equals("") ? value : Convert.ToDateTime(txtFechaCompraD.Text);
                    asiSoftware.Fecha_Vencimiento   = txtFechaVencimientoD.Text.Trim().Equals("") ? value : Convert.ToDateTime(txtFechaVencimientoD.Text);
                    asiSoftware.Incluido_Responsiva = txtIncluido_ResponsivaD.Text.Trim().Equals("") ? null : txtIncluido_ResponsivaD.Text;
                    asiSoftware.Key                       = txtKeyD.Text;
                    asiSoftware.Lenguaje                  = txtLenguajeD.Text.Trim().Equals("") ? null : txtLenguajeD.Text;
                    asiSoftware.Lote_Code                 = txtLoteCodeD.Text.Equals("") ? null : txtLoteCodeD.Text;
                    asiSoftware.Material                  = txtMaterialD.Text.Equals("") ? null : txtMaterialD.Text;
                    asiSoftware.Numero_Factura            = txtNoFacturaD.Text.Trim().Equals("") ? valueInt : Convert.ToInt32(txtNoFacturaD.Text);
                    asiSoftware.Nombre_Usuario            = txtNombreUsuarioD.Text;
                    asiSoftware.Numero_Requisicion_Compra = txtNoRequisicionCompraD.Text.Trim().Equals("") ? valueInt : Convert.ToInt32(txtNoRequisicionCompraD.Text);
                    asiSoftware.Numero_Taejeta            = txtNoTarjetaD.Text.Equals("") ? null : txtNoTarjetaD.Text;
                    asiSoftware.Observaciones             = txtObservacionD.Text.Equals("") ? null : txtObservacionD.Text;
                    asiSoftware.Pesos                     = txtPesosD.Text.Trim().Equals("") ? valueDecimal : Convert.ToDecimal(txtPesosD.Text);
                    asiSoftware.Proveedor                 = txtProveedorD.Text.Trim().Equals("") ? null : txtProveedorD.Text;
                    asiSoftware.Responsiva                = txtResponsivaD.Text.Equals("") ? null : txtResponsivaD.Text;
                    asiSoftware.Sucursal                  = txtSucursalD.Text.Trim().Equals("") ? null : txtSucursalD.Text;

                    BLAsignacion_Software blAsignacionSoftware = new BLAsignacion_Software(asiSoftware);
                    string mensaje = blAsignacionSoftware.ActualiaAsignacionSoftware();

                    gvwDetalle.DataSource = blAsignacionSoftware.ObtieneAsignacionSoftware(Convert.ToInt32(hdnCve_Software.Value));
                    gvwDetalle.DataBind();

                    EnviaMensaje(mensaje);
                    mpeDetalleAsignacion.Hide();
                }

                hdnGenerrarControles.Value = "0";
            }
            catch (Exception ex)
            {
                LabelWarning.Focus();
                Warning.Visible            = true;
                LabelWarning.Text          = "Ocurrio un Error en el Proceso: " + ex.Message;
                LabelInfo.Text             = "";
                Info.Visible               = false;
                hdnGenerrarControles.Value = "0";
                mpeDetalleAsignacion.Hide();
            }
        }