using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Office.Interop.Excel; // zusätzlich ist der Projektverweis auf COM -> Microsoft Excel xx-Objectlibrary
using NXOpen;
using NXOpen.UF;
namespace UpdateStandPartFamMemUsStat
{
public partial class Form1 : Form
{
#region Version und Copyright
// Version und Copyright
string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen
string programVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
string copyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
string icon = System.Windows.Forms.Application.StartupPath + "\\Info.bmp";
//Assembly Datum und Zeit
static DateTime value = AssemblyDateTime();
string date = value.ToShortDateString();
string time = value.ToLongTimeString();
private static DateTime AssemblyDateTime()
{
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision));
//Tage seit dem 1. Januar 2000 und Sekunden seit Mitternacht, (multiplizier mit 2 ergibt das Original)
return buildDateTime;
}
#endregion
#region Programm-Info
///
/// Contains the name of the program file
///
public static string ProgramName { set; get; }
///
/// Contains the version of the program file
///
public static string ProgramVersion { set; get; }
///
/// Contains the copyright notice
///
public static string Copyright { set; get; }
private void SetProgramInfo()
{
//Name, Version und Copyright setzen
ProgramName = programName;
ProgramVersion = programVersion;
Copyright = copyright;
}
#endregion
//Spalten Namen
const string colObject = "Objekt";
const string colVStatus = "VStat";
const string colItemNumber = "ItemNumber";
const string colStatus = "Status";
//int colomnStatus = 0;
int oRangeSap;
//int oRangeReuse;
//string fileNameReuse = "";
public static List SapObject { set; get; }
public static List SapVStat { set; get; }
public static List PfItem { set; get; }
public static List PfStatusOld { set; get; }
public static List PfStatusNew { set; get; }
////oExcelApp benötigt den kompletten Namensraum, da andernfalls der Compiler den Unterschied zwischen
////"Microsoft.Office.Interop.Excel.Application" und "System.Windows.Forms.Application" nicht erkennen kann
//private Microsoft.Office.Interop.Excel.Application oExcelApp = new Microsoft.Office.Interop.Excel.Application();
//private Workbook oWorkbook = null;
//private Worksheet oWorksheet = null;
public Form1()
{
SetProgramInfo(); //Name, Version und Copyright setzen
InitializeComponent();
Session theSession = Session.GetSession();
Part dispPart = theSession.Parts.Display;
Part workPart = theSession.Parts.Work;
UFSession theUFSession = UFSession.GetUFSession();
lw = theSession.ListingWindow;
}
private void Form1_Load(object sender, EventArgs e)
{
this.MaximumSize = new Size(808, Screen.PrimaryScreen.Bounds.Height - 30); //Um 30 kleiner, weil sonst der untere Rand hinter der Start-Leiste verschwindet
this.Text = String.Concat("::::: ", ProgramName, " ::::: -- V", ProgramVersion, " - ", Copyright.Replace("Copyright ", ""), " --");
lwWriteLine("Selection Window opened.");
}
private void buttonReadSapColumn_Click(object sender, EventArgs e)
{
buttonReadSapColumn.Enabled = false;
if (!ReadSapColumns())
{
buttonReadSapColumn.Enabled = true;
return;
}
buttonReadSapColumn.Enabled = false;
ReadReuseColumns();
buttonSaveChanges.Enabled = true;
}
private void buttonSaveChanges_Click(object sender, EventArgs e)
{
List