| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- 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 = "";//路径
- /// <summary>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- 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;
- }
- }
-
- /// <summary>
- /// 查询
- /// </summary>
- private void doQueryData()
- {
- List<BaseUserOrderEntity> listSource = EntityHelper.GetData<BaseUserOrderEntity>(
- "com.steering.lims.data.pipe.FrmBaseUser.doQueryUser", new object[] { arrId }, this.ob);
- baseUserOrderEntityBindingSource.DataSource = listSource;
- }
- /// <summary>
- /// 新增
- /// </summary>
- private void doAdd()
- {
- this.ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> 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);
- }
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- private void doUpdate()
- {
- this.ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> 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);
- }
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- private void doDelete()
- {
- this.ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> 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);
- }
- }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- private void close()
- {
- this.Close();
- }
- private void FrmBaseUser_Load(object sender, EventArgs e)
- {
- EntityHelper.ShowGridCaption<BaseUserOrderEntity>(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<FileBean> list = new List<FileBean>();
- 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<FileBean> list = new List<FileBean>();
- 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;
- }
- }
- }
- }
- }
|