protected void BtnEditImage_Click(object sender, EventArgs e) { string folio = DateTime.Now.ToLongTimeString().Replace(":", ""); string path = Path.Combine(Server.MapPath("~/Images/COT_COMPONENTES/")); if (!string.IsNullOrEmpty(FileUpFoto.FileName.ToString())) { string fileName = folio + FileUpFoto.FileName.ToString(); string path_foto = "http://" + HttpContext.Current.Request.Url.Authority + "/Images/COT_COMPONENTES/" + fileName; path = path + fileName; FileUpFoto.SaveAs(path); //hacer un update a la tabla con la foto ComponentesClass cOMPO = new ComponentesClass(); bool Isinserted = cOMPO.UpdateComponente(HdnIdComp.Value, COT_MCOMPONENTES.Campos.IMG_PATH(), path_foto); if (!Isinserted) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script> $(document).ready(alert('Error al intentar Actualizar la información, intentelo nuevamente.'));</script>", false); } else { Response.Redirect("~/View/Comercial/AdmVentas/Productos/EdicionComponente.aspx?ID=" + HdnIdComp.Value + "&TOKEN=" + TOKEN); } } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script> $(document).ready(alert('No se seleccionó ningún archivo.'));</script>", false); } }
protected void Btnmodalprecio_Click(object sender, EventArgs e) { double number; double cantidad; bool Isupdateprecio = false; bool IsUpdateUnMed = false; bool IsUpdateCant = false; string ErrorA = ""; string ErrorB = ""; string ErrorC = ""; ComponentesClass Comp = new ComponentesClass(); if (Double.TryParse(TxtPrecio.Text, out number)) { Isupdateprecio = Comp.UpdateComponente(HdnIdComp.Value, COT_MCOMPONENTES.Campos.PRECIO_UNIT(), number); } else { ErrorB = " Formato de precio no es correcto "; } if (Double.TryParse(TxtCant.Text, out cantidad)) { IsUpdateCant = Comp.UpdateComponente(HdnIdComp.Value, COT_MCOMPONENTES.Campos.CANT_UNIT(), cantidad); } else { ErrorA = " Formato de cantidad no es correcto "; } IsUpdateUnMed = Comp.UpdateComponente(HdnIdComp.Value, COT_MCOMPONENTES.Campos.ID_MAGMED(), DDLUnidadmed.SelectedValue); if (!IsUpdateCant) { ErrorA = " Error en la cantidad "; } if (!Isupdateprecio) { ErrorB = " Error en el precio "; } if (!IsUpdateUnMed) { ErrorC = " Error en la unidad de medida "; } if (IsUpdateCant && Isupdateprecio && IsUpdateUnMed) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myalert", "alert('La actualización ha sido exitosa.'); window.location='" + Page.ResolveUrl("~/View/Comercial/AdmVentas/Productos/EdicionComponente.aspx?ID=" + HdnIdComp.Value + "&TOKEN=" + TOKEN) + "';", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script> $(document).ready(alert('Hubo un error al intentar actualizar , intentelo de nuevo. Errores " + ErrorA + ErrorB + ErrorC + "'));</script>", false); } }
protected void LinkSelectCompo_Click(object sender, EventArgs e) { string ID = ((LinkButton)sender).CssClass; ComponentesClass CsC = new ComponentesClass(ID, true); if (!string.IsNullOrEmpty(CsC._Detalle._ID)) { PnlCompoSelected.Visible = true; GrdCompo.Visible = false; TxtSearchCompo.Visible = false; BtnSearchCompo.Visible = false; LblResCodCompo.Text = CsC._Detalle.Nombre; HdnIdSelectedCompo.Value = CsC._Detalle._ID; LblCostoCompo.Text = CsC._Detalle.PrecioUn.ToString("C0", CultureInfo.CurrentCulture) + "/" + CsC._Detalle.UnMedSimbolo; if (CsC._Detalle.Path_Photo.Length > 1) { HtmlGenericControl img = new HtmlGenericControl("img"); img.Attributes.Add("class", "img-thumbnail rounded mx-auto d-block "); img.Attributes.Add("alt", "Responsive image"); img.Attributes.Add("src", CsC._Detalle.Path_Photo); PnlCompoDivImage.Controls.Add(img); } Encriptacion token = new Encriptacion(CsC._Detalle.TokeId); HtmlGenericControl a = new HtmlGenericControl("a"); a.Attributes.Add("href", "http://" + HttpContext.Current.Request.Url.Authority + "/View/Comercial/AdmVentas/Productos/EdicionComponente.aspx?ID=" + ID + "&TOKEN=" + token.TokenEncriptado); a.Attributes.Add("target", "_blank"); a.Attributes.Add("rel", "noopener noreferrer"); a.InnerHtml = "Ver más detalles"; PnlCompoSelDivHasProc.Controls.Add(a); if (CsC._Detalle.HasProc) { LblHasProcCompo.Text = "Este componente tiene procesos asociados."; LblHasProcCompo.Font.Bold = true; } HtmlGenericControl i = new HtmlGenericControl("a"); HtmlGenericControl span = new HtmlGenericControl("label"); HtmlGenericControl label = new HtmlGenericControl("label"); if (CsC._Detalle.UnMedSimbolo == "Un") { i.Attributes.Add("data-content", "Ingresar números enteros"); } label.InnerHtml = "Rendimiento o Ecuación de cálculo: "; span.InnerHtml = CsC._Detalle.UnidadMedida + " por pieza \"" + DDLFirstDivCompo.SelectedItem + "\""; span.Attributes.Add("class", "h6"); DivPreInfoFormula.Controls.Add(label); DivInfoFormula.Controls.Add(span); } }
protected void BtnDelete_Click(object sender, EventArgs e) { ComponentesClass Comp = new ComponentesClass(); bool IsDelete = Comp.UpdateComponente(HdnIDItem.Value, COT_MCOMPONENTES.Campos.ESTADO(), false); if (IsDelete) { Response.Redirect("~/View/Comercial/AdmVentas/Productos/AdministracionComponentes.aspx"); } }
protected void LinkBtnDescripcion_Click(object sender, EventArgs e) { if (TxtDescripcion.Enabled) { TxtDescripcion.Enabled = false; LinkBtnDescripcion.Text = "Editar"; //hacer un update a la tabla con la descripcion ComponentesClass cOMPO = new ComponentesClass(); bool Isinserted = cOMPO.UpdateComponente(HdnIdComp.Value, COT_MCOMPONENTES.Campos.DESCRIPCION(), TxtDescripcion.Text); if (!Isinserted) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script> $(document).ready(alert('Error al intentar Actualizar la información, intentelo nuevamente.'));</script>", false); } } else { TxtDescripcion.Enabled = true; LinkBtnDescripcion.Text = "Actualizar"; } }
protected void LinkSelectAlfak_Click(object sender, EventArgs e) { ComponentesClass cOMPO = new ComponentesClass(); string _CodigoAlfak = ((LinkButton)sender).Text; string WGR = DDLSubTipoProcAsocAlfak.SelectedValue; bool IsEdited = cOMPO.UpdateComponente(HdnIdbeforeCreate.Value, COT_MCOMPONENTES.Campos.COD_ALFAK(), _CodigoAlfak); bool IsEdited2 = cOMPO.UpdateComponente(HdnIdbeforeCreate.Value, COT_MCOMPONENTES.Campos.KA_WGR(), WGR); if (WGR.Contains("B") || WGR.Contains("C") || WGR.Contains("D")) { cOMPO.UpdateComponente(HdnIdbeforeCreate.Value, "IsGlass", true); } if (IsEdited) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myalert", "alert('El componente ha sido vinculado con el código " + _CodigoAlfak + " de Alfak'); window.location='" + Page.ResolveUrl("~/View/Comercial/AdmVentas/Productos/EdicionComponente.aspx?ID=" + HdnIdbeforeCreate.Value + "&TOKEN=" + TOKEN) + "';", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myalert", "alert('Se produjo un error al tratar de vincular el proceso con Alfak, por favor intentelo nuevamente.');", true); } }
protected void BtnCrearComp_Click(object sender, EventArgs e) { string folio = DateTime.Now.ToLongTimeString().Replace(":", ""); string path = Path.Combine(Server.MapPath("~/Images/COT_COMPONENTES/")); string fileName = folio + FileUpFoto.FileName.ToString(); string path_foto = "http://" + HttpContext.Current.Request.Url.Authority + "/Images/COT_COMPONENTES/" + fileName; path = path + fileName; FileUpFoto.SaveAs(path); Random random = new Random(); int TokenId = random.Next(10000, 9999999); ComponentesClass Componente = new ComponentesClass(); bool Isinsert = Componente.InsertinTabla(TxtNombreComp.Text, TxtDescripcion.Text, path_foto, TokenId); if (Isinsert) { Encriptacion encriptacion = new Encriptacion(TokenId.ToString()); Response.Redirect("~/View/Comercial/AdmVentas/Productos/EdicionComponente.aspx?ID=" + Componente.IdReturnedInsert + "&TOKEN=" + encriptacion.TokenEncriptado); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script> $(document).ready(alert('Error al intentar crear el componente, intentelo nuevamente.'));</script>", false); } }
protected void Page_Load(object sender, EventArgs e) { string ID = Request.QueryString["ID"]; TOKEN = Request.QueryString["TOKEN"]; if (!IsPostBack) { if (!string.IsNullOrEmpty(ID) && !string.IsNullOrEmpty(TOKEN)) { ComponentesClass CsC = new ComponentesClass(); bool IsComponente = CsC.IsComponente(ID, TOKEN); HdnIdComp.Value = ID; if (IsComponente) { Imagen.ImageUrl = CsC._Detalle.Path_Photo; TxtNombre.Text = CsC._Detalle.Nombre; LblCreateDate.Text = CsC._Detalle.F_Creacion.ToLongDateString(); LblEditDate.Text = CsC._Detalle.F_Actualizacion.ToLongDateString(); TxtDescripcion.Text = CsC._Detalle.Descripcion; FillDDLMagnitud(); FamiliasAlfak alfak = new FamiliasAlfak(); List <FamiliasAlfak.Familia> familias = alfak.familias; FamiliasAlfak.Familia Item1 = new FamiliasAlfak.Familia { ID = "VI", Name = "VIDRIOS" }; familias.Add(Item1); FillDDL(DDLTipoProcAsocAlfak, "Name", "ID", "Seleccionar Tipo", familias); if (string.IsNullOrEmpty(CsC._Detalle.COD_ALFAK)) { LblEditAsocAlfak.Text = "El componente no tiene asociado ningún código en Alfak"; LinkTomdlAsocAlfak.InnerHtml = "Asociar"; TitleMdlAsocAlfak1.InnerHtml = "Asociar Código Alfak"; } else { ProductoAlfak alfakP = new ProductoAlfak(); ProductoAlfak.BA_PRODUKTE producto = alfakP.GetByCod(CsC._Detalle.COD_ALFAK); LblEditAsocAlfak.Text = "El componente tiene asociado el código Alfak \"" + producto.CodigoAlfak + "\" - " + producto.Descripcion; lblFamilyAlfak.Text = "Familia Alfak " + producto.Familia_Alfak; LinkTomdlAsocAlfak.InnerHtml = "Editar"; TitleMdlAsocAlfak1.InnerHtml = "Editar Código Alfak"; } //habilita el textbox si es que no tiene precio if (CsC._Detalle.PrecioUn == 0) { } //habilita el textbox para actualizar la cantidad del componente if (CsC._Detalle.CantEmb == 0) { } //verifica si tiene precio if (CsC._Detalle.PrecioUn == 0) { BtnEditPrecio.InnerHtml = "Ingresar"; LblPrecioydim.Text = "Debe ingresar precio y dimensión."; } else { BtnEditPrecio.InnerHtml = "Editar"; GetMagnitudes Mag = new GetMagnitudes(); LblPrecioydim.Text = "Precio por " + CsC._Detalle.UnMedSimbolo + " : " + CsC._Detalle.PrecioUn.ToString("C0", CultureInfo.CurrentCulture); LblCantEmb.Text = CsC._Detalle.CantEmb + " " + CsC._Detalle.UnidadMedida + " por unidad de entrega."; TxtPrecio.Text = CsC._Detalle.PrecioUn.ToString(); TxtCant.Text = CsC._Detalle.CantEmb.ToString(); DDLmagnitud.SelectedValue = CsC._Detalle.Magnitud; DDLUnidadmed.Visible = true; GetMagnitudes Mag2 = new GetMagnitudes(CsC._Detalle.Magnitud); FillDDLUnidadmed(Mag2.AllMagnitudes); DDLUnidadmed.SelectedValue = CsC._Detalle.ID_Magnitud; LblPrecioX.Visible = true; LblCantX.Visible = true; TxtCant.Visible = true; TxtPrecio.Visible = true; LblCant2.Visible = true; LblCantX.Text = CsC._Detalle.UnidadMedida + " por unidad de entrega:"; LblMedida1.Visible = true; LblSimbolUn.Visible = true; LblPrecioX.Text = "Precio por " + CsC._Detalle.UnMedSimbolo + ":"; } //verifica si tiene procesos asociados ProcesosClass.GetProcNoAsign procesos = new ProcesosClass.GetProcNoAsign(ID, true); FillDDlProcesos(procesos.Procesos); if (!CsC._Detalle.HasProc) { LblProcesos.Text = "No tiene procesos asociados"; LblMdltitleProc.Text = "Agregar Procesos"; } else { LblMdltitleProc.Text = "Agregar Procesos"; LblProcesos.Visible = false; ProcesosClass.GetProcAsign procAsign = new ProcesosClass.GetProcAsign(ID, true); FillingTable(procAsign.Procesos); } } else { Response.Redirect(Error404.Redireccion(MasterPageFile, "El componente no fue encontrado")); } } else { Response.Redirect(Error404.Redireccion(MasterPageFile, "Hubo un error al tratar de buscar el componente, intentelo nuevamente")); } } }
protected void BtnAddPieces_Click(object sender, EventArgs e) { BomModel model = new BomModel(); bool IsInserted = false; BomModel.Bom bom; if (DDLFirstPieceOrComp.SelectedIndex == 1) { double ancho; double largo; string error; if (double.TryParse(TxtMdlAPAnchoPiece.Text, out ancho)) { if (double.TryParse(TxtMdlAPLargoPiece.Text, out largo)) { bom = new BomModel.Bom { NOMBRE = TxtMdlAPNamePiece.Text, ANCHO = ancho, LARGO = largo, ALFAK_CODE = TxtSelectedAlfakCode.Text, CANT_PRED = 0, COSTO = 0, NODE = model.GetPos_Nr(HdnIdModel.Value, true, "1"), ID_MODEL = HdnIdModel.Value, LEVEL = "1", FROM_TAB = "", ID_FROM_TAB = "0", ESTADO = true, POS_NR = model.GetPos_Nr(HdnIdModel.Value, true, "1"), FORMULA = "", }; IsInserted = model.InsertBom(bom); } else { error = "Formato de Alto incorrecto"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myalert", "alert('Se produjo un error de formato: " + error + "'); window.location='" + Page.ResolveUrl("~/View/Comercial/AdmVentas/Productos/EdicionModelos.aspx?ID=" + HdnIdModel.Value + "&TOKEN=" + TOKEN) + "';", true); } } else { error = " Formato de Ancho incorrecto"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myalert", "alert('Se produjo un error de formato: " + error + "'); window.location='" + Page.ResolveUrl("~/View/Comercial/AdmVentas/Productos/EdicionModelos.aspx?ID=" + HdnIdModel.Value + "&TOKEN=" + TOKEN) + "';", true); } } else if (DDLFirstPieceOrComp.SelectedIndex == 2) { ComponentesClass Item = new ComponentesClass(HdnIdSelectedCompo.Value, true); int IDItemBom = Convert.ToInt32(DDLFirstDivCompo.SelectedValue); BomModel ItemBom = new BomModel(IDItemBom, true); bom = new BomModel.Bom { NOMBRE = Item._Detalle.Nombre, ALFAK_CODE = Item._Detalle.COD_ALFAK, ANCHO = 0, LARGO = 0, FORMULA = TxtFormulaCompo.Text, CANT_PRED = 0, ESTADO = true, COSTO = Item._Detalle.PrecioUn, FROM_TAB = "COT_MCOMPONENTES", ID_FROM_TAB = Item._Detalle._ID, ID_MODEL = HdnIdModel.Value, LEVEL = "2", NODE = ItemBom.ItemBom.POS_NR, POS_NR = ItemBom.GetPos_Nr(HdnIdModel.Value, true, "2", ItemBom.ItemBom.POS_NR), OPCIONAL = ChkIsOpcional.Checked, }; IsInserted = model.InsertBom(bom); } else if (DDLFirstPieceOrComp.SelectedIndex == 3) { ProcesosClass ProcClass = new ProcesosClass(); ProcesosClass._Proceso proceso = ProcClass.GetProceso(DDLTipoProcAsocAlfak.SelectedValue, true); int IDItemBom = Convert.ToInt32(DDLFirstDivCompo2.SelectedValue); BomModel ItemBom = new BomModel(IDItemBom, true); bom = new BomModel.Bom { NOMBRE = proceso.Nombre, ALFAK_CODE = proceso._CodAlfak, ANCHO = 0, LARGO = 0, FORMULA = TxtPnlProcSelectedFormula.Text, CANT_PRED = 0, ESTADO = true, COSTO = proceso.Costo_Unit, FROM_TAB = "COT_MPROCESOS", ID_FROM_TAB = proceso._ID, ID_MODEL = HdnIdModel.Value, LEVEL = "2", NODE = ItemBom.ItemBom.POS_NR, POS_NR = ItemBom.GetPos_Nr(HdnIdModel.Value, true, "2", ItemBom.ItemBom.POS_NR), OPCIONAL = ChkOpcionalProc.Checked, }; IsInserted = model.InsertBom(bom); } else { bom = new BomModel.Bom(); } if (IsInserted) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myalert", "alert('Asignación Completa.'); window.location='" + Page.ResolveUrl("~/View/Comercial/AdmVentas/Productos/EdicionModelos.aspx?ID=" + HdnIdModel.Value + "&TOKEN=" + TOKEN) + "';", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myalert", "alert('Se produjo un error en la asignación, por favor intentelo nuevamente.'); window.location='" + Page.ResolveUrl("~/View/Comercial/AdmVentas/Productos/EdicionModelos.aspx?ID=" + HdnIdModel.Value + "&TOKEN=" + TOKEN) + "';", true); } }