protected void gvTypeScaleContinuous_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { // get id scalecontinuous my datakey selected in the gridview int id_scalecontinuous = Convert.ToInt32(gvTypeScaleContinuous.DataKeys[e.NewSelectedIndex].Value); HttpContext.Current.Session["hddIdScaleContinuous"] = id_scalecontinuous.ToString(); hddIdScaleContinuous.Value = id_scalecontinuous.ToString(); TypScaleContinuous scalec = DataAccess.DataAccessTestCase.getScaleContinuous(id_scalecontinuous); tContScaleUpdate.Text = scalec.DescriptionScaleContinuous; tContScaleVerUpdate.Text = scalec.verScaleCont.ToString(); textValue = scalec.DescriptionScaleContinuous; versionValue = scalec.verScaleCont.ToString(); fUpdateContScale.Visible = true; fConfigFooter.Visible = true; DivSuccessConfig.Visible = false; DivErrorConfig.Visible = false; fAdd.Visible = false; HttpContext.Current.Session["tabStatus"] = "cont"; Response.Redirect("~/configFramework/AddTypeUser.aspx#tabs-2"); }
// new type scalecontinuous, eventargs-> nuovo evento se clicco su button protected void btnAddScaleContinuous_Click(object sender, EventArgs e) { // variabile tu della classe TypScaleContinuous TypScaleContinuous tsc = new TypScaleContinuous(); tsc.DescriptionScaleContinuous = txtScaleContinuous.Text; tsc.verScaleCont = Convert.ToInt16(tVerScaleCont.Text); if (fuLoadImageMin.PostedFile != null) { tsc.PathImageMin = Constant.sReferencePath + @"\Continuous\" + tsc.DescriptionScaleContinuous + "\\" + tsc.verScaleCont + "\\Worst\\" + fuLoadImageMin.PostedFile.FileName; saveOnServer(Constant.sReferencePath + @"\Continuous\" + tsc.DescriptionScaleContinuous + "\\" + tsc.verScaleCont + "\\Worst", fuLoadImageMin); } if (fuLoadImageMax.PostedFile != null) { tsc.PathImageMax = Constant.sReferencePath + @"\Continuous\" + tsc.DescriptionScaleContinuous + "\\" + tsc.verScaleCont + "\\Best\\" + fuLoadImageMax.PostedFile.FileName;// fUploadRefImage(fuLoadImageMax.PostedFile.FileName, "maxImg", "Best", "Continuous/" + txtScaleContinuous.Text + "_v" + tVerScaleCont.Text); - Martin saveOnServer(Constant.sReferencePath + @"\Continuous\" + tsc.DescriptionScaleContinuous + "\\" + tsc.verScaleCont + "\\Best", fuLoadImageMax); } DataAccess.DataAccessTestCase.InsertTypeScaleContinuous(tsc); // id non lo inserisco perche è autoincrementante BindGridTypeScaleContinuous(); // refresh gridview txtScaleContinuous.Text = string.Empty; // textbox empty tVerScaleCont.Text = string.Empty; // textbox empty DivInfo.Visible = true; tContScaleVerUpdate.Text = "1"; tContScaleUpdate.Text = ""; }
protected void btnUpdateContScale_Click(object sender, EventArgs e) { TypScaleContinuous tsc = new TypScaleContinuous(); tsc.DescriptionScaleContinuous = tContScaleUpdate.Text; tsc.ID_TypScaleContinuous = Convert.ToInt32(HttpContext.Current.Session["hddIdScaleContinuous"]); tsc.verScaleCont = Convert.ToInt16(tContScaleVerUpdate.Text); TypScaleContinuous scalec = DataAccess.DataAccessTestCase.getScaleContinuous(tsc.ID_TypScaleContinuous); if (!String.IsNullOrEmpty(fuWorstUpdate.FileName)) { if (((scalec.PathImageMin.Split('\\')).Last()) != fuWorstUpdate.FileName) { saveOnServer(Constant.sReferencePath + @"\Continuous\" + tsc.DescriptionScaleContinuous + "\\" + tsc.verScaleCont + "\\Worst", fuWorstUpdate); } tsc.PathImageMin = Constant.sReferencePath + @"\Continuous\" + tsc.DescriptionScaleContinuous + "\\" + tsc.verScaleCont + "\\Worst\\" + fuWorstUpdate.PostedFile.FileName; } else { tsc.PathImageMin = null; } if (!String.IsNullOrEmpty(fuBestUpdate.FileName)) { if (((scalec.PathImageMax.Split('\\')).Last()) != fuBestUpdate.FileName) { saveOnServer(Constant.sReferencePath + @"\Continuous\" + tsc.DescriptionScaleContinuous + "\\" + tsc.verScaleCont + "\\Best", fuBestUpdate); } tsc.PathImageMax = Constant.sReferencePath + @"\Continuous\" + tsc.DescriptionScaleContinuous + "\\" + tsc.verScaleCont + "\\Best\\" + fuBestUpdate.PostedFile.FileName;// fUploadRefImage(fuLoadImageMax.PostedFile.FileName, "maxImg", "Best", "Continuous/" + txtScaleContinuous.Text + "_v" + tVerScaleCont.Text); - Martin } else { tsc.PathImageMax = null; } Result res = DataAccess.DataAccessTestCase.UpdateScaleContinuous(tsc.ID_TypScaleContinuous, tsc.DescriptionScaleContinuous, tsc.verScaleCont, tsc.PathImageMin, tsc.PathImageMax); BindGridTypeScaleContinuous(); if (res.result) { DivSuccessConfig.Visible = true; DivErrorConfig.Visible = false; fUpdateTypeUser.Visible = false; } else { DivSuccessConfig.Visible = false; DivErrorConfig.Visible = true; lblErrorConfig.Text = res.Message; } fUpdateContScale.Visible = false; fAdd.Visible = true; HttpContext.Current.Session["tabStatus"] = "contUpdate"; Response.Redirect("~/configFramework/AddTypeUser.aspx#tabs-2"); }