protected void FunCargarMantenimiento() { try { _dts = new CedenteDAO().FunGetSegmentoCabecera(int.Parse(ViewState["CodigoCEDE"].ToString()), int.Parse(ViewState["CodigoCPCE"].ToString()), 1); GrdvSegmento.DataSource = _dts; GrdvSegmento.DataBind(); ViewState["SegmentoCabecera"] = _dts.Tables[0]; } catch (Exception ex) { Lblerror.Text = ex.ToString(); } }
protected void ImgEliminar_Click(object sender, ImageClickEventArgs e) { try { GridViewRow _gvrow = (GridViewRow)(sender as Control).Parent.Parent; ViewState["Codigo"] = int.Parse(GrdvSegmento.DataKeys[_gvrow.RowIndex].Values["Codigo"].ToString()); _dtbsegmento = (DataTable)ViewState["SegmentoCabecera"]; _result = _dtbsegmento.Select("Codigo='" + ViewState["Codigo"].ToString() + "'").FirstOrDefault(); _result.Delete(); _dtbsegmento.AcceptChanges(); ViewState["SegmentoCabecera"] = _dtbsegmento; GrdvSegmento.DataSource = _dtbsegmento; GrdvSegmento.DataBind(); new CedenteDAO().FunDelSegmento(int.Parse(ViewState["CodigoCEDE"].ToString()), int.Parse(ViewState["CodigoCPCE"].ToString()), int.Parse(ViewState["Codigo"].ToString()), 1); } catch (Exception ex) { Lblerror.Text = ex.ToString(); } }
protected void ImgModi_Click(object sender, ImageClickEventArgs e) { try { if (string.IsNullOrEmpty(TxtEtiqueta.Text.Trim())) { new FuncionesDAO().FunShowJSMessage("Ingrese DescripciĆ³n Etiqueta..!", this); return; } if (string.IsNullOrEmpty(TxtValorInicial.Text.Trim())) { new FuncionesDAO().FunShowJSMessage("Ingrese Porcentaje Inicial..!", this); return; } if (string.IsNullOrEmpty(TxtValorFinal.Text.Trim())) { new FuncionesDAO().FunShowJSMessage("Ingrese Porcentaje Final..!", this); return; } if (int.Parse(TxtValorFinal.Text.Trim()) <= int.Parse(TxtValorInicial.Text.Trim())) { new FuncionesDAO().FunShowJSMessage("Valor Final no puede ser menor o igual al Inicial..!", this); return; } if (string.IsNullOrEmpty(Request.Form[TxtColor.UniqueID])) { new FuncionesDAO().FunShowJSMessage("Ingrese Color de Etiqueta..!", this); return; } if (ViewState["SegmentoCabecera"] != null) { _dtbsegmento = (DataTable)ViewState["SegmentoCabecera"]; _resultado = _dtbsegmento.Select("Codigo<>'" + ViewState["Codigo"].ToString() + "'"); foreach (DataRow _dr in _resultado) { _between = new FuncionesDAO().FunBetween(int.Parse(_dr[3].ToString()), int.Parse(_dr[4].ToString()), int.Parse(TxtValorInicial.Text), int.Parse(TxtValorFinal.Text)); if (_between > 0) { _lexiste = true; break; } } } if (_lexiste) { new FuncionesDAO().FunShowJSMessage("Segmento ya Existe Creado..!", this); return; } _dtbsegmento = (DataTable)ViewState["SegmentoCabecera"]; _result = _dtbsegmento.Select("Codigo='" + ViewState["Codigo"].ToString() + "'").FirstOrDefault(); _result["Segmento"] = "PRESUPUESTO"; _result["Descripcion"] = TxtEtiqueta.Text.Trim().ToUpper(); _result["ValorI"] = TxtValorInicial.Text.Trim(); _result["ValorF"] = TxtValorFinal.Text.Trim(); _result["Estado"] = "Activo"; _result["auxv1"] = Request.Form[TxtColor.UniqueID]; _result["auxv2"] = ""; _result["auxv3"] = ""; _result["auxi1"] = "1"; _result["auxi2"] = "0"; _result["auxi3"] = "0"; _dtbsegmento.AcceptChanges(); _dtbsegmento.DefaultView.Sort = "ValorI"; ViewState["SegmentoCabecera"] = _dtbsegmento; GrdvSegmento.DataSource = _dtbsegmento; GrdvSegmento.DataBind(); TxtEtiqueta.Text = ""; TxtColor.Text = ""; TxtValorInicial.Text = ""; TxtValorFinal.Text = ""; ImgAdd.Enabled = true; ImgModi.Enabled = false; } catch (Exception ex) { Lblerror.Text = ex.ToString(); } }
protected void ImgAdd_Click(object sender, ImageClickEventArgs e) { try { if (string.IsNullOrEmpty(TxtEtiqueta.Text.Trim())) { new FuncionesDAO().FunShowJSMessage("Ingrese Etiqueta..!", this); return; } if (string.IsNullOrEmpty(TxtValorInicial.Text.Trim())) { new FuncionesDAO().FunShowJSMessage("Ingrese Porcentaje Inicial..!", this); return; } if (string.IsNullOrEmpty(TxtValorFinal.Text.Trim())) { new FuncionesDAO().FunShowJSMessage("Ingrese Porcentaje Final..!", this); return; } if (int.Parse(TxtValorFinal.Text.Trim()) <= int.Parse(TxtValorInicial.Text.Trim())) { new FuncionesDAO().FunShowJSMessage("Valor Final no puede ser menor o igual al Inicial..!", this); return; } if (string.IsNullOrEmpty(Request.Form[TxtColor.UniqueID])) { new FuncionesDAO().FunShowJSMessage("Ingrese Color de Etiqueta..!", this); return; } if (ViewState["SegmentoCabecera"] != null) { _dtbsegmento = (DataTable)ViewState["SegmentoCabecera"]; if (_dtbsegmento.Rows.Count > 0) { _maxcodigo = _dtbsegmento.AsEnumerable() .Max(row => int.Parse((string)row["Codigo"])); } else { _maxcodigo = 0; } if (_dtbsegmento.Rows.Count > 0) { foreach (DataRow _dr in _dtbsegmento.Rows) { _between = new FuncionesDAO().FunBetween(int.Parse(_dr[3].ToString()), int.Parse(_dr[4].ToString()), int.Parse(TxtValorInicial.Text), int.Parse(TxtValorFinal.Text)); if (_between > 0) { _lexiste = true; break; } } } } if (_lexiste) { new FuncionesDAO().FunShowJSMessage("Segmento ya Existe Creado..!", this); return; } _dtbsegmento = (DataTable)ViewState["SegmentoCabecera"]; _filagre = _dtbsegmento.NewRow(); _filagre["Codigo"] = _maxcodigo + 1; _filagre["Segmento"] = "PRESUPUESTO"; _filagre["Descripcion"] = TxtEtiqueta.Text.Trim().ToUpper(); _filagre["ValorI"] = TxtValorInicial.Text.Trim(); _filagre["ValorF"] = TxtValorFinal.Text.Trim(); _filagre["Estado"] = "Activo"; _filagre["auxv1"] = Request.Form[TxtColor.UniqueID]; _filagre["auxv2"] = ""; _filagre["auxv3"] = ""; _filagre["auxi1"] = "1"; _filagre["auxi2"] = "0"; _filagre["auxi3"] = "0"; _dtbsegmento.Rows.Add(_filagre); _dtbsegmento.DefaultView.Sort = "ValorI"; ViewState["SegmentoCabecera"] = _dtbsegmento; GrdvSegmento.DataSource = _dtbsegmento; GrdvSegmento.DataBind(); TxtEtiqueta.Text = ""; TxtColor.Text = ""; TxtValorInicial.Text = ""; TxtValorFinal.Text = ""; } catch (Exception ex) { Lblerror.Text = ex.ToString(); } }