| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using Core.StlMes.Client.SaleOrder.BLL;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinGrid;
- using Core.Mes.Client.Comm.Tool;
- using Infragistics.Win.UltraWinEditors;
- using Core.StlMes.Client.Qcm;
- using CoreFS.SA06;
- using Core.StlMes.Client.SaleOrder.Dialog;
- namespace Core.StlMes.Client.SaleOrder.Control
- {
- public partial class CraftFileApplyCtrl : UserControl
- {
- private CraftFileApplyBLL _craftFileApplyBLL;
- private CraftFileApplyEntity _queryCondition;
- private UltraComboEditor[] _cmbs = new UltraComboEditor[2];
- private OpeBase ob;
- public CraftFileApplyCtrl(System.Windows.Forms.Control container, OpeBase ob)
- {
- InitializeComponent();
- this.ob = ob;
- _craftFileApplyBLL = new CraftFileApplyBLL(ob);
- container.Controls.Add(this);
- this.Dock = DockStyle.Fill;
- EntityHelper.ShowGridCaption<CraftFileApplyEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- InitData();
- }
- private void InitData()
- {
- for(int i = 0; i < _cmbs.Length; i++)
- {
- _cmbs[i] = new UltraComboEditor();
- _cmbs[i].DropDownListWidth = -1;
- _cmbs[i].Visible = false;
- this.Controls.Add(_cmbs[i]);
- }
- ultraGrid1.DisplayLayout.Bands[0].Columns["MscDesc"].EditorComponent = ultraTextEditor1;
- ultraGrid1.DisplayLayout.Bands[0].Columns["ModelDesc"].EditorComponent = ultraTextEditor1;
- //QcmBaseQuery.NitializePsc(_cmbs[0], false, ob);
- //ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"].EditorComponent = _cmbs[0];
- //ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown;
- //ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"].AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
- QcmBaseQuery.NitializeSpec(_cmbs[1], "C", false, ob);
- ultraGrid1.DisplayLayout.Bands[0].Columns["SpecCode"].EditorComponent = _cmbs[1];
- ultraGrid1.DisplayLayout.Bands[0].Columns["SpecCode"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- }
- public void Query(CraftFileApplyEntity queryCondition)
- {
- this._queryCondition = queryCondition;
- this.craftFileApplyEntityBindingSource.DataSource = _craftFileApplyBLL.Query(queryCondition);
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- ControlCellEdite(row);
- }
- }
- public void Save()
- {
- this.ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
- if (rows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择一条适用范围!");
- return;
- }
- List<CraftFileApplyEntity> list = new List<CraftFileApplyEntity>();
- CraftFileApplyEntity relocate = new CraftFileApplyEntity();
- foreach (UltraGridRow row in rows)
- {
- CraftFileApplyEntity craftFileApply = (CraftFileApplyEntity)row.ListObject;
- if (CheckData(craftFileApply, row) == false) return;
- CraftFileApplyEntity parm = EntityHelper.CopyEntity<CraftFileApplyEntity>(craftFileApply);
- foreach(string model in parm.ModelCode.Split('|'))
- {
- parm.ModelCode = model;
- DataTable dtSampeCnt = _craftFileApplyBLL.GetSampeCnt(parm);
- if (int.Parse(dtSampeCnt.Rows[0]["COUNT"].ToString()) > 0)
- {
- MessageUtil.ShowWarning(string.Format("与工艺文件号{0}版本号{1}的适用范围存在交集,不允许保存!",
- dtSampeCnt.Rows[0]["CRAFT_NO"].ToString(), dtSampeCnt.Rows[0]["CRAFT_NO_V"].ToString()));
- return;
- }
- }
- craftFileApply.CreateName = CoreUserInfo.UserInfo.GetUserName();
- list.Add(craftFileApply);
- relocate = craftFileApply;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认保存适用范围?") == DialogResult.No)
- {
- return;
- }
- _craftFileApplyBLL.Save(list);
- MessageUtil.ShowTips("保存成功!");
- Relocate(relocate);
- }
- private void Relocate(CraftFileApplyEntity relocate)
- {
- Query(_queryCondition);
- IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where(
- a => a.GetValue("Msc") == relocate.Msc && a.GetValue("MinD") == relocate.MinD
- && a.GetValue("MaxD") == relocate.MaxD && a.GetValue("MinH") == relocate.MinH
- && a.GetValue("MaxH") == relocate.MaxH && a.GetValue("SpecCode") == relocate.SpecCode
- && a.GetValue("ModelCode") == relocate.ModelCode);
- if (rows.Count() > 0)
- {
- rows.First().Activate();
- }
- }
- private bool CheckData(CraftFileApplyEntity craftFileApply, UltraGridRow row)
- {
- if (craftFileApply.Msc == "")
- {
- MessageUtil.ShowWarning("请选择冶金规范!");
- return false;
- }
- if (craftFileApply.SpecCode == ""
- && craftFileApply.MinD == "" && craftFileApply.MaxD == ""
- && craftFileApply.MinH == "" && craftFileApply.MaxH == "")
- {
- MessageUtil.ShowWarning("请输入适用规格!");
- row.Cells["MinD"].Activate();
- return false;
- }
- if (craftFileApply.SpecCode == "")
- {
- if (craftFileApply.MinD == "")
- {
- MessageUtil.ShowWarning("请输入适用外径最小值!");
- row.Cells["MinD"].Activate();
- return false;
- }
- else if (craftFileApply.MaxD == "")
- {
- MessageUtil.ShowWarning("请输入适用外径最大值!");
- row.Cells["MaxD"].Activate();
- return false;
- }
- else if (craftFileApply.MinH == "")
- {
- MessageUtil.ShowWarning("请输入适用壁厚最小值!");
- row.Cells["MinH"].Activate();
- return false;
- }
- else if (craftFileApply.MaxH == "")
- {
- MessageUtil.ShowWarning("请输入适用壁厚最大值!");
- row.Cells["MaxH"].Activate();
- return false;
- }
- }
- if (craftFileApply.SpecCode == "")
- {
- if (decimal.Parse(craftFileApply.MinD) > decimal.Parse(craftFileApply.MaxD))
- {
- MessageUtil.ShowWarning("适用外径最小值不能大于适用外径最大值!");
- row.Cells["MinD"].Activate();
- return false;
- }
- if (decimal.Parse(craftFileApply.MinH) > decimal.Parse(craftFileApply.MaxH))
- {
- MessageUtil.ShowWarning("适用壁厚最小值不能大于适用壁厚最大值!");
- row.Cells["MinH"].Activate();
- return false;
- }
- }
- return true;
- }
- private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- UltraGridRow row = this.ultraGrid1.DisplayLayout.ActiveRow;
- if (ultraGrid1.ActiveCell.Column.Key == "ModelDesc")
- {
- FrmModel frms = new FrmModel();
- frms.FormClosed += new FormClosedEventHandler((a, b)=>
- {
- row.Cells["ModelCode"].Value = frms.Code;
- row.Cells["ModelDesc"].Value = frms.Desc;
- });
- frms.Desc = row.Cells["ModelDesc"].Value.ToString();
- frms.FrmOb = this.ob;
- frms.Show();
-
- }
- else if (ultraGrid1.ActiveCell.Column.Key == "MscDesc")
- {
- this.Cursor = Cursors.WaitCursor;
- PscMscPopup pscMscPopup = new PscMscPopup(row.GetValue("Msc"), ob);
- pscMscPopup.FormClosed += new FormClosedEventHandler((a, b) =>
- {
- if (pscMscPopup.DialogResult == DialogResult.OK)
- {
- row.Cells["Msc"].Value = pscMscPopup.ChoiceMsc;
- row.Cells["MscDesc"].Value = pscMscPopup.ChoiceMscDesc;
- }
- });
- this.Cursor = Cursors.Default;
- pscMscPopup.Show();
-
- }
- }
- private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
- {
- e.Row.Cells["CraftNo"].Value = _queryCondition.CraftNo;
- e.Row.Cells["CraftNoV"].Value = _queryCondition.CraftNoV;
- e.Row.Cells["CraftKey"].Value = _queryCondition.CraftKey;
- }
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- //ultraGrid1.UpdateData();
- if(e.Cell.Column.Key == "CHK")
- {
- ultraGrid1.UpdateData();
- ControlCellEdite(e.Cell.Row);
- }
- }
- private void ControlCellEdite(UltraGridRow row)
- {
- Activation activation;
- if (row.Cells["CHK"].Value.ToString() == "True")
- {
- activation = Activation.AllowEdit;
- }
- else
- {
- activation = Activation.ActivateOnly;
- }
- row.Cells["MinH"].Activation = activation;
- row.Cells["MaxH"].Activation = activation;
- row.Cells["MinD"].Activation = activation;
- row.Cells["MaxD"].Activation = activation;
- row.Cells["SpecCode"].Activation = activation;
- row.Cells["ModelDesc"].Activation = activation;
- }
- }
- }
|