private void ckChangeMethod_CheckedChanged(object sender, EventArgs e) { paChooseMethod.Visible = ckChangeMethod.Checked; CTemplate_method_aaFactory faTemplate_method_aa = new CTemplate_method_aaFactory(); object obj = gvMethods.GetFocusedRowCellValue(gcMet_Idtemplate_method); if (obj != null) { if (gvMethods.RowCount > 0) ShowColumnsByTypeAnalysis(Comun.GetTypeAnalysis(Convert.ToChar(gvMethods.GetFocusedRowCellValue(gcMet_Type_analisys)))); } }
private void gvMethods_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) { // --- get type method ShowColumnsByTypeAnalysis(Comun.GetTypeAnalysis(Convert.ToChar(gvMethods.GetFocusedRowCellValue(gcMet_Type_analisys)))); }
bool SaveAA() { try { string Cod_method = gluCod_method.Text; string Title = tbTitle.Text; string messageOk = ""; Methods oMethods = new Methods(); Comun.MethodSaveProperty InspectionChanges = RequireNewVersionOrMethod(Comun.GetTypeAnalysis(Convert.ToChar(cbTypeAnalysis.EditValue))); if (InspectionChanges == Comun.MethodSaveProperty.NewMethod) { Num_version = 1; messageOk = "Se guardó un nuevo método con código " + Cod_method + "\ncon título " + Title; } if (InspectionChanges == Comun.MethodSaveProperty.InspectionNewVersion) { // --- save as new version or overwrite FormConfirmSaveMethod fmConfirmSaveMethod = new FormConfirmSaveMethod(true); if (fmConfirmSaveMethod.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (fmConfirmSaveMethod.SaveType == Comun.Save_type.SaveAs) { FormMethodSaveAs fmMethodSaveAs = new FormMethodSaveAs(); fmMethodSaveAs.ListTemplate = oMethods.GetAllLastVersionMethods( Convert.ToInt32(cbElement.EditValue), cbTypeSample.EditValue.ToString(), Convert.ToChar(cbTypeAnalysis.EditValue)); if (fmMethodSaveAs.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Num_version = 1; IDTemplate_Method = 0; Cod_method = fmMethodSaveAs.Cod_method; Title = fmMethodSaveAs.Title; messageOk = "Se guardó un nuevo método con código " + fmMethodSaveAs.Cod_method + "\n con título '" + fmMethodSaveAs.Title + "'"; } else { return(false); } } if (fmConfirmSaveMethod.SaveType == Comun.Save_type.Save) { Num_version = oMethods.GetNumNewVersion(IDTemplate_Method); IDTemplate_Method = 0; messageOk = "Se guardó una nueva versión [" + Num_version.ToString() + "] del método " + Cod_method; } } else { return(false); } } if (InspectionChanges == Comun.MethodSaveProperty.InspectionNewMethod) { FormMethodSaveAs fmMethodSaveAs = new FormMethodSaveAs(); fmMethodSaveAs.ListTemplate = oMethods.GetAllLastVersionMethods( Convert.ToInt32(cbElement.EditValue), cbTypeSample.EditValue.ToString(), Convert.ToChar(cbTypeAnalysis.EditValue)); if (fmMethodSaveAs.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Num_version = 1; IDTemplate_Method = 0; Cod_method = fmMethodSaveAs.Cod_method; Title = fmMethodSaveAs.Title; messageOk = "Se guardó un nuevo método con código " + fmMethodSaveAs.Cod_method + "\n con título " + fmMethodSaveAs.Title; } else { return(false); } } if (InspectionChanges == Comun.MethodSaveProperty.Nothing) { messageOk = "Se guardó correctamente"; } // --- save head CTemplate_methodFactory faTemplate_Method = new CTemplate_methodFactory(); CTemplate_method oTemplate_Method = new CTemplate_method(); oTemplate_Method.Idtemplate_method = IDTemplate_Method; oTemplate_Method.Num_version = Num_version; oTemplate_Method.Idelement = Convert.ToInt32(cbElement.EditValue); oTemplate_Method.Cod_template_method = Cod_method; oTemplate_Method.Title = Title; oTemplate_Method.Cod_digestion_method = cbDigestion.EditValue.ToString(); oTemplate_Method.Cod_repetition = Convert.ToInt16(cbRepetition.EditValue); oTemplate_Method.Abbreviation = tbAbreviation.Text; oTemplate_Method.Recognized = ckRecognized.Checked; oTemplate_Method.Cod_type_sample = cbTypeSample.EditValue.ToString(); oTemplate_Method.Cost_method = tbCost_Method.Value; oTemplate_Method.Type_analisys = Convert.ToChar(cbTypeAnalysis.EditValue); oTemplate_Method.Status = true; if (IDTemplate_Method == 0) { oTemplate_Method.Usernew = Comun.GetUser(); oTemplate_Method.Datenew = Comun.GetDate(); oTemplate_Method.Useredit = Comun.GetUser(); oTemplate_Method.Dateedit = Comun.GetDate(); } else { oTemplate_Method.Useredit = Comun.GetUser(); oTemplate_Method.Dateedit = Comun.GetDate(); } bool result_template_method = false; if (!(result_template_method = faTemplate_Method.Update(oTemplate_Method))) { result_template_method = faTemplate_Method.Insert(oTemplate_Method); } if (result_template_method) { IDTemplate_Method = oTemplate_Method.Idtemplate_method; SaveTypeAnalysis(); } FormResult fmResult = new FormResult(); fmResult.Message = messageOk; fmResult.ShowDialog(); gluCod_method.Text = Cod_method; return(true); } catch (Exception ex) { ComunForm.Send_message(this.Text, TypeMsg.error, ex.Message); return(false); } }