using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Server;
using CoreFS.CA06;
using Infragistics.Win.UltraWinEditors;
using Infragistics.Win.UltraWinGrid;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
namespace Core.StlMes.Client.Qcm
{
///
/// 产品规范管理
///
public partial class FrmStandard1 : FrmBase
{
//提示信息
private string errMessage = "";
//动态生成科室
private Dictionary departments = null;
//定位标准基础
private string _std = "";
//定位产品规范
private string _psc = "";
//定位最终客户
private string _cust = "";
//判断是否勾选
private int isSelectData = -1;
private int distance = 0;
private int disWidth = 0;
private UltraComboEditor[] uces = new UltraComboEditor[7];
public FrmStandard1()
{
IsLoadUserView = true;
InitializeComponent();
}
///
/// 隐藏页面
///
private void Distinguish()
{
if (this.CustomInfo == "1")
{
splitContainer1.Panel2Collapsed = true;
ultraGrid2.Enabled = false;
}
if (this.CustomInfo == "2")
{
splitContainer1.Panel2Collapsed = true;
splitContainer2.Panel2Collapsed = true;
}
if (this.CustomInfo == "3")
{
splitContainer2.Panel2Collapsed = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["DEPARTMENT_CODE"].CellAppearance.BackColor = Color.Empty;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["UNIT_CODE"].CellAppearance.BackColor = Color.Empty;
// LightGray
}
}
///
/// 重写基类方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "doQuery":
DoQuery();
break;
case "doSave":
DoSave();
break;
case "doDelete":
this.DoDeleteOrResume(true);
break;
case "doResume":
this.DoDeleteOrResume(false);
break;
case "Refresh":
InitComBoEditor();
break;
case "Close":
this.Close();
break;
}
}
///
/// 初始化
///
///
///
private void FrmStandard1_Load(object sender, EventArgs e)
{
Distinguish();
InitComBoEditor();
CreateDepartments();
}
///
/// 初始化下拉框
///
private void InitComBoEditor()
{
for (int i = 0; i < uces.Length; i++)
{
uces[i] = new UltraComboEditor();
Controls.Add(uces[i]);
uces[i].Visible = false;
}
UltraGridBand ugb1 = ultraGrid1.DisplayLayout.Bands[0];
UltraGridBand ugb2 = ultraGrid2.DisplayLayout.Bands[0];
UltraGridBand ugb3 = ultraGrid3.DisplayLayout.Bands[0];
//初始化标准类型
QcmBaseQuery.NitializeStandardType(uces[0], false, this.ob);
if (CustomInfo == "1")
{
((DataTable)uces[0].DataSource).DefaultView.RowFilter = "CODE IN ('G', 'X')";
}
if (CustomInfo == "2")
{
((DataTable)uces[0].DataSource).DefaultView.RowFilter = "CODE NOT IN ('G', 'X','K')";
}
if (CustomInfo == "3")
{
((DataTable)uces[0].DataSource).DefaultView.RowFilter = "CODE IN ('K')";
}
QcmBaseQuery.BindColumn(uces[0], "STDSTYLE", ugb1);
//初始化标准协会
QcmBaseQuery.NitializeSociety(uces[1], true, this.ob);
QcmBaseQuery.BindColumn(uces[1], "STD_STYLE", ugb1);
//初始化管理部门
QcmBaseQuery.NitializeDepartment(uces[2], false, this.ob);
QcmBaseQuery.BindColumn(uces[2], "DEPARTMENT_CODE", ugb1);
QcmBaseQuery.BindColumn(uces[2], "DEPARTMENT_CODE", ugb2);
//品名描述
QcmBaseQuery.NitializeProducName(uces[3], false, this.ob);
QcmBaseQuery.BindColumn(uces[3], "PRODUCCODE", ugb2);
//初始化标准类别
QcmBaseQuery.NitializeStdStyle(uces[4], true, this.ob);
QcmBaseQuery.BindColumn(uces[4], "STD_STYLE", ugb2);
//初始化钢级牌号
QcmBaseQuery.NitializeSteel(uces[5], true, this.ob);
QcmBaseQuery.BindColumn(uces[5], "STEELCODE", ugb2);
//初始化最终客户
QcmBaseQuery.NitializeCustomer(uces[6], true, this.ob);
QcmBaseQuery.BindColumn(uces[6], "CUST_CODE", ugb3);
}
///
/// 动态绑定数据源 管理科室
///
private void BandDepartments(InitializeRowEventArgs e)
{
string pid = e.Row.Cells["DEPARTMENT_CODE"].Value.ToString();
if (departments.ContainsKey(pid))
{
e.Row.Cells["UNIT_CODE"].EditorComponent = departments[pid];
}
else
{
e.Row.Cells["UNIT_CODE"].EditorComponent = departments["noValue"];
}
}
///
/// 根据部门生成科室
///
private void CreateDepartments()
{
int count = uces[2].Items.Count;
departments = new Dictionary(count + 1);
departments.Add("noValue", new UltraComboEditor());
for (int i = 0; i < count; i++)
{
string pid = uces[2].Items[i].DataValue.ToString();
DataTable dt = ServerHelper.GetData("com.steering.comm.data.ComBaseInfo.getSection", new object[] { }, this.ob);
dt.DefaultView.RowFilter = "PID='" + pid + "'";
UltraComboEditor uce = new UltraComboEditor();
uce.DataSource = dt;
uce.DisplayMember = "DEPARTNAME";
uce.ValueMember = "DEPARTID";
uce.Visible = false;
departments.Add(pid, uce);
Controls.Add(uce);
}
}
///
/// 查询
///
private void DoQuery()
{
//查询条件
string valid = "1";
if (ChcValid.Checked)
valid = "0";
string std = "";
if (ChcStd.Checked)
std = TextStd.Text.Trim();
//CoreStandard标准基础表
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.getComBaseStd", new Object[] { valid, std }, this.ob);
if (CustomInfo == "1")
{
DataRow[] rows = dt.Select("STDSTYLE<>'订货标准' AND STDSTYLE<>'协议标准'");
foreach (DataRow dr in rows)
{
dt.Rows.Remove(dr);
}
}
else if (CustomInfo == "3")
{
DataRow[] rows = dt.Select("STDSTYLE<>'Alpha'");
foreach (DataRow dr in rows)
{
dt.Rows.Remove(dr);
}
}
else
{
DataRow[] rows = dt.Select("STDSTYLE='协议标准' or STDSTYLE='订货标准' or STDSTYLE='Alpha'");
foreach (DataRow dr in rows)
{
dt.Rows.Remove(dr);
}
}
GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
//定位
UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "STD_NAME" }, new string[] { _std });
if (rows1.Length > 0)
rows1[0].Activate();
UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"] };
GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
isSelectData = -1;
}
///
/// 保存
///
private void DoSave()
{
ultraGrid1.UpdateData();
ultraGrid2.UpdateData();
ultraGrid3.UpdateData();
if (isSelectData == -1)
{
MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
//标准基础
UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHC" }, new string[] { "True" });
ArrayList stdAdd = new ArrayList();
ArrayList stdUpdate = new ArrayList();
if (rows.Length > 0)
{
foreach (UltraGridRow row in rows)
{
ArrayList stdList = GetStdData(row);
if (stdList == null)
{
MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
//标准名称
string stdName = row.Cells["STD_NAME"].Value.ToString().Trim();
string stdType = row.Cells["STDSTYLE"].Value.ToString();
_std = stdName;
//标准代码
string stdCode = row.Cells["STD_CODE"].Value.ToString().Trim();
//如果创建人为空,则新增,否则修改
if (row.Cells["CREATE_NAME"].Value.ToString().Equals(""))
{
UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "STD_NAME", "STDSTYLE" }, new string[] { stdName, stdType });
if (rows1.Length > 1)
{
MessageBox.Show("标准名称:" + stdName + " 已经存在,请重新输入!", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
//验证标准名称是否重复
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkStdName", new Object[] { stdName, stdType }, this.ob);
if (dt != null && dt.Rows.Count > 0)
{
MessageBox.Show("标准名称:" + stdName + " 已经存在,请重新输入!", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
stdAdd.Add(stdList);
}
else
{
//验证标准名称是否重复
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkStdName",
new Object[] { stdName, stdCode, stdType }, this.ob);
if (dt != null && dt.Rows.Count > 0)
{
MessageBox.Show("标准名称:" + stdName + " 已经存在,请重新输入!", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
stdList.Add(stdCode);
stdUpdate.Add(stdList);
}
}
}
//产品规范
ArrayList pscAdd = new ArrayList();
ArrayList pscUpdate = new ArrayList();
rows = GridHelper.GetRowsWithKey(ultraGrid2, new string[] { "CHC" }, new string[] { "True" });
if (rows.Length > 0)
{
foreach (UltraGridRow row in rows)
{
string psc = row.Cells["PSC"].Value.ToString();
string pscDesc = row.Cells["PSC_DESC"].Value.ToString();
_psc = pscDesc;
ArrayList pscList = GetPscData(row);
if (pscList == null)
{
MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (row.Cells["CREATE_NAME"].Value.ToString().Equals(""))
{
UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid2, new string[] { "PSC_DESC" }, new string[] { pscDesc });
if (rows1.Length > 1)
{
MessageBox.Show("产品规范描述:" + pscDesc + " 已经存在,请重新组合!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
//验证产品规范描述是否重复
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkPSC", new Object[] { pscDesc }, this.ob);
if (dt != null && dt.Rows.Count > 0)
{
MessageBox.Show("产品规范描述:" + pscDesc + " 已经存在,请重新组合!", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
pscAdd.Add(pscList);
}
else
{
//验证产品规范描述是否重复
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkPSC", new Object[] { pscDesc, psc }, this.ob);
if (dt != null && dt.Rows.Count > 0)
{
MessageBox.Show("产品规范描述:" + pscDesc + " 已经存在,请重新组合!", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
pscList.Add(psc);
pscUpdate.Add(pscList);
}
}
}
//客户
ArrayList custerAdd = new ArrayList();
ArrayList custerUpdate = new ArrayList();
rows = GridHelper.GetRowsWithKey(ultraGrid3, new string[] { "CHC" }, new string[] { "True" });
if (rows.Length > 0)
{
foreach (UltraGridRow row in rows)
{
ArrayList custList = GetcustData(row);
if (custList == null)
{
MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
string stdCode = row.Cells["STD_CODE"].Value.ToString();
string custName = row.Cells["CUST_NAME"].Text.ToString();
//用于定位客户
_cust = custName;
string custCode = row.Cells["CUST_CODE"].Value.ToString();
if (row.Cells["CREATE_NAME"].Value.ToString().Equals(""))
{
UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid3, new string[] { "CUST_CODE" }, new string[] { custCode });
if (rows1.Length > 1)
{
MessageBox.Show("最终客户:" + custName + " 已经存在,请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
//验证最终客户是否重复
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkCust", new Object[] { custCode, stdCode }, this.ob);
if (dt != null && dt.Rows.Count > 0)
{
MessageBox.Show("最终客户:" + custName + " 已经存在,请重新选择!", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
custerAdd.Add(custList);
}
else
{
//验证最终客户是否重复
if (!custCode.Equals(row.Cells["OLD_CUST_CODE"].Value.ToString()))
{
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkCust1", new Object[] { custCode, stdCode }, this.ob);
if (dt != null && dt.Rows.Count > 0)
{
MessageBox.Show("最终客户:" + custName + " 已经存在,请重新选择!", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
custList.Add(stdCode);
custList.Add(custCode);
custerUpdate.Add(custList);
}
}
}
if (MessageBox.Show("是否保存记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
if (stdAdd.Count > 0 || pscAdd.Count > 0 || custerAdd.Count > 0 || stdUpdate.Count > 0 || pscUpdate.Count > 0 || custerUpdate.Count > 0)
{
int count = ServerHelper.SetData("com.steering.pss.qcm.CoreStandard1.saveCoreStandard1",
new Object[] { stdAdd, stdUpdate, pscAdd, pscUpdate, custerAdd, custerUpdate }, this.ob);
if (count > 0)
{
MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
DoQuery();
}
}
}
///
/// 作废与恢复
///
///
private void DoDeleteOrResume(Boolean flag)
{
if (isSelectData == -1)
{
MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
//标准基础
UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHC" }, new string[] { "True" });
ArrayList stdList = new ArrayList();
ArrayList pscList = new ArrayList();
ArrayList custList = new ArrayList();
if (rows.Length > 0)
{
foreach (UltraGridRow row in rows)
{
ArrayList std = new ArrayList();
//如果作废标准基础,就同时此标准基础下作废产品规范和客户
if (flag)
{
std.Add(UserInfo.GetUserName());
for (int i = 0; i < ultraGrid2.Rows.Count; i++)
{
ArrayList psc = new ArrayList();
psc.Add(UserInfo.GetUserName());
psc.Add(ultraGrid2.Rows[i].Cells["PSC"].Value.ToString());
pscList.Add(psc);
}
for (int i = 0; i < ultraGrid3.Rows.Count; i++)
{
ArrayList cust = new ArrayList();
cust.Add(UserInfo.GetUserName());
cust.Add(ultraGrid3.Rows[i].Cells["STD_CODE"].Value.ToString());
cust.Add(ultraGrid3.Rows[i].Cells["CUST_CODE"].Value.ToString());
custList.Add(cust);
}
}
else
std.Add("");
std.Add(row.Cells["STD_CODE"].Value.ToString());
stdList.Add(std);
//用于定位
_std = row.Cells["STD_NAME"].Value.ToString();
}
}
//产品规范
rows = GridHelper.GetRowsWithKey(ultraGrid2, new string[] { "CHC" }, new string[] { "True" });
if (rows.Length > 0)
{
foreach (UltraGridRow row in rows)
{
ArrayList psc = new ArrayList();
if (flag)
psc.Add(UserInfo.GetUserName());
else
psc.Add("");
psc.Add(row.Cells["PSC"].Value.ToString());
pscList.Add(psc);
//用于定位
_psc = row.Cells["PSC_DESC"].Value.ToString();
}
}
//最终客户
rows = GridHelper.GetRowsWithKey(ultraGrid3, new string[] { "CHC" }, new string[] { "True" });
if (rows.Length > 0)
{
foreach (UltraGridRow row in rows)
{
ArrayList cust = new ArrayList();
if (flag)
cust.Add(UserInfo.GetUserName());
else
{
//恢复客户,如果所对应的标准名称没有恢复,且不能恢复
string stdName = row.Cells["STD_NAME"].Value.ToString();
UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "STD_NAME" }, new string[] { stdName });
if (rows1.Length > 0 && rows1[0].Cells["VALIDFLAG"].Value.Equals("无效"))
{
MessageBox.Show("请先恢复标准名称:" + stdName, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
cust.Add("");
}
cust.Add(row.Cells["STD_CODE"].Value.ToString());
cust.Add(row.Cells["CUST_CODE"].Value.ToString());
custList.Add(cust);
_cust = row.Cells["CUST_NAME"].Value.ToString();
}
}
if (flag)
{
if (MessageBox.Show("是否作废记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
}
else
{
if (MessageBox.Show("是否恢复记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
}
if (stdList.Count > 0 || pscList.Count > 0 || custList.Count > 0)
{
int count = ServerHelper.SetData("com.steering.pss.qcm.CoreStandard1.deleteOrResume",
new Object[] { stdList, pscList, custList, flag }, this.ob);
if (count > 0)
{
if (flag)
MessageBox.Show("作废成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
MessageBox.Show("恢复成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
DoQuery();
}
}
}
///
/// 查询区
///
///
///
private void ChcStd_CheckedChanged(object sender, EventArgs e)
{
if (ChcStd.Checked)
TextStd.Enabled = true;
else
TextStd.Enabled = false;
}
///
/// 将ultraGrid2选择全部不勾选
///
///
private void changeUltraGirdChc(UltraGrid ug)
{
for (int i = 0; i < ug.Rows.Count; i++)
ug.Rows[i].Cells["CHC"].Value = false;
}
//--------------------------------ultraGrid1-------------------------------
///
/// 标准行增加
///
///
///
private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
{
//增加一行,自动获取最大的标准代码,然后加1
UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
int stdCode = 0;
DataRow[] rows = dataTable1.Select("", "STD_CODE DESC");
if (rows.Length > 0)
stdCode = Convert.ToInt32(rows[0]["STD_CODE"].ToString().Substring(3, 7));
ugr.Cells["STD_CODE"].Value = "STD" + string.Format("{0:0000000}", (stdCode + 1));
//增加行如果没有勾选则不可编辑
if (!Convert.ToBoolean(ugr.Cells["CHC"].Value))
{
for (int i = 0; i < ugr.Cells.Count; i++)
{
if (!ugr.Cells[i].Column.Key.Equals("CHC"))
ugr.Cells[i].Activation = Activation.ActivateOnly;
}
}
}
///
/// ultraGrid1
///
///
///
private void ultraGrid1_CellChange(object sender, CellEventArgs e)
{
ultraGrid1.UpdateData();
UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
if (e.Cell.Column.Key.Equals("STD_NAME")) //标准名称
{
for (int i = 0; i < ultraGrid2.Rows.Count; i++)
{ ultraGrid2.Rows[i].Cells["STD_NAME"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_NAME"].Value.ToString().Trim(); }
for (int i = 0; i < ultraGrid3.Rows.Count; i++)
{ ultraGrid3.Rows[i].Cells["STD_NAME"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_NAME"].Value.ToString().Trim(); }
}
if (e.Cell.Column.Key.Equals("STDSTYLE")) //标准类型
{
string stdstyle = ugr.Cells["STDSTYLE"].Text;
if (stdstyle.Equals("订货标准") || stdstyle.Equals("协议标准"))
{
ultraGrid2.Enabled = true;
changeUltraGirdChc(ultraGrid3);
ultraGrid3.Enabled = false;
if (stdstyle.Equals("订货标准"))
{
ugr.Cells["DEPARTMENT_DESC"].Value = "制造部";
ugr.Cells["DEPARTMENT_CODE"].Value = "141106165400";
ugr.Cells["UNIT_DESC"].Value = "标准科";
ugr.Cells["UNIT_CODE"].Value = "141223091224";
;
}
if (stdstyle.Equals("协议标准"))
{
ugr.Cells["DEPARTMENT_DESC"].Value = "制造部";
ugr.Cells["DEPARTMENT_CODE"].Value = "141106165400";
ugr.Cells["UNIT_DESC"].Value = "工艺科";
ugr.Cells["UNIT_CODE"].Value = "141106174134";
;
}
}
else if (stdstyle.Equals("Alpha"))
{
changeUltraGirdChc(ultraGrid2);
ultraGrid2.Enabled = false;
ultraGrid3.Enabled = true;
}
else
{
changeUltraGirdChc(ultraGrid2);
changeUltraGirdChc(ultraGrid3);
ultraGrid2.Enabled = false;
ultraGrid3.Enabled = false;
}
}
if (e.Cell.Column.Key.Equals("STD_STYLE")) //标准协会
{
ugr.Cells["STD_STYLE_NAME"].Value = ugr.Cells["STD_STYLE"].Text;
}
if (e.Cell.Column.Key.Equals("DEPARTMENT_CODE")) //部门管理
{
ugr.Cells["DEPARTMENT_DESC"].Value = ugr.Cells["DEPARTMENT_CODE"].Text;
ugr.Cells["UNIT_DESC"].Value = "";
ugr.Cells["UNIT_CODE"].Value = "";
}
if (e.Cell.Column.Key.Equals("UNIT_CODE")) //科室管理
{
ugr.Cells["UNIT_DESC"].Value = ugr.Cells["UNIT_CODE"].Value.ToString();
}
if (e.Cell.Column.Key.Equals("CHC"))//选择
{
Activation activation = Activation.ActivateOnly;
if (Convert.ToBoolean(e.Cell.Value))
{
activation = Activation.AllowEdit;
isSelectData += 1;
}
else
isSelectData -= 1;
CellsCollection cells = e.Cell.Row.Cells;
for (int i = 0; i < cells.Count; i++)
{
if (!cells[i].Column.Key.Equals("CHC") && !cells[i].Column.Key.Equals("STD_NAME"))
{
e.Cell.Row.Cells[i].Activation = activation;
}
}
if (!e.Cell.Row.Cells["CREATE_NAME"].Value.ToString().Equals(""))
{
if (ultraGrid2.Rows.Count > 0 || ultraGrid3.Rows.Count > 0)
e.Cell.Row.Cells["STD_NAME"].Activation = Activation.ActivateOnly;
else
e.Cell.Row.Cells["STD_NAME"].Activation = activation;
}
else
e.Cell.Row.Cells["STD_NAME"].Activation = activation;
}
}
///
/// ultraGrid1
///
///
///
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
{
BandDepartments(e);
if (e.Row.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
{
e.Row.Appearance.ForeColor = Color.Red;
}
else
{
e.Row.Appearance.ForeColor = Color.Black;
}
}
///
/// 行激活事件
///
///
///
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
if (this.CustomInfo == "2")
return;
ultraGrid2.Enabled = true;
ultraGrid3.Enabled = true;
ultraGrid2.UpdateData();
ultraGrid3.UpdateData();
UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
string stdName = ugr.Cells["STD_NAME"].Value.ToString();
_std = stdName;
string stdStyle = ugr.Cells["STDSTYLE"].Text.ToString();
//国标 产品规范码
if (stdStyle.Equals("订货标准") || stdStyle.Equals("协议标准"))
{
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.getComPsc", new Object[] { stdName }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable2, true);
//激活操作的行
UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGrid2, new string[] { "PSC_DESC" }, new string[] { _psc });
if (rows.Length > 0)
rows[0].Activate();
_psc = "";
UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"] };
GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, col);
dataTable3.Rows.Clear();
ultraGrid3.Enabled = false;
}
//Alpha 客户
else if (stdStyle.Equals("Alpha"))
{
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.getComBaseStdRCust", new Object[] { stdName }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable3, true);
//激活操作的行
UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid3, new string[] { "CUST_NAME" }, new string[] { _cust });
if (rows1.Length > 0)
rows1[0].Activate();
_cust = "";
//UltraGridColumn[] col1 = new UltraGridColumn[] { this.ultraGrid2.DisplayLayout.Bands[0].Columns["CHC"] };
GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid3, null);
dataTable2.Rows.Clear();
ultraGrid2.Enabled = false;
}
else
{
dataTable3.Rows.Clear();
dataTable2.Rows.Clear();
ultraGrid2.Enabled = false;
ultraGrid3.Enabled = false;
}
QcmBaseCommon.SetUltraGridNoEdit(ultraGrid2);
QcmBaseCommon.SetUltraGridNoEdit(ultraGrid3);
}
//--------------------------------ultraGrid2-------------------------
///
/// 行增加事件 ultraGrid2
///
///
///
private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
{
//增加一行,自动获取最大的最大产品规范码,然后加1
UltraGridRow ugr = ultraGrid2.DisplayLayout.ActiveRow;
int psc = 0;
DataRow[] rows = dataTable2.Select("", "PSC DESC");
if (rows.Length > 0)
psc = Convert.ToInt32(rows[0]["PSC"].ToString().Substring(4, 6));
ugr.Cells["PSC"].Value = "PSC" + string.Format("{0:0000000}", (psc + 1));
ugr.Cells["STD_NAME"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_NAME"].Value.ToString().Trim();
ugr.Cells["STD_CODE"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_CODE"].Value.ToString().Trim();
ugr.Cells["DEPARTMENT_DESC"].Value = UserInfo.GetDepartment();
ugr.Cells["DEPARTMENT_CODE"].Value = UserInfo.GetDeptid();
//增加行如果没有勾选则不可编辑
if (!Convert.ToBoolean(ugr.Cells["CHC"].Value))
{
for (int i = 0; i < ugr.Cells.Count; i++)
{
if (!ugr.Cells[i].Column.Key.Equals("CHC"))
ugr.Cells[i].Activation = Activation.ActivateOnly;
}
}
}
///
/// ultraGrid2值变化事件
///
///
///
private void ultraGrid2_CellChange(object sender, CellEventArgs e)
{
ultraGrid2.UpdateData();
UltraGridRow ugr = ultraGrid2.DisplayLayout.ActiveRow;
if (e.Cell.Column.Key.Equals("PRODUCCODE")) //品名描述
{
ugr.Cells["PRODUCNAME"].Value = ugr.Cells["PRODUCCODE"].Text;
}
if (e.Cell.Column.Key.Equals("STEELCODE")) //钢级(牌号)名称
{
ugr.Cells["STEELNAME"].Value = ugr.Cells["STEELCODE"].Text;
}
if (e.Cell.Column.Key.Equals("STD_STYLE")) //标准类别描述(PSL1....)
{
ugr.Cells["STD_STYLE_DESC"].Value = ugr.Cells["STD_STYLE"].Text;
}
//产品规范描述组成 =品名+标准类型+钢级+ 标准类别
ugr.Cells["PSC_DESC"].Value = ugr.Cells["PRODUCNAME"].Text + "," + ugr.Cells["STD_NAME"].Text + "," +
ugr.Cells["STEELNAME"].Text;
//标准类别
string stdStyleDesc = ugr.Cells["STD_STYLE_DESC"].Text;
if (stdStyleDesc != null && !stdStyleDesc.Equals(""))
ugr.Cells["PSC_DESC"].Value = ugr.Cells["PRODUCNAME"].Text + "," + ugr.Cells["STD_NAME"].Text + "," +
ugr.Cells["STEELNAME"].Text + "+" + ugr.Cells["STD_STYLE_DESC"].Text;
if (e.Cell.Column.Key.Equals("DEPARTMENT_CODE")) //部门管理
{
ugr.Cells["DEPARTMENT_DESC"].Value = ugr.Cells["DEPARTMENT_DESC"].Text;
//根据部门号查询管理科室
}
if (e.Cell.Column.Key.Equals("UNIT_CODE")) //科室管理
{
ugr.Cells["UNIT_DESC"].Value = ugr.Cells["UNIT_CODE"].Text;
}
if (e.Cell.Column.Key.Equals("CHC"))//选择
{
Activation activation = Activation.ActivateOnly;
if (Convert.ToBoolean(e.Cell.Value))
{
activation = Activation.AllowEdit;
isSelectData += 1;
}
else
isSelectData -= 1;
CellsCollection cells = e.Cell.Row.Cells;
for (int i = 0; i < cells.Count; i++)
{
if (!cells[i].Column.Key.Equals("CHC"))
{
e.Cell.Row.Cells[i].Activation = activation;
}
}
}
}
///
/// ultraGrid2
///
///
///
private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e)
{
BandDepartments(e);
if (e.Row.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
{
e.Row.Appearance.ForeColor = Color.Red;
}
else
{
e.Row.Appearance.ForeColor = Color.Black;
}
}
///
/// 获取标准类型数据
///
///
///
private ArrayList GetStdData(UltraGridRow ugr)
{
ArrayList list = new ArrayList();
string std_code = ugr.Cells["STD_CODE"].Value.ToString();
string std_name = ugr.Cells["STD_NAME"].Value.ToString().Trim();
if (std_name.Equals(""))
{
errMessage = "请输入标准名称";
return null;
}
string stdstyle = ugr.Cells["STDSTYLE"].Value.ToString();
string std_note = ugr.Cells["STD_NOTE"].Value.ToString();
string std_style = ugr.Cells["STD_STYLE"].Value.ToString();
string std_style_name = ugr.Cells["STD_STYLE_NAME"].Value.ToString();
string std_version = ugr.Cells["STD_VERSION"].Value.ToString();
string department_code = ugr.Cells["DEPARTMENT_CODE"].Value.ToString();
string department_desc = ugr.Cells["DEPARTMENT_DESC"].Value.ToString();
if (CustomInfo != "3" && department_desc.Equals(""))
{
errMessage = "请选择管理部门描述";
return null;
}
string unit_code = ugr.Cells["UNIT_CODE"].Value.ToString();
string unit_desc = ugr.Cells["UNIT_DESC"].Value.ToString();
if (CustomInfo != "3" && unit_desc.Equals(""))
{
errMessage = "请选择管理科室描述";
return null;
}
string userName = UserInfo.GetUserName();
string validflag = ugr.Cells["VALIDFLAG"].Value.ToString();
if (validflag.Equals("无效"))
{
errMessage = "无效记录不能保存";
return null;
}
string memo = ugr.Cells["MEMO"].Value.ToString();
list.Add(std_code);
list.Add(std_name);
list.Add(stdstyle);
list.Add(std_note);
list.Add(std_style);
list.Add(std_style_name);
list.Add(std_version);
list.Add(department_code);
list.Add(department_desc);
list.Add(unit_code);
list.Add(unit_desc);
list.Add(userName);
list.Add(memo);
return list;
}
///
/// 获取产品规范数据
///
///
///
private ArrayList GetPscData(UltraGridRow ugr)
{
ArrayList list = new ArrayList();
string psc = ugr.Cells["PSC"].Value.ToString();
string psc_desc = ugr.Cells["PSC_DESC"].Value.ToString();
string produccode = ugr.Cells["PRODUCCODE"].Value.ToString();
string producname = ugr.Cells["PRODUCNAME"].Value.ToString();
if (producname.Equals(""))
{
errMessage = "请选择品名描述";
return null;
}
string std_code = ugr.Cells["STD_CODE"].Value.ToString();
string std_name = ugr.Cells["STD_NAME"].Value.ToString();
string steelcode = ugr.Cells["STEELCODE"].Value.ToString();
string steelname = ugr.Cells["STEELNAME"].Value.ToString();
if (steelname.Equals(""))
{
errMessage = "请选择钢级牌号";
return null;
}
string std_style = ugr.Cells["STD_STYLE"].Value.ToString();
string std_style_desc = ugr.Cells["STD_STYLE_DESC"].Value.ToString();
string new_proc_code = ugr.Cells["NEW_PROC_CODE"].Value.ToString();
if (Convert.ToBoolean(new_proc_code))
new_proc_code = "1";
else
new_proc_code = "0";
string new_proc_desc = ugr.Cells["NEW_PROC_DESC"].Value.ToString();
string department_code = ugr.Cells["DEPARTMENT_CODE"].Value.ToString();
string department_desc = ugr.Cells["DEPARTMENT_DESC"].Value.ToString();
if (department_desc.Equals(""))
{
errMessage = "请选择管理部门描述";
return null;
}
string unit_code = ugr.Cells["UNIT_CODE"].Value.ToString();
string autojudge = ugr.Cells["AUTOJUDGE"].Value.ToString();
if (Convert.ToBoolean(autojudge))
autojudge = "1";
else
autojudge = "0";
string unit_desc = ugr.Cells["UNIT_DESC"].Value.ToString();
string userName = UserInfo.GetUserName();
string validflag = ugr.Cells["validflag"].Value.ToString();
if (validflag.Equals("无效"))
{
errMessage = "无效记录不能保存";
return null;
}
string memo = ugr.Cells["memo"].Value.ToString();
//list.Add(psc);
list.Add(psc_desc);
list.Add(produccode);
list.Add(producname);
list.Add(std_code);
list.Add(std_name);
list.Add(steelcode);
list.Add(steelname);
list.Add(std_style);
list.Add(std_style_desc);
list.Add(new_proc_code);
list.Add(new_proc_desc);
list.Add(department_code);
list.Add(department_desc);
list.Add(unit_code);
list.Add(autojudge);
list.Add(unit_desc);
list.Add(userName);
list.Add(memo);
return list;
}
///
/// 获取客户数据
///
///
///
private ArrayList GetcustData(UltraGridRow ugr)
{
ArrayList list = new ArrayList();
string std_code = ugr.Cells["STD_CODE"].Value.ToString();
string std_name = ugr.Cells["STD_NAME"].Value.ToString();
string cust_code = ugr.Cells["CUST_CODE"].Value.ToString();
string cust_name = ugr.Cells["CUST_NAME"].Value.ToString();
if (cust_name.Equals(""))
{
errMessage = "请选择最终客户";
}
string userName = UserInfo.GetUserName();
string validflag = ugr.Cells["VALIDFLAG"].Value.ToString();
if (validflag.Equals("无效"))
{
errMessage = "无效记录不能保存";
return null;
}
string memo = "";
list.Add(std_code);
list.Add(std_name);
list.Add(cust_code);
list.Add(cust_name);
list.Add(userName);
list.Add(memo);
return list;
}
//-----------------------------------------ultraGrid3
private void ultraGrid3_AfterRowInsert(object sender, RowEventArgs e)
{
UltraGridRow ugr = ultraGrid3.DisplayLayout.ActiveRow;
ugr.Cells["STD_NAME"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_NAME"].Value.ToString().Trim();
ugr.Cells["STD_CODE"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_CODE"].Value.ToString().Trim();
}
private void ultraGrid3_CellChange(object sender, CellEventArgs e)
{
ultraGrid3.UpdateData();
UltraGridRow ugr = ultraGrid3.DisplayLayout.ActiveRow;
if (e.Cell.Column.Key.Equals("CUST_CODE")) //客户
{
ugr.Cells["CUST_NAME"].Value = ugr.Cells["CUST_CODE"].Text;
}
if (e.Cell.Column.Key.Equals("CHC"))//选择
{
Activation activation = Activation.ActivateOnly;
if (Convert.ToBoolean(e.Cell.Value))
{
activation = Activation.AllowEdit;
isSelectData += 1;
}
else
isSelectData -= 1;
CellsCollection cells = e.Cell.Row.Cells;
for (int i = 0; i < cells.Count; i++)
{
if (!cells[i].Column.Key.Equals("CHC"))
{
e.Cell.Row.Cells[i].Activation = activation;
}
}
}
}
private void ultraGrid3_InitializeRow(object sender, InitializeRowEventArgs e)
{
if (e.Row.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
{
e.Row.Appearance.ForeColor = Color.Red;
}
else
{
e.Row.Appearance.ForeColor = Color.Black;
}
}
///
/// 伸缩
///
///
///
private void ultraExpandableGroupBox1_ExpandedStateChanged(object sender, EventArgs e)
{
if (ultraExpandableGroupBox1.Expanded)
splitContainer2.SplitterDistance = distance;
else
splitContainer2.SplitterDistance = this.Height;
}
private void FrmStandard1_Shown(object sender, EventArgs e)
{
distance = splitContainer2.SplitterDistance;
disWidth = splitContainer1.SplitterDistance; ;
}
private void ultraExpandableGroupBox2_ExpandedStateChanged(object sender, EventArgs e)
{
if (ultraExpandableGroupBox2.Expanded)
splitContainer1.SplitterDistance = disWidth;
else
splitContainer1.SplitterDistance = this.Width;
}
}
}