update 20241201
This commit is contained in:
327
Client - Kopie/Diverses/MitarbeiterProfil.cs
Normal file
327
Client - Kopie/Diverses/MitarbeiterProfil.cs
Normal file
@@ -0,0 +1,327 @@
|
||||
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 Syncfusion.WinForms.Controls.Styles;
|
||||
using Syncfusion.Windows.Forms.Tools;
|
||||
using Syncfusion.WinForms.Controls;
|
||||
using Syncfusion.WinForms.DataGrid;
|
||||
using Syncfusion.WinForms.DataGrid.Interactivity;
|
||||
using OnDoc.Klassen;
|
||||
using System.Data.SqlClient;
|
||||
using Database;
|
||||
using System.Threading;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
|
||||
namespace OnDoc.Diverses
|
||||
{
|
||||
public partial class MitarbeiterProfil : SfForm
|
||||
{
|
||||
private int mitarbeiternr = 0;
|
||||
private bool onLoad = true;
|
||||
public MitarbeiterProfil()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public MitarbeiterProfil(int Mitarbeiternr)
|
||||
{
|
||||
InitializeComponent();
|
||||
mitarbeiternr = Mitarbeiternr;
|
||||
}
|
||||
|
||||
private void MitarbeiterProfil_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
refresh_profile();
|
||||
ribbonTab1_ActiveChanged(sender, e);
|
||||
refresh_unterschriften_team();
|
||||
onLoad = false;
|
||||
lbprofile.SelectedIndex = 0;
|
||||
|
||||
}
|
||||
|
||||
private void refresh_profile()
|
||||
{
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
db.Get_Tabledata("Select * from profil where aktiv=1 and mitarbeiternr=" + mitarbeiternr.ToString(), false, true);
|
||||
lbprofile.DataSource = db.dsdaten.Tables[0];
|
||||
lbprofile.DisplayMember = "Bezeichnung";
|
||||
lbprofile.ValueMember = "profilnr";
|
||||
db = null;
|
||||
}
|
||||
|
||||
private void refresh_unterschriften_team()
|
||||
{
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
db.clear_parameter();
|
||||
db.Get_Tabledata("SP_Dokumentbearbeitung_Mitarbeiter", true, false);
|
||||
cbboxUnterschriftLinks.DataSource = db.dsdaten.Tables[0];
|
||||
cbboxUnterschriftLinks.DisplayMember = "name";
|
||||
cbboxUnterschriftLinks.ValueMember = "mitarbeiternr";
|
||||
cbboxUnterschriftRechts.DataSource = db.dsdaten.Tables[0];
|
||||
cbboxUnterschriftRechts.DisplayMember = "name";
|
||||
cbboxUnterschriftRechts.ValueMember = "mitarbeiternr";
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@profilnr", 0.ToString());
|
||||
db.add_parameter("@mitarbeiternr", mitarbeiternr.ToString());
|
||||
db.Get_Tabledata("sp_dokumentbearbeitung_team", true, false);
|
||||
cbboxTeam.DataSource = null;
|
||||
cbboxTeam.DataSource = db.dsdaten.Tables[0];
|
||||
cbboxTeam.ValueMember = "teamnr";
|
||||
cbboxTeam.DisplayMember = "bezeichnung";
|
||||
db = null;
|
||||
}
|
||||
private void RibbonButtonExit_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void lbprofile_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (onLoad) { return; }
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
db.Get_Tabledata("Select * from profil where profilnr=" + lbprofile.SelectedValue, false, true);
|
||||
cbboxUnterschriftLinks.SelectedValue = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["Unterschriftlinks"].ToString());
|
||||
cbboxUnterschriftRechts.SelectedValue = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["Unterschriftrechts"].ToString());
|
||||
cbboxTeam.SelectedValue = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["team"].ToString());
|
||||
cbStandard.Checked = db.dsdaten.Tables[0].Rows[0]["standard"].ToString() == "True";
|
||||
txtbezeichnung.Text = db.dsdaten.Tables[0].Rows[0]["bezeichnung"].ToString();
|
||||
db = null;
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
if (cbStandard.Checked)
|
||||
{
|
||||
db.Exec_SQL("Update profil set standard=0 where mitarbeiternr=" + mitarbeiternr.ToString());
|
||||
db.Exec_SQL("Update profil set bezeichnung='" + txtbezeichnung.Text + "', unterschriftlinks=" + cbboxUnterschriftLinks.SelectedValue.ToString() + ", unterschriftrechts=" + cbboxUnterschriftRechts.SelectedValue.ToString() + ", team=" + cbboxTeam.SelectedValue.ToString() + " ,standard=1 where profilnr=" + lbprofile.SelectedValue.ToString());
|
||||
}
|
||||
db.Exec_SQL("Update profil set bezeichnung='" + txtbezeichnung.Text + "',unterschriftlinks=" + cbboxUnterschriftLinks.SelectedValue.ToString() + ", unterschriftrechts=" + cbboxUnterschriftRechts.SelectedValue.ToString() + ", team=" + cbboxTeam.SelectedValue.ToString() + " where profilnr=" + lbprofile.SelectedValue.ToString());
|
||||
db = null;
|
||||
|
||||
}
|
||||
|
||||
private void ribbonButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
int saveselected = Convert.ToInt32(lbprofile.SelectedValue);
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
if (cbStandard.Checked)
|
||||
{
|
||||
db.Exec_SQL("Update profil set standard=0 where mitarbeiternr=" + mitarbeiternr.ToString());
|
||||
db.Exec_SQL("Update profil set bezeichnung='" + txtbezeichnung.Text + "', unterschriftlinks=" + cbboxUnterschriftLinks.SelectedValue.ToString() + ", unterschriftrechts=" + cbboxUnterschriftRechts.SelectedValue.ToString() + ", team=" + cbboxTeam.SelectedValue.ToString() + " ,standard=1 where profilnr=" + lbprofile.SelectedValue.ToString());
|
||||
}
|
||||
db.Exec_SQL("Update profil set bezeichnung='" + txtbezeichnung.Text + "',unterschriftlinks=" + cbboxUnterschriftLinks.SelectedValue.ToString() + ", unterschriftrechts=" + cbboxUnterschriftRechts.SelectedValue.ToString() + ", team=" + cbboxTeam.SelectedValue.ToString() + " where profilnr=" + lbprofile.SelectedValue.ToString());
|
||||
//db.Exec_SQL("Update mitarbeiter set name='" + txtName.Text + "', vorname='" + txtVorname.Text + "', email='" + txtmail.Text + "', telefon='" + txttelefon.Text + "' where mitarbeiternr=" + AppParams.CurrentMitarbieter.ToString());
|
||||
//db.Exec_SQL("Update mitarbeiter set fax='" + txtfax.Text + "', unterschrift_text='" + txtunterschrift.Text + "', funktion='" + txtfunktion.Text + "', mutiert_am=getdate(), mutierer=" + AppParams.CurrentMitarbieter.ToString() + " where mitarbeiternr = " + AppParams.CurrentMitarbieter.ToString());
|
||||
db = null;
|
||||
refresh_profile();
|
||||
lbprofile.SelectedValue = saveselected;
|
||||
}
|
||||
|
||||
private void ribbonButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
if (cbStandard.Checked)
|
||||
{
|
||||
MessageBox.Show("Das Standardprofil kann nicht gelöscht werden.", "Profil löschen", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
db.Exec_SQL("Update profil set aktiv=0 where profilnr=" + lbprofile.SelectedValue.ToString());
|
||||
}
|
||||
db = null;
|
||||
refresh_profile();
|
||||
lbprofile.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void ribbonButtonNew_Click(object sender, EventArgs e)
|
||||
{
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
db.Get_Tabledata("Select * from profil where profilnr=0", false, true);
|
||||
|
||||
int newkey = Convert.ToInt32(db.get_dbkey("Profil").ToString());
|
||||
|
||||
|
||||
db.dsdaten.Tables[0].Rows[0]["PROFILnr"] = newkey;
|
||||
db.dsdaten.Tables[0].Rows[0]["Mitarbeiternr"] = AppParams.CurrentMitarbieter;
|
||||
db.dsdaten.Tables[0].TableName = "Profil";
|
||||
var res = db.InsertDataRow(db.dsdaten.Tables[0].Rows[0], AppParams.connectionstring);
|
||||
//SqlCommand sqlq = db.CreateInsertCommand(db.dsdaten.Tables[0].Rows[0]);
|
||||
//db.InsertDataRow(sqlq);
|
||||
|
||||
//string sql1 = db.BuildAllFieldsSQL(db.dsdaten.Tables[0]);
|
||||
//MessageBox.Show(sql1);
|
||||
//string sql = db.BuildInsertSQL(db.dsdaten.Tables[0]);
|
||||
//MessageBox.Show(sql);
|
||||
//db.Exec_SQL(sql);
|
||||
db = null; ;
|
||||
refresh_profile();
|
||||
lbprofile.SelectedValue = newkey;
|
||||
|
||||
}
|
||||
|
||||
private void ribbonButtonNew_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void MitarbeiterProfil_Activated(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ribbonTab1_ActiveChanged(object sender, EventArgs e)
|
||||
{
|
||||
GrpBoxProfile.Dock = DockStyle.Left;
|
||||
GrpBoxProfile.Visible = true;
|
||||
GrpBoxDetails.Dock = DockStyle.Fill;
|
||||
GrpBoxDetails.Visible = true;
|
||||
GrpBoxMitarbeiter.Visible = false;
|
||||
}
|
||||
|
||||
private void ribbonTab2_ActiveChanged(object sender, EventArgs e)
|
||||
{
|
||||
GrpBoxProfile.Visible = false;
|
||||
GrpBoxDetails.Visible = false;
|
||||
GrpBoxMitarbeiter.Visible = true;
|
||||
GrpBoxMitarbeiter.Dock = DockStyle.Fill;
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
db.Get_Tabledata("select * from mitarbeiter where mitarbeiternr=" + AppParams.CurrentMitarbieter.ToString(), false, true);
|
||||
if (db.dsdaten.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try {
|
||||
string unterschrift = get_unterschrift(db.dsdaten.Tables[0].Rows[0]["tgnummer"].ToString());
|
||||
string ss = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(unterschrift);
|
||||
MemoryStream mssign = new MemoryStream(Convert.FromBase64String(ss));
|
||||
System.Drawing.Image img = System.Drawing.Image.FromStream(mssign);
|
||||
pictureBox1.Image = img;
|
||||
mssign.Close();
|
||||
mssign.Dispose();
|
||||
|
||||
|
||||
}
|
||||
catch { }
|
||||
txtName.Text = db.dsdaten.Tables[0].Rows[0]["name"].ToString();
|
||||
txtVorname.Text= db.dsdaten.Tables[0].Rows[0]["vorname"].ToString();
|
||||
txtmail.Text = db.dsdaten.Tables[0].Rows[0]["email"].ToString();
|
||||
txttelefon.Text = db.dsdaten.Tables[0].Rows[0]["telefon"].ToString();
|
||||
txtfax.Text = db.dsdaten.Tables[0].Rows[0]["fax"].ToString();
|
||||
txtunterschrift.Text = db.dsdaten.Tables[0].Rows[0]["unterschrift_text"].ToString();
|
||||
txtfunktion.Text = db.dsdaten.Tables[0].Rows[0]["funktion"].ToString();
|
||||
db = null;
|
||||
// System.Drawing.Image image = System.Drawing.Image.FromFile(@"E:\Software-Projekte\OnDoc\Images\download.png");
|
||||
//this.pictureBox1.Image = image;
|
||||
}
|
||||
}
|
||||
|
||||
private string get_unterschrift(string MaNr)
|
||||
{
|
||||
|
||||
string URL = AppParams.RESTURI + "API/GetUnterschriftAsBase64ByMitarbeiternr?MaNr=" + AppParams.CurrentMitarbieter.ToString()+ "&ImageWith=-1";
|
||||
|
||||
HttpWebRequest webRequest = HttpWebRequest.Create(URL) as HttpWebRequest;
|
||||
webRequest.Method = WebRequestMethods.Http.Get;
|
||||
webRequest.Headers["Authorization"] = "Bearer " + AppParams.apikey;
|
||||
try
|
||||
{
|
||||
using (HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse)
|
||||
{
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
StreamReader reader = new StreamReader(response.GetResponseStream());
|
||||
string responseContent = reader.ReadToEnd();
|
||||
|
||||
return responseContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Logging.Error(URL + ": " + response.StatusCode.ToString() + " / " + response.StatusDescription, "Clinet - DokList GetDocument", "");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
protected bool validData;
|
||||
string path;
|
||||
protected System.Drawing.Image image;
|
||||
protected Thread getImageThread;
|
||||
private void pictureBox1_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
string filename;
|
||||
validData = GetFilename(out filename, e);
|
||||
if (validData)
|
||||
{
|
||||
path = filename;
|
||||
getImageThread = new Thread(new ThreadStart(LoadImage));
|
||||
getImageThread.Start();
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
private bool GetFilename(out string filename, DragEventArgs e)
|
||||
{
|
||||
bool ret = false;
|
||||
filename = String.Empty;
|
||||
if ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy)
|
||||
{
|
||||
Array data = ((IDataObject)e.Data).GetData("FileDrop") as Array;
|
||||
if (data != null)
|
||||
{
|
||||
if ((data.Length == 1) && (data.GetValue(0) is String))
|
||||
{
|
||||
filename = ((string[])data)[0];
|
||||
string ext = System.IO.Path.GetExtension(filename).ToLower();
|
||||
if ((ext == ".jpg") || (ext == ".png") || (ext == ".bmp"))
|
||||
{
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
protected void LoadImage()
|
||||
|
||||
{
|
||||
image = new Bitmap(path);
|
||||
}
|
||||
|
||||
private void pictureBox1_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
{
|
||||
if (validData)
|
||||
{
|
||||
while (getImageThread.IsAlive)
|
||||
{
|
||||
System.Windows.Forms.Application.DoEvents();
|
||||
Thread.Sleep(0);
|
||||
}
|
||||
pictureBox1.Image = image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RibbonMitarbeiterButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
|
||||
db.Exec_SQL("Update mitarbeiter set name='" + txtName.Text + "', vorname='" + txtVorname.Text + "', email='" + txtmail.Text + "', telefon='" + txttelefon.Text + "' where mitarbeiternr=" + AppParams.CurrentMitarbieter.ToString());
|
||||
db.Exec_SQL("Update mitarbeiter set fax='" + txtfax.Text + "', unterschrift_text='" + txtunterschrift.Text + "', funktion='" + txtfunktion.Text + "', mutiert_am=getdate(), mutierer=" + AppParams.CurrentMitarbieter.ToString() + " where mitarbeiternr = " + AppParams.CurrentMitarbieter.ToString());
|
||||
db = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user