protected void LinkButton_ref_Click(object sender, EventArgs e) { if ( string.IsNullOrEmpty(txt_folio_ref.Text) || string.IsNullOrEmpty(txt_fecha_ref.Text) ) { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Por Favor Complete Todos los Campos de Referencia');", true); } else { DataTable dt_ref = (DataTable)ViewState["REFERENCIAS"]; DataRow dr = dt_ref.NewRow(); dr["NroLinRef"] = dt_ref.Rows.Count; dr["TpoDocRef"] = list_documentos.SelectedValue.ToString(); dr["IndGlobal"] = ""; dr["FolioRef"] = txt_folio_ref.Text.Trim(); dr["RUTOtr"] = ""; dr["FchRef"] = txt_fecha_ref.Text.Trim(); string prubea = ListCodRef.SelectedValue.ToString(); dr["CodRef"] = ListCodRef.SelectedValue.ToString(); dr["RazonRef"] = ListCodRef.SelectedItem.ToString(); dt_ref.Rows.Add(dr); ViewState["REFERENCIAS"] = dt_ref; Grid_Referencia.DataSource = (DataTable)ViewState["REFERENCIAS"]; Grid_Referencia.DataBind(); dt_ref = (DataTable)ViewState["REFERENCIAS"]; } Grid_Referencia.DataBind(); }
protected void Grid_Referencia_RowDeleting(object sender, GridViewDeleteEventArgs e) { DataTable dt_ref = (DataTable)ViewState["REFERENCIAS"]; dt_ref.Rows.RemoveAt(e.RowIndex); int i = -1; foreach (DataRow row in dt_ref.Rows) { i++; row["NroLinRef"] = i; } GridView1.DataSource = dt_ref; GridView1.DataBind(); Grid_Referencia.DataSource = (DataTable)ViewState["REFERENCIAS"]; Grid_Referencia.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { Session s = new Session(); if (s.get_tpo_doc() == null) { Response.Redirect("Seleccion_Docs.apsx"); } if (string.IsNullOrEmpty(s.get_nombre_emp())) { Response.Redirect("Seleccion_Empresa.aspx"); } if (string.IsNullOrEmpty(s.get_id_emp())) { Response.Redirect("Seleccion_Empresa.aspx"); } if (!this.IsPostBack) { //<detalle> datatable #region DataTable dt = new DataTable(); dt.TableName = ("DETALLES"); dt.Columns.AddRange(new DataColumn[37] { new DataColumn("NroLinDet"), new DataColumn("TpoCodigo"), new DataColumn("VlrCodigo"), new DataColumn("IndExe"), new DataColumn("IndAgente"), new DataColumn("MntBaseFaena"), new DataColumn("MntMargComer"), new DataColumn("PrcConsFinal"), new DataColumn("NmbItem"), new DataColumn("DscItem"), new DataColumn("QtyRef"), new DataColumn("UnmdRef"), new DataColumn("PrcRef"), new DataColumn("QtyItem"), new DataColumn("SubQty"), new DataColumn("SubCod"), new DataColumn("FchElabor"), new DataColumn("FchVencim"), new DataColumn("UnmdItem"), new DataColumn("PrcItem"), new DataColumn("PrcOtrMon"), new DataColumn("Moneda"), new DataColumn("FctConv"), new DataColumn("DctoOtrMnda"), new DataColumn("RecargoOtrMnda"), new DataColumn("MontoItemOtrMnda"), new DataColumn("DescuentoPct"), new DataColumn("DescuentoMonto"), new DataColumn("TipoDscto"), new DataColumn("ValorDscto"), new DataColumn("RecargoPct"), new DataColumn("RecargoMonto"), new DataColumn("TipoRecargo"), new DataColumn("ValorRecargo"), new DataColumn("CodImpAdic"), new DataColumn("MontoItem"), new DataColumn("AUX") }); ViewState["DETALLES"] = dt; GridView1.DataSource = (DataTable)ViewState["DETALLES"]; GridView1.DataBind(); #endregion //</detalle> //<referencias> datatable #region DataTable dt_ref = new DataTable(); dt_ref.TableName = ("REFERENCIAS"); dt_ref.Columns.AddRange(new DataColumn[8] { new DataColumn("NroLinRef"), new DataColumn("TpoDocRef"), new DataColumn("IndGlobal"), new DataColumn("FolioRef"), new DataColumn("RUTOtr"), new DataColumn("FchRef"), new DataColumn("CodRef"), new DataColumn("RazonRef") }); ViewState["REFERENCIAS"] = dt_ref; Grid_Referencia.DataSource = (DataTable)ViewState["REFERENCIAS"]; Grid_Referencia.DataBind(); #endregion //</referencias> //<desc_global> #region DataTable dt_desc_global = new DataTable(); dt_desc_global.TableName = ("DESCUENTO_GLOBAL"); dt_desc_global.Columns.AddRange(new DataColumn[7] { new DataColumn("NroLinDR"), new DataColumn("TpoMov"), new DataColumn("GlosaDR"), new DataColumn("TpoValor"), new DataColumn("ValorDR"), new DataColumn("ValorDROtrMnda"), new DataColumn("IndExeDR") }); ViewState["DESCUENTO_GLOBAL"] = dt_desc_global; #endregion //</desc_global > txt_sub_uni.Attributes.Add("readonly", "readonly"); txt_desc_rec.Text = "0"; txt_cantidad.Text = "0"; } // var serv = new ServFact.ServicioFacturaClient(); TextArea_clientes.Value = serv.ObtieneListaClientes(Int32.Parse(s.get_id_emp())); TextArea_detalles.Value = serv.ObtieListaDetalle(Int32.Parse(s.get_id_emp())); string tipodoc = s.get_tpo_doc(); List_Tipo_Doc.SelectedValue = tipodoc; if (List_Tipo_Doc.SelectedValue.ToString() == "34") { List_iva.SelectedIndex = List_iva.Items.IndexOf(List_iva.Items.FindByText("NO")); List_iva.Enabled = false; } // int id_emp = Int32.Parse(s.get_id_emp()); string json = s.get_ListaEmpresas(); DataTable dt_list_emp = (DataTable)JsonConvert.DeserializeObject(json, (typeof(DataTable))); var empresa_a_usar = from x in dt_list_emp.AsEnumerable() where x.Field <Int64>("ID_EMPESA") == id_emp select new { rut_emis = x.Field <string>("RUT_EMPRESA"), rzn_emis = x.Field <string>("RAZON_SOCIAL"), fecha = x.Field <string>("FECHA_RESOLUCION"), giro = x.Field <string>("GIRO"), direccion = x.Field <string>("DIRECCION"), comuna = x.Field <string>("COMUNA"), ciudad = x.Field <string>("CIUDAD") }; string rut_session = s.get_sessionRUT(); string xml_get = serv.get_setDTE(serv.get_empresaRUT(rut_session)); /* DataSet ds = new DataSet(); * ds.ReadXml(XmlReader.Create(new StringReader(xml_get))); */ txt_rut_emisor.Text = empresa_a_usar.FirstOrDefault().rut_emis; txt_rut_envia.Text = rut_session; txt_rzn_emis.Text = empresa_a_usar.FirstOrDefault().rzn_emis; txt_fecha.Text = empresa_a_usar.FirstOrDefault().fecha; txt_giro_emisor.Text = empresa_a_usar.FirstOrDefault().giro; txt_direccion_emisor.Text = empresa_a_usar.FirstOrDefault().direccion; txt_comuna_emisor.Text = empresa_a_usar.FirstOrDefault().comuna; txt_ciudad_emisor.Text = empresa_a_usar.FirstOrDefault().ciudad; }