using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Format;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.Lims.Data.PipeAndOutdec.封装类.实体类;
using CoreFS.CA06;
using Infragistics.Win.UltraWinGrid;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Core.StlMes.Client.Lims.Data.PipeAndOutdec
{
public partial class FrmBaseUser : FrmBase
{
private string[] arrId;//数据权限
public FrmBaseUser()
{
InitializeComponent();
}
private string fileName = "";//路径
///
/// 重写基类方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
doQueryData();
break;
case "Add":
doAdd();
break;
case "Update":
doUpdate();
break;
case "Delete":
doDelete();
break;
case "Close":
close();
break;
}
}
///
/// 查询
///
private void doQueryData()
{
List listSource = EntityHelper.GetData(
"com.steering.lims.data.pipe.FrmBaseUser.doQueryUser", new object[] { arrId }, this.ob);
baseUserOrderEntityBindingSource.DataSource = listSource;
}
///
/// 新增
///
private void doAdd()
{
this.ultraGrid1.UpdateData();
IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
if (checkMagRows.Count() == 0)
{
MessageUtil.ShowTips("请选择需要新增的用户信息!");
return;
}
ArrayList parmList = new ArrayList();
foreach(UltraGridRow row in checkMagRows)
{
BaseUserOrderEntity baseTity = (BaseUserOrderEntity)row.ListObject;
baseTity.UserId = row.Cells["UserId"].Value.ToString();
baseTity.UserName = row.Cells["UserId"].Text.ToString();
baseTity.UserOrder = row.Cells["UserOrder"].Value.ToString();
baseTity.UserGroup = row.Cells["UserGroup"].Value.ToString();
baseTity.UserType = row.Cells["UserType"].Value.ToString();
baseTity.SignaturePath = row.Cells["SignaturePath"].Text;
baseTity.UserId2 = row.Cells["UserId2"].Value.ToString();
baseTity.UserName2 = row.Cells["UserId2"].Text.ToString();
baseTity.SignaturePath2 = row.Cells["SignaturePath2"].Text;
baseTity.DeptId = UserInfo.GetDeptid();
string baseEntity = JSONFormat.Format(baseTity);
parmList.Add(baseEntity);
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.lims.data.pipe.FrmBaseUser";
ccp.MethodName = "doAdd";
ccp.ServerParams = new object[] { parmList,UserInfo.GetUserName() };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("新增成功!"))
{
doQueryData();
MessageUtil.ShowTips(ccp.ReturnInfo);
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
///
/// 修改
///
private void doUpdate()
{
this.ultraGrid1.UpdateData();
IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
if (checkMagRows.Count() == 0)
{
MessageUtil.ShowTips("请选择需要修改的用户信息!");
return;
}
ArrayList parmList = new ArrayList();
foreach (UltraGridRow row in checkMagRows)
{
BaseUserOrderEntity baseTity = (BaseUserOrderEntity)row.ListObject;
baseTity.UserId = row.Cells["UserId"].Value.ToString();
baseTity.UserOrder = row.Cells["UserOrder"].Value.ToString();
baseTity.UserGroup = row.Cells["UserGroup"].Value.ToString();
baseTity.SignaturePath = row.Cells["SignaturePath"].Text;
baseTity.UserId2 = row.Cells["UserId2"].Value.ToString();
baseTity.UserName2 = row.Cells["UserId2"].Text.ToString();
baseTity.SignaturePath2 = row.Cells["SignaturePath2"].Text;
string baseEntity = JSONFormat.Format(baseTity);
parmList.Add(baseEntity);
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.lims.data.pipe.FrmBaseUser";
ccp.MethodName = "doUpdate";
ccp.ServerParams = new object[] { parmList };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("修改成功!"))
{
doQueryData();
MessageUtil.ShowTips(ccp.ReturnInfo);
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
///
/// 删除
///
private void doDelete()
{
this.ultraGrid1.UpdateData();
IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
if (checkMagRows.Count() == 0)
{
MessageUtil.ShowTips("请选择需要删除的用户信息!");
return;
}
ArrayList parmList = new ArrayList();
foreach (UltraGridRow row in checkMagRows)
{
BaseUserOrderEntity baseTity = (BaseUserOrderEntity)row.ListObject;
baseTity.UserId = row.Cells["UserId"].Value.ToString();
string baseEntity = JSONFormat.Format(baseTity);
parmList.Add(baseEntity);
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.lims.data.pipe.FrmBaseUser";
ccp.MethodName = "doDelete";
ccp.ServerParams = new object[] { parmList };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("删除成功!"))
{
doQueryData();
MessageUtil.ShowTips(ccp.ReturnInfo);
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
///
/// 关闭
///
private void close()
{
this.Close();
}
private void FrmBaseUser_Load(object sender, EventArgs e)
{
EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]);
arrId = this.ValidDataPurviewIds;//获取数据权限
initUser();
}
private void initUser()
{
DataTable dt = ServerHelper.GetData("com.steering.lims.data.pipe.FrmBaseUser.doQueryUserMa", new object[] { arrId }, ob);
if(dt.Rows.Count > 0)
{
ultraComboEditor1.DataSource = dt;
ultraComboEditor1.DisplayMember = "USERNAME";
ultraComboEditor1.ValueMember = "USERID";
ultraComboEditor5.DataSource = dt;
ultraComboEditor5.DisplayMember = "USERNAME";
ultraComboEditor5.ValueMember = "USERID";
}
}
private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
this.ultraGrid1.UpdateData();
UltraGridRow row = ultraGrid1.ActiveRow;
//string askSubItem = row.GetValue("PLINE_CODE");
string userId = row.Cells["UserId"].Value.ToString();
string filePath = "Lims/autograph/" + userId + "/";
if (e.Button.Key.ToLower().Equals("select"))
{
FormFileDown down = new FormFileDown(this.ob, row.Cells["SignaturePath"].Text);
down.CtrlFileDown1.Button3.Visible = false;
down.ShowDialog();
}
if (e.Button.Key.ToLower().Equals("insert"))
{
if (userId.Equals(""))
{
MessageUtil.ShowTips("没有用户不允许上传!");
return;
}
FormFileDown down = new FormFileDown(this.ob, filePath);
down.CtrlFileDown1.FilePath = filePath;
List list = new List();
FileBean bean = new FileBean();
OpenFileDialog file = new OpenFileDialog();
file.Multiselect = false;
DialogResult drStat;
drStat = file.ShowDialog();
if (drStat == DialogResult.OK)
{
fileName = file.FileName;
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
long s = fs.Length;
if (s / 1024.0 > 50)
{
MessageUtil.ShowTips("图片大于50KB,请重新上传!");
return;
}
string filena = System.IO.Path.GetFileName(fileName);
//DataTable dt = ServerHelper.GetData("com.steering.lims.data.pipe.FrmBaseUser.doQueryPath", new object[] { row.Cells["UserId"].Value.ToString() }, ob);
//if (dt.Rows.Count > 0)
//{
// //string seturl = dt.Rows[0]["SIGNATURE_PATH"].ToString();
// //bool isdelete = Core.Mes.Client.Comm.Server.FileHelper.Delete(seturl);
// CoreClientParam ccp = new CoreClientParam();
// ccp.ServerName = "com.steering.mes.signature.FrmTubeRollFileManage";
// ccp.MethodName = "updateMinStgnature1";
// ccp.ServerParams = new object[] { filePath + filena, row.Cells["UserId"].Value.ToString() };
// ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
// if (ccp.ReturnCode == -1) { MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question); return; }
//}
bean = new FileBean();
bean.setFileName(filena);
bean.setPathName(filePath);
bean.setFile(FileHelper.FileToArray(fileName));
list.Add(bean);
bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
if (isSuccess)
{
MessageBox.Show("上传成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
}
else
{
MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
}
ultraGrid1.ActiveCell.Value = filena;
ultraGrid1.ActiveRow.Cells["SignaturePath"].Value = filePath + filena;
//ultraGrid1.ActiveRow.Cells["SignaturePath"].Value = fileName;
}
}
}
private void craftImg2_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
this.ultraGrid1.UpdateData();
UltraGridRow row = ultraGrid1.ActiveRow;
//string askSubItem = row.GetValue("PLINE_CODE");
string userId2 = row.Cells["UserId2"].Value.ToString();
string filePath = "Lims/autograph/" + userId2 + "2/";
if (e.Button.Key.ToLower().Equals("select"))
{
FormFileDown down = new FormFileDown(this.ob, row.Cells["SignaturePath2"].Text);
down.CtrlFileDown1.Button3.Visible = false;
down.ShowDialog();
}
if (e.Button.Key.ToLower().Equals("insert"))
{
if (userId2.Equals(""))
{
MessageUtil.ShowTips("没有复审人不允许上传!");
return;
}
FormFileDown down = new FormFileDown(this.ob, filePath);
down.CtrlFileDown1.FilePath = filePath;
List list = new List();
FileBean bean = new FileBean();
OpenFileDialog file = new OpenFileDialog();
file.Multiselect = false;
DialogResult drStat;
drStat = file.ShowDialog();
if (drStat == DialogResult.OK)
{
fileName = file.FileName;
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
long s = fs.Length;
if (s / 1024.0 > 50)
{
MessageUtil.ShowTips("图片大于50KB,请重新上传!");
return;
}
string filena = System.IO.Path.GetFileName(fileName);
bean = new FileBean();
bean.setFileName(filena);
bean.setPathName(filePath);
bean.setFile(FileHelper.FileToArray(fileName));
list.Add(bean);
bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
if (isSuccess)
{
MessageBox.Show("上传成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
}
else
{
MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
}
ultraGrid1.ActiveCell.Value = filena;
ultraGrid1.ActiveRow.Cells["SignaturePath2"].Value = filePath + filena;
//ultraGrid1.ActiveRow.Cells["SignaturePath"].Value = fileName;
}
}
}
}
}