/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PC_0104.cs
* 2.功能描述:成型线管理
* 编辑履历:
* 作者 日期 版本 修改内容
* 庄天威 2014/09/28 1.00 新建
*******************************************************************************/
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Basics.DockPanel;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
using Dongke.IBOSS.PRD.WCF.Proxys.PCModuleService;
namespace Dongke.IBOSS.PRD.Client.PCModule
{
///
/// 成型线管理
///
public partial class F_PC_0104 : DockPanelBase
{
#region 成员变量
// 单例模式使用
private static F_PC_0104 _instance;
// 成型线集合
private List _groutingLineList = new List();
//选择的成型线状态
private int? _mouldStatus;
#endregion
#region 构造函数
///
/// 构造函数
///
public F_PC_0104()
{
InitializeComponent();
// 为控件名赋值
this.btnSearch.Text = ButtonText.BTN_SEARCH;
this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
this.tsbtnQueryRecord.Text = ButtonText.TSBTN_QUERYRECORD;
this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
this.Text = FormTitles.F_PC_0104;
}
#endregion
#region 单例模式
///
/// 单例模式,防止重复创建窗体
///
public static F_PC_0104 Instance
{
get
{
if (_instance == null)
{
_instance = new F_PC_0104();
}
return _instance;
}
}
#endregion
#region 事件处理
///
/// 页面加载事件
///
///
///
private void F_PC_0104_Load(object sender, System.EventArgs e)
{
try
{
// 加载权限
FormPermissionManager.FormPermissionControl(this.Name, this,
Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
// 为成型线绑定数据源
this.BindMouldType();
// 设置日期控件不可用
this.SetBeginTimePickerEnable(false);
this.SetEndTimePickerEnable(false);
this.chkValueFlag.AllItemCheck();
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 自动列宽按钮按下处理
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvGroutingLine.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
this.dgvGroutingLineDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 开始日期条件选中状态改变处理事件
///
///
///
private void cbStartTime_CheckedChanged(object sender, EventArgs e)
{
this.SetBeginTimePickerEnable(this.cbStartTime.Checked);
}
///
/// 结束日期条件选中状态改变处理事件
///
///
///
private void cbEndTime_CheckedChanged(object sender, EventArgs e)
{
this.SetEndTimePickerEnable(this.cbEndTime.Checked);
}
///
/// 查询按钮按下处理
///
///
///
private void btnSearch_Click(object sender, EventArgs e)
{
try
{
this.dgvGroutingLine.DataSource = null;
this.dgvGroutingLineDetail.DataSource = null;
this._mouldStatus = this.lstcbxGMouldStatus.SelectedValue == null
? null : (int?)Convert.ToInt32(this.lstcbxGMouldStatus.SelectedValue);
DataSet dsGroutingLine = (DataSet)DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(() =>
{
return GetGroutingLine();
}));
if (dsGroutingLine != null)
{
this.DataTableToListByLine(dsGroutingLine);
if (dsGroutingLine.Tables.Count != Constant.INT_IS_ZERO)
{
this.dgvGroutingLine.DataSource = ((DataSet)dsGroutingLine).Tables[0];
this.dgvGroutingLine.ReadOnly = true;
if (this.dgvGroutingLine.Rows.Count == Constant.INT_IS_ZERO)
{
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
this.dgvGroutingLineDetail.DataSource = null;
}
else
{
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 清空查询条件处理
///
///
///
private void btnClearCondition_Click(object sender, EventArgs e)
{
this.txtBuildingNo.Text = "";
this.txtFloorNo.Text = "";
this.txtGroutingLineNo.Text = "";
this.lstcbxGMouldStatus.Text = "";
this.lstcbxGMouldStatus.SelectedValue = "";
this.txtGroutingLineCode.Text = "";
this.txtGroutingLineName.Text = "";
this.cbStartTime.Checked = false;
this.cbEndTime.Checked = false;
this.txtBeginUsedDateStart.Enabled = false;
this.txtBeginUsedDateEnd.Enabled = false;
this.txtEndUsedDateStart.Enabled = false;
this.txtEndUsedDateEnd.Enabled = false;
this.txtRemarks.Text = "";
this.txtGroutingUserCode.Text = "";
this.chkValueFlag.AllItemCheck();
}
///
/// 窗体关闭事件处理
///
///
///
private void tsbtnClose_Click(object sender, System.EventArgs e)
{
this.Close();
}
///
/// 窗体关闭后,释放单例模式
///
///
///
private void F_PC_0104_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
{
_instance = null;
}
///
/// 双击某成型线进行编辑
///
///
///
private void dgvGroutingLine_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
try
{
if (e.RowIndex == -Constant.INT_IS_ONE || e.ColumnIndex == -Constant.INT_IS_ONE)
{
return;
}
DataGridViewRow currentRow = this.dgvGroutingLine.CurrentRow;
int GroutingLineId = Convert.ToInt32(currentRow.Cells["GroutingLineId"].Value);
F_PC_0103 frmFPC0103 = new F_PC_0103(GroutingLineId);
DialogResult dialogresult = frmFPC0103.ShowDialog();
if (dialogresult.Equals(DialogResult.OK))
{
this.dgvGroutingLine.DataSource = null;
object obResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(GetGroutingLine));
if (obResult != null)
{
DataSet dsGroutingLine = (DataSet)obResult;
if (dsGroutingLine.Tables.Count != Constant.INT_IS_ZERO)
{
this.dgvGroutingLine.DataSource = dsGroutingLine.Tables[0];
this.dgvGroutingLine.ReadOnly = true;
}
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 添加新成型线
///
///
///
private void tsbtnAdd_Click(object sender, EventArgs e)
{
try
{
F_PC_0102 frmFPC0102 = new F_PC_0102();
DialogResult dialogresult = frmFPC0102.ShowDialog();
if (dialogresult.Equals(DialogResult.OK))
{
this.dgvGroutingLine.DataSource = null;
DataSet dsGroutingLine = (DataSet)DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(() =>
{
return GetGroutingLine();
}));
if (dsGroutingLine != null)
{
if (dsGroutingLine.Tables.Count != Constant.INT_IS_ZERO)
{
this.dgvGroutingLine.DataSource = ((DataSet)dsGroutingLine).Tables[0];
this.dgvGroutingLine.ReadOnly = true;
}
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 编辑选中成型线
///
///
///
private void tsbtnEdit_Click(object sender, EventArgs e)
{
try
{
DataGridViewRow currentRow = this.dgvGroutingLine.CurrentRow;
if (currentRow != null)
{
int GroutingLineId = Convert.ToInt32(currentRow.Cells["GroutingLineId"].Value);
F_PC_0103 frmFPC0103 = new F_PC_0103(GroutingLineId);
DialogResult dialogresult = frmFPC0103.ShowDialog();
if (dialogresult.Equals(DialogResult.OK))
{
this.dgvGroutingLine.DataSource = null;
object obResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(GetGroutingLine));
if (obResult != null)
{
DataSet dsGroutingLine = (DataSet)obResult;
if (dsGroutingLine.Tables.Count != Constant.INT_IS_ZERO)
{
this.dgvGroutingLine.DataSource = dsGroutingLine.Tables[0];
this.dgvGroutingLine.ReadOnly = true;
}
}
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 选择某成型线查看模具明细
///
///
///
private void dgvGroutingLine_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
try
{
if (e.RowIndex == -Constant.INT_IS_ONE || e.ColumnIndex == -Constant.INT_IS_ONE)
{
return;
}
int GroutingLineID = Convert.ToInt32(this.dgvGroutingLine.Rows[e.RowIndex].Cells["GroutingLineID"].Value);
this.BindDetailInfo(GroutingLineID);
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 打开履历查询界面
///
///
///
private void tsbtnQueryRecord_Click(object sender, EventArgs e)
{
try
{
F_PC_0105 frmFPC0105 = new F_PC_0105();
DialogResult dialogresult = frmFPC0105.ShowDialog();
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 成型线列头点击事件
///
///
///
private void dgvGroutingLine_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
try
{
if (this.dgvGroutingLine.SelectedRows.Count != Constant.INT_IS_ZERO)
{
int GroutingLineID = Convert.ToInt32(this.dgvGroutingLine.SelectedRows[0].Cells["GroutingLineID"].Value);
this.BindDetailInfo(GroutingLineID);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
#region 私有方法
///
/// 为页面的成型线类型绑定数据源
///
private void BindMouldType()
{
try
{
DataTable dtDataSourse = new DataTable();
dtDataSourse.Columns.Add("GMouldType", System.Type.GetType("System.String"));
dtDataSourse.Columns.Add("GMouldTypeName", System.Type.GetType("System.String"));
for (int i = 0; i < Constant.ConGMouldStatusCount; i++)
{
DataRow drRow = dtDataSourse.NewRow();
drRow["GMouldType"] = Constant.ConGMouldStatus[i, 0];
drRow["GMouldTypeName"] = Constant.ConGMouldStatus[i, 1];
dtDataSourse.Rows.Add(drRow);
}
this.lstcbxGMouldStatus.ListBox.DisplayMember = "GMouldTypeName";
this.lstcbxGMouldStatus.ListBox.ValueMember = "GMouldType";
this.lstcbxGMouldStatus.ListBox.DataSource = dtDataSourse;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 设置开始使用时间可用状态
///
///
/// false:不可用
/// true:可用
///
private void SetBeginTimePickerEnable(bool isEnable)
{
this.txtBeginUsedDateStart.Enabled = isEnable;
this.txtBeginUsedDateEnd.Enabled = isEnable;
}
///
/// 设置结束使用时间可用状态
///
///
/// false:不可用
/// true:可用
///
private void SetEndTimePickerEnable(bool isEnable)
{
this.txtEndUsedDateStart.Enabled = isEnable;
this.txtEndUsedDateEnd.Enabled = isEnable;
}
///
/// 根据条件取得成型线数据
///
///
private DataSet GetGroutingLine()
{
try
{
this.dgvGroutingLine.AutoGenerateColumns = false;
GroutingLineEntity groutingLineEntity = new GroutingLineEntity();
groutingLineEntity.VALUEFLAG = null;
groutingLineEntity.BUILDINGNO = this.txtBuildingNo.Text.Trim();
groutingLineEntity.FLOORNO = this.txtFloorNo.Text.Trim();
groutingLineEntity.GROUTINGLINENO = this.txtGroutingLineNo.Text.Trim();
if (_mouldStatus != null)
{
groutingLineEntity.MouldStatus = _mouldStatus;
}
groutingLineEntity.GROUTINGLINECODE = this.txtGroutingLineCode.Text.Trim();
groutingLineEntity.GROUTINGLINENAME = this.txtGroutingLineName.Text.Trim();
if (this.cbStartTime.Checked)
{
groutingLineEntity.BEGINUSEDDATE = Convert.ToDateTime(this.txtBeginUsedDateStart.Text.Trim());
groutingLineEntity.BEGINUSEDDATEEND = Convert.ToDateTime(this.txtBeginUsedDateEnd.Text.Trim()).AddHours(23)
.AddMinutes(59).AddSeconds(59);
}
if (this.cbEndTime.Checked)
{
groutingLineEntity.ENDUSEDDATE = Convert.ToDateTime(this.txtEndUsedDateStart.Text.Trim());
groutingLineEntity.ENDUSEDDATEEND = Convert.ToDateTime(this.txtEndUsedDateEnd.Text.Trim()).AddHours(23)
.AddMinutes(59).AddSeconds(59);
}
groutingLineEntity.REMARKS = this.txtRemarks.Text.Trim();
if (this.mtType.MouldTypeID != null)
{
groutingLineEntity.MOULDTYPEID = this.mtType.MouldTypeID;
}
object[] objListValue = chkValueFlag.SelectedValues;
if (objListValue.Length == Constant.INT_IS_ONE)
{
groutingLineEntity.VALUEFLAG = (int)objListValue[0];
}
else if (objListValue.Length == Constant.INT_IS_ZERO)
{
return null;
}
groutingLineEntity.USERCODE = this.txtGroutingUserCode.Text.Trim();
return PCModuleProxy.Service.GetGroutingLine(groutingLineEntity);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 将成型线DataSet数据集转入集合中
///
///
private void DataTableToListByLine(DataSet dsLine)
{
try
{
this._groutingLineList.Clear();
foreach (DataRow drFor in dsLine.Tables[0].Rows)
{
GroutingLineEntity lineEntity = new GroutingLineEntity();
lineEntity.GROUTINGLINEID = Convert.ToInt32(drFor["GROUTINGLINEID"]);
lineEntity.BUILDINGNO = drFor["BUILDINGNO"].ToString();
lineEntity.FLOORNO = drFor["FLOORNO"].ToString();
lineEntity.GROUTINGLINENO = drFor["GROUTINGLINENO"].ToString();
lineEntity.GROUTINGLINECODE = drFor["GROUTINGLINECODE"].ToString();
lineEntity.GROUTINGLINENAME = drFor["GROUTINGLINENAME"].ToString();
lineEntity.MOULDQUANTITY = Convert.ToDecimal(drFor["MOULDQUANTITY"]);
lineEntity.MOULDTYPEID = Convert.ToInt32(drFor["GMOULDTYPEID"]);
lineEntity.USERID = Convert.ToInt32(drFor["USERID"]);
lineEntity.BEGINUSEDDATE = Convert.ToDateTime(drFor["BEGINUSEDDATE"]);
if (drFor["ENDUSEDDATE"].ToString() != string.Empty)
{
lineEntity.ENDUSEDDATE = Convert.ToDateTime(drFor["ENDUSEDDATE"].ToString());
}
lineEntity.MouldStatus = Convert.ToInt32(drFor["GMouldStatus"]);
lineEntity.REMARKS = drFor["REMARKS"].ToString();
lineEntity.ACCOUNTID = Convert.ToInt32(drFor["ACCOUNTID"]);
lineEntity.VALUEFLAG = Convert.ToInt32(drFor["VALUEFLAG"]);
lineEntity.CREATETIME = Convert.ToDateTime(drFor["CREATETIME"]);
lineEntity.CREATEUSERID = Convert.ToInt32(drFor["CREATEUSERID"]);
lineEntity.UPDATETIME = Convert.ToDateTime(drFor["UPDATETIME"]);
lineEntity.UPDATEUSERID = Convert.ToInt32(drFor["UPDATEUSERID"]);
lineEntity.OPTIMESTAMP = Convert.ToDateTime(drFor["OPTIMESTAMP"]);
lineEntity.MOULDTYPENAME = drFor["GMOULDTYPENAME"].ToString();
this._groutingLineList.Add(lineEntity);
}
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 根据成型线ID获取明细信息
///
private void BindDetailInfo(int GroutingLineID)
{
try
{
this.dgvGroutingLineDetail.AutoGenerateColumns = false;
DataSet dsDetail = (DataSet)DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(() =>
{
return PCModuleProxy.Service.GetGroutingLineDetailByMainId(GroutingLineID, null, 0);
}));
this.dgvGroutingLineDetail.DataSource = dsDetail.Tables[0];
this.dgvGroutingLineDetail.ReadOnly = true;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}