private void PreFacturar()
        {
            try
            {
                using (Models.WerkERPContext db = new WerkUI.Models.WerkERPContext())
                {
                    //pFormFac.cod_cliente = Convert.ToDecimal(vLiq.CODCLIENTE);
                    //pFormFac.cod_liquidacion = Convert.ToDecimal(vLiq.Cod__Liquidación);
                    //pFormFac.cod_moneda = Convert.ToInt32(((DropDownList)PreFacturaFormView.FindControl("new_monedaDDL")).SelectedValue);
                    //pFormFac.fecha = System.DateTime.Now;
                    //pFormFac.ruc = vLiq.R_U_C_.Trim();
                    //pFormFac.direccion = vLiq.Dirección;
                    //pFormFac.cod_empresa = Convert.ToInt32(vLiq.CodEmpresa);
                    //pFormFac.telefono = vLiq.Teléfono;
                    //pFormFac.cod_tipo_factura = Guid.Parse(((DropDownList)PreFacturaFormView.FindControl("new_tipo_facturaDDL")).SelectedValue.ToString());
                    //pFormFac.nro_despacho_interno = Convert.ToDecimal(vLiq.Nro__Despacho_Interno.Trim());
                    //pFormFac.nro_despacho = vLiq.Nro__Despacho;

                    Models.ProFormaFactura num_factura = new Models.ProFormaFactura {
                        num_factura = Convert.ToDecimal(((TextBox)PreFacturaFormView.FindControl("new_num_facturaTB")).Text)
                    };
                    Models.ProFormaFactura cod_cliente = new Models.ProFormaFactura {
                        cod_cliente = Convert.ToDecimal(((TextBox)PreFacturaFormView.FindControl("new_CodClienteTB")).Text)
                    };
                    Models.ProFormaFactura cod_liquidacion = new Models.ProFormaFactura {
                        cod_liquidacion = Convert.ToDecimal(((TextBox)PreFacturaFormView.FindControl("new_num_liquidacionTB")).Text)
                    };
                    Models.ProFormaFactura cod_moneda = new Models.ProFormaFactura {
                        cod_moneda = Convert.ToInt32(((DropDownList)PreFacturaFormView.FindControl("new_monedaDDL")).SelectedValue)
                    };
                    Models.ProFormaFactura fecha = new Models.ProFormaFactura {
                        fecha = System.DateTime.Now
                    };
                    Models.ProFormaFactura ruc = new Models.ProFormaFactura {
                        ruc = ((TextBox)PreFacturaFormView.FindControl("new_rucTB")).Text
                    };
                    Models.ProFormaFactura direccion = new Models.ProFormaFactura {
                        direccion = ((TextBox)PreFacturaFormView.FindControl("new_direccionTB")).Text
                    };
                    Models.ProFormaFactura cod_empresa = new Models.ProFormaFactura {
                        cod_empresa = Convert.ToInt32(((TextBox)PreFacturaFormView.FindControl("new_CodEmpresaTB")).Text)
                    };
                    Models.ProFormaFactura telefono = new Models.ProFormaFactura {
                        telefono = ((TextBox)PreFacturaFormView.FindControl("new_telefonoTB")).Text
                    };


                    db.ProFormaFacturas.Add(num_factura);
                    db.ProFormaFacturas.Add(cod_cliente);
                    db.ProFormaFacturas.Add(cod_liquidacion);

                    //db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #2
0
        private void Obtener_datos_liquidacion(int p_cod_liquidacion)
        {
            try
            {
                /*Codigo de Inicializacion Beta*/
                object[] para = { p_cod_liquidacion };
                Models.V_LIQUIDACIONES vLiq;

                if (p_cod_liquidacion > 0)
                {
                    using (Models.WerkERPContext db = new WerkUI.Models.WerkERPContext())
                    {
                        //Obtengo la Liquidacion segun el cod_liquidacion recibdo por el formulario web
                        vLiq = db.V_LIQUIDACIONES.Find(para);

                        ((TextBox)PreFacturaFormView.FindControl("new_num_facturaTB")).Attributes.Add("onblur", "javascript:verifyNroFactura(this);");

                        // Asignamos los valores a los campos del form view
                        ((TextBox)PreFacturaFormView.FindControl("new_fechaTB")).Text                 = DateTime.Now.ToShortDateString();
                        ((TextBox)PreFacturaFormView.FindControl("new_clienteTB")).Text               = vLiq.Cliente.Trim();
                        ((TextBox)PreFacturaFormView.FindControl("new_CodClienteTB")).Text            = vLiq.CODUSUARIO.ToString();
                        ((TextBox)PreFacturaFormView.FindControl("new_CodEmpresaTB")).Text            = vLiq.CODEMPRESA.ToString();
                        ((TextBox)PreFacturaFormView.FindControl("new_num_liquidacionTB")).Text       = vLiq.Nro__Liquidación.ToString();
                        ((DropDownList)PreFacturaFormView.FindControl("new_monedaDDL")).SelectedIndex = 1;
                        ((TextBox)PreFacturaFormView.FindControl("new_telefonoTB")).Text              = vLiq.Teléfono.Trim();
                        ((TextBox)PreFacturaFormView.FindControl("new_rucTB")).Text                         = vLiq.R_U_C_.Trim();
                        ((TextBox)PreFacturaFormView.FindControl("new_direccionTB")).Text                   = vLiq.Dirección.Trim();
                        ((TextBox)PreFacturaFormView.FindControl("new_despachanteTB")).Text                 = vLiq.Despachante.Trim();
                        ((TextBox)PreFacturaFormView.FindControl("new_ruc_despachanteTB")).Text             = vLiq.R_U_C__Despachante.Trim();
                        ((DropDownList)PreFacturaFormView.FindControl("new_tipo_facturaDDL")).SelectedIndex = 1;
                        ((TextBox)PreFacturaFormView.FindControl("new_despacho_internoTB")).Text            = vLiq.Nro__Despacho_Interno.Trim();
                        ((TextBox)PreFacturaFormView.FindControl("new_despachoTB")).Text                    = vLiq.Nro__Despacho.Trim();
                        ((TextBox)PreFacturaFormView.FindControl("new_totalTB")).Text                       = Core.Util.GetFormatedNumber(vLiq.Total);
                        ((TextBox)PreFacturaFormView.FindControl("new_iva_gastosTB")).Text                  = Core.Util.GetFormatedNumber(vLiq.IVA_Gastos);
                        ((TextBox)PreFacturaFormView.FindControl("new_iva_honorariosTB")).Text              = Core.Util.GetFormatedNumber(vLiq.IVA_Honorarios);
                        ((TextBox)PreFacturaFormView.FindControl("new_retencion_ivaTB")).Text               = Core.Util.GetFormatedNumber(calcularRetenciones(Convert.ToDecimal(vLiq.IVA_Gastos), Convert.ToDecimal(vLiq.IVA_Retención)));
                        ((TextBox)PreFacturaFormView.FindControl("new_retencion_iva_gastosTB")).Text        = Core.Util.GetFormatedNumber(vLiq.IVA_Ret__Gastos);
                        ((TextBox)PreFacturaFormView.FindControl("new_retencion_iva_honorariosTB")).Text    = Core.Util.GetFormatedNumber(vLiq.IVA_Ret__Honorarios);
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Example #3
0
        private void PreFacturar()
        {
            try
            {
                using (Models.WerkERPContext db = new WerkUI.Models.WerkERPContext())
                {
                    Models.ProFormaFactura p = new Models.ProFormaFactura();

                    Models.ProFormaFactura num_factura = new Models.ProFormaFactura {
                        num_factura = Convert.ToDecimal(((TextBox)PreFacturaFormView.FindControl("new_num_facturaTB")).Text)
                    };
                    Models.ProFormaFactura cod_cliente = new Models.ProFormaFactura {
                        cod_cliente = Convert.ToDecimal(((TextBox)PreFacturaFormView.FindControl("new_CodClienteTB")).Text)
                    };
                    Models.ProFormaFactura cod_liquidacion = new Models.ProFormaFactura {
                        cod_liquidacion = Convert.ToDecimal(((TextBox)PreFacturaFormView.FindControl("new_num_liquidacionTB")).Text)
                    };
                    Models.ProFormaFactura cod_moneda = new Models.ProFormaFactura {
                        cod_moneda = Convert.ToInt32(((DropDownList)PreFacturaFormView.FindControl("new_monedaDDL")).SelectedValue)
                    };
                    Models.ProFormaFactura fecha = new Models.ProFormaFactura {
                        fecha = System.DateTime.Now
                    };
                    Models.ProFormaFactura ruc = new Models.ProFormaFactura {
                        ruc = ((TextBox)PreFacturaFormView.FindControl("new_rucTB")).Text
                    };
                    Models.ProFormaFactura direccion = new Models.ProFormaFactura {
                        direccion = ((TextBox)PreFacturaFormView.FindControl("new_direccionTB")).Text
                    };
                    Models.ProFormaFactura cod_empresa = new Models.ProFormaFactura {
                        cod_empresa = Convert.ToInt32(((TextBox)PreFacturaFormView.FindControl("new_CodEmpresaTB")).Text)
                    };
                    Models.ProFormaFactura telefono = new Models.ProFormaFactura {
                        telefono = ((TextBox)PreFacturaFormView.FindControl("new_telefonoTB")).Text
                    };
                    Models.ProFormaFactura cod_tipo_factura = new Models.ProFormaFactura {
                        cod_tipo_factura = Guid.Parse(((DropDownList)PreFacturaFormView.FindControl("new_tipo_facturaDDL")).SelectedValue.ToString())
                    };
                    Models.ProFormaFactura nro_despacho_interno = new Models.ProFormaFactura {
                        nro_despacho_interno = Convert.ToDecimal(((TextBox)PreFacturaFormView.FindControl("new_despacho_internoTB")).Text)
                    };
                    Models.ProFormaFactura nro_despacho = new Models.ProFormaFactura {
                        nro_despacho = ((TextBox)PreFacturaFormView.FindControl("new_despachoTB")).Text
                    };

                    /*
                     * db.ProFormaFacturas.Add(num_factura);
                     * db.ProFormaFacturas.Add(cod_cliente);
                     * db.ProFormaFacturas.Add(cod_liquidacion);
                     * db.ProFormaFacturas.Add(cod_moneda);
                     * db.ProFormaFacturas.Add(fecha);
                     * db.ProFormaFacturas.Add(ruc);
                     * db.ProFormaFacturas.Add(direccion);
                     * db.ProFormaFacturas.Add(cod_empresa);
                     * db.ProFormaFacturas.Add(telefono);
                     * db.ProFormaFacturas.Add(cod_tipo_factura);
                     * db.ProFormaFacturas.Add(nro_despacho_interno);
                     * db.ProFormaFacturas.Add(nro_despacho);
                     */

                    db.SaveChanges();

                    for (int i = 0; i <= PreFacturaDetalleGridView.Rows.Count - 1; i++)
                    {
                        GridViewRow row = (GridViewRow)PreFacturaDetalleGridView.Rows[i];
                        CheckBox    chk = (CheckBox)row.FindControl("ConceptoCheck");
                        if (chk.Checked)
                        {
                            Models.ProFormaFacturaDetalle secuencia = new Models.ProFormaFacturaDetalle {
                                secuencia_interna = Convert.ToDecimal(((Label)row.FindControl("lblSecuencia")).Text)
                            };
                            Models.ProFormaFacturaDetalle comentario = new Models.ProFormaFacturaDetalle {
                                comentario = ((Label)row.FindControl("lblComentario")).Text
                            };
                            Models.ProFormaFacturaDetalle cod_con_liquidacion = new Models.ProFormaFacturaDetalle {
                                cod_con_liquidacion = Convert.ToDecimal(cod_liquidacion)
                            };
                            Models.ProFormaFacturaDetalle descripcion = new Models.ProFormaFacturaDetalle {
                                descripcion = ((Label)row.FindControl("lblConcepto")).Text
                            };
                            Models.ProFormaFacturaDetalle grupo_impresion = new Models.ProFormaFacturaDetalle {
                                grupo_impresion = Byte.Parse(((Label)row.FindControl("lblGrupo")).Text)
                            };
                            Models.ProFormaFacturaDetalle importe = new Models.ProFormaFacturaDetalle {
                                importe = Convert.ToDecimal(((Label)row.FindControl("lblImporte")).Text)
                            };
                            Models.ProFormaFacturaDetalle facturado = new Models.ProFormaFacturaDetalle {
                                Facturado = true
                            };
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }