SourceCode/PROMS/VEPROMS User Interface/frmAnnotationsCleanup.cs

169 lines
4.8 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using VEPROMS.CSLA.Library;
using Volian.Base.Library;
//using Volian.Pipe.Library;
using System.Xml;
using System.Diagnostics;
using JR.Utils.GUI.Forms;
namespace VEPROMS
{
public partial class frmAnnotationsCleanup : Form
{
Label mylab = new Label();
string procList = "";
string docvList = "";
int AnnotationTyp;
List<ProcedureInfo> pil2 = new List<ProcedureInfo>();
List<DocVersionInfo> dvil2 = new List<DocVersionInfo>();
private frmBatchRefresh mainForm = null;
public frmAnnotationsCleanup(Form callingForm, List<ProcedureInfo> pil, List<DocVersionInfo> dvil)
{
mainForm = callingForm as frmBatchRefresh;
InitializeComponent();
pil2 = pil;
dvil2 = dvil;
myAnnotationTypeInfoList = AnnotationTypeInfoList.Get();
lbAnnotationTypes.DataSource = myLocalAnnotationTypeInfoList = new LocalAnnotationTypeInfoList(myAnnotationTypeInfoList);
Dictionary<string, string> AnnotationsList = new Dictionary<string, string>();
foreach (LocalAnnotationTypeInfo lati in myLocalAnnotationTypeInfoList)
{
AnnotationsList.Add(lati.TypeID.ToString(), lati.Name);
//cbAnnotationTypes.Items.Add(new { Name = lati.Name, Value = lati.TypeID });
}
//cbAnnotationTypes.DroppedDown = true; //DroppedDown
lbAnnotationTypes.DataSource = new BindingSource(AnnotationsList, null);
lbAnnotationTypes.DisplayMember = "Value";
lbAnnotationTypes.ValueMember = "Key";
lbAnnotationTypes.SelectedIndexChanged += lbAnnotationTypes_SelectedIndexChanged;
//List<ProcedureInfo> SelectedProds = new List<ProcedureInfo>();
//SelectedProds = frmBatchRefresh.RetrieveChkAnnotations();
}
private string getAnnotationProcItems(List<ProcedureInfo> pil2)
{
procList = "";
foreach (var p in pil2)
{
if (p.IsProcedure)
{
if (procList == "")
{
procList = procList + p.ItemID.ToString();
}
else
{
procList = procList + "," + p.ItemID.ToString();
}
}
}
return procList;
//for( int i = 0; pil2.Count ; i++ )
}
private string getAnnotationDocvItems(List<DocVersionInfo> dvil2)
{
docvList = "";
foreach (var d in dvil2)
{
if (d.IsDocVersion)
{
if (docvList == "")
{
docvList = docvList + d.VersionID.ToString();
}
else
{
docvList = docvList + "," + d.VersionID.ToString();
}
}
}
return docvList;
//for( int i = 0; pil2.Count ; i++ )
}
private AnnotationTypeInfoList myAnnotationTypeInfoList = null;
private LocalAnnotationTypeInfoList myLocalAnnotationTypeInfoList = null;
private void button1_Click(object sender, EventArgs e)
{
foreach (var p in pil2)
{
if (p.IsProcedure)
{
TextBox frm2 = mainForm.GettxtProcess();
frm2.AppendText(p.DisplayNumber + ' ' + p.DisplayText);
AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
Annotation.DeleteAnnotationProcByType(AnnotationTyp, p.ItemID.ToString());
lblCountNumber.Text = "0";
}
}
foreach (var d in dvil2)
{
if (d.IsDocVersion)
{
TextBox frm2 = mainForm.GettxtProcess();
frm2.AppendText(d.ActiveParent.ToString());
AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
Annotation.DeleteAnnotationDocvByType(AnnotationTyp, d.VersionID.ToString());
lblCountNumber.Text = "0";
}
}
}
//private void cbAnnotationTypes_SelectedIndexChanged(object sender, EventArgs e)
//{
// mylab.Text = mylab.Text + ((KeyValuePair<string, string>)cbAnnotationTypes.SelectedItem).Key;
//}
private void lbAnnotationTypes_SelectedIndexChanged(object sender, EventArgs e)
{
int deletecountProc = 0;
int deletecountDocv = 0;
if (pil2.Count > 0)
{
AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
deletecountProc = Annotation.getAnnotationProcCnt(AnnotationTyp, getAnnotationProcItems(pil2));
}
if (dvil2.Count > 0)
{
AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
deletecountDocv = Annotation.getAnnotationCountDocv(AnnotationTyp, getAnnotationDocvItems(dvil2));
}
lblCountNumber.Text = (deletecountProc + deletecountDocv).ToString();
}
//private void cbAnnotationTypes_(object sender, EventArgs e)
//{
// //mylab.Text = mylab.Text + cbAnnotationTypes.SelectedValue;
// //mylab.Text = mylab.Text + cbAnnotationTypes.SelectedItem.ToString();
// //mylab.Text = mylab.Text + ((KeyValuePair<string, string>)cbAnnotationTypes.SelectedItem).Value;
//}
}
}