| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Qcm.BLL;
- using Core.StlMes.Client.Qcm.model;
- using CoreFS.CA06;
- using CoreFS.SA06;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm.Control
- {
- public partial class QcmZbsTemplateHeadCtrl : UserControl
- {
- private QcmZbsTemplateHeadBLL _zbsTemplateHeadBLL;
- private OpeBase ob;
- public QcmZbsTemplateHeadCtrl(System.Windows.Forms.Control container, OpeBase ob)
- {
- InitializeComponent();
- this.ob = ob;
- _zbsTemplateHeadBLL = new QcmZbsTemplateHeadBLL(ob);
- container.Controls.Add(this);
- this.Dock = DockStyle.Fill;
- EntityHelper.ShowGridCaption<QcmZbsTemplateHeadEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- }
- private string _decription = "";
- private string _validflag = "";
- public void Query(string decription, string validflag)
- {
- _decription = decription;
- _validflag = validflag;
- qcmZbsTemplateHeadEntityBindingSource.DataSource = _zbsTemplateHeadBLL.Query(decription, validflag);
- foreach (var row in ultraGrid1.Rows)
- {
- GridEdite(row);
- }
- }
- public void Relocate(string tbh, string decription, string validflag)
- {
- Query(decription, validflag);
- var row = ultraGrid1.Rows.Where(a => a.GetValue("tbh") == tbh).FirstOrDefault();
- if (row != null)
- {
- row.Activate();
- }
- }
- public void Save()
- {
- var rows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
- if (rows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择记录!");
- return;
- }
- List<QcmZbsTemplateHeadEntity> parms = new List<QcmZbsTemplateHeadEntity>();
- string tbh = "";
- foreach (var row in rows)
- {
- QcmZbsTemplateHeadEntity zbsTemplateHead = EntityHelper.CopyEntity<QcmZbsTemplateHeadEntity>(row.ListObject);
- if (zbsTemplateHead.Description == "")
- {
- MessageUtil.ShowWarning("请输入模板描述!");
- return;
- }
- if (zbsTemplateHead.SheetCount == null)
- {
- MessageUtil.ShowWarning("请输入模板SHEET页数!");
- return;
- }
- zbsTemplateHead.CreateName = CoreUserInfo.UserInfo.GetUserName();
- zbsTemplateHead.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- parms.Add(zbsTemplateHead);
- tbh = zbsTemplateHead.Tbh;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No) return;
- _zbsTemplateHeadBLL.Save(parms);
- MessageUtil.ShowTips("保存成功!");
- Relocate(tbh, _decription, _validflag);
- }
- public void UpdateValidflag(string validflag)
- {
- var rows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
- if (rows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择记录!");
- return;
- }
- List<QcmZbsTemplateHeadEntity> parms = new List<QcmZbsTemplateHeadEntity>();
- string tbh = "";
- foreach (var row in rows)
- {
- QcmZbsTemplateHeadEntity zbsTemplateHead = EntityHelper.CopyEntity<QcmZbsTemplateHeadEntity>(row.ListObject);
- zbsTemplateHead.DeleteName = CoreUserInfo.UserInfo.GetUserName();
- parms.Add(zbsTemplateHead);
- tbh = zbsTemplateHead.Tbh;
- }
- if (MessageUtil.ShowYesNoAndQuestion(string.Format("是否确认{0}?",
- validflag == "0" ? "作废" : "恢复")) == DialogResult.No) return;
- _zbsTemplateHeadBLL.UpdateValidflag(parms, validflag);
- MessageUtil.ShowTips(string.Format("{0}成功!", validflag == "0" ? "作废" : "恢复"));
- Relocate(tbh, _decription, _validflag);
- }
- private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- ultraGrid1.UpdateData();
- GridEdite(e.Cell.Row);
- }
- private void GridEdite(UltraGridRow row)
- {
- if (row.GetValue("Chk") == "True")
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.AllowEdit;
- }
- }
- }
- else
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.Key == "Chk") continue;
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- if (e.Row.GetValue("Validflag") == "无效")
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- else
- {
- e.Row.Appearance.ForeColor = Color.Black;
- }
- }
- private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- QcmZbsTemplateHeadEntity zbsTemplateEntity = EntityHelper.CopyEntity<QcmZbsTemplateHeadEntity>(ultraGrid1.ActiveRow.ListObject);
- if (zbsTemplateEntity.Validflag == "")
- {
- MessageUtil.ShowWarning("请先保存记录,然后再上传图片!");
- return;
- }
- string path = "Qcm/ZbsTemplate/" + zbsTemplateEntity.Tbh + "/";
- if (e.Button.Key == "View")
- {
- FormFileDown down = new FormFileDown(ob, path);
- //if (flag == "试样关系")
- //{
- // down.DeleteButton.Visible = false;
- //}
- down.ShowDialog();
- if (down.CtrlFileDown1.List.Count == 0 && zbsTemplateEntity.Xls != "")
- {
- zbsTemplateEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- zbsTemplateEntity.Xls = "";
- _zbsTemplateHeadBLL.UpdateXls(zbsTemplateEntity);
- Relocate(zbsTemplateEntity.Tbh, _decription, _validflag);
- }
- }
- if (e.Button.Key == "Upload")
- {
- var serverFileList = FileHelper.Download(path);
- if (serverFileList.Count > 0)
- {
- MessageUtil.ShowWarning("该记录已存在一份文件,请删除后再重新上传!");
- return;
- }
- 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)
- {
- string filePath = file.FileName;
- string fileName = System.IO.Path.GetFileName(filePath);
- bean = new FileBean();
- bean.setFileName(fileName);
- bean.setPathName(path);
- bean.setFile(FileHelper.FileToArray(filePath));
- list.Add(bean);
- zbsTemplateEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- zbsTemplateEntity.Xls = path + fileName;
- _zbsTemplateHeadBLL.UpdateXls(zbsTemplateEntity);
- bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
- if (isSuccess)
- {
- MessageUtil.ShowTips("上传成功!");
- Relocate(zbsTemplateEntity.Tbh, _decription, _validflag);
- }
- else
- {
- MessageUtil.ShowTips("上传失败,请重试!");
- }
- }
- }
- }
- }
- }
|