| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- /*******************************************************************************
- * Copyright(c) 2017 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_2302.cs
- * 2.功能描述:生产订单新建/编辑界面
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2017/02/07 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.DataModels;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- public partial class F_PM_2302 : FormBase
- {
- #region 成员变量
- // 存储窗口的编辑状态
- private Constant.FormMode _editStatus;
- // 修改生产订单时存储上个窗口传过来的ID
- private int _orderID;
- private OrderEntity _orderEntity = new OrderEntity();
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_PM_2302()
- : this(Constant.FormMode.Add)
- {
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_PM_2302(Constant.FormMode editStatus)
- : this(editStatus, 0)
- {
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_PM_2302(Constant.FormMode editStatus, int orderID)
- {
- InitializeComponent();
- this._editStatus = editStatus;
- // 根据新建、编辑状态为标题赋值
- if (editStatus == Constant.FormMode.Add)
- {
- this.Text = FormTitles.F_PM_2302_ADD;
- }
- else
- {
- this.Text = FormTitles.F_PM_2302_EDIT;
- // 存储上个窗口传过来的生产订单ID
- this._orderID = orderID;
- }
- // 按钮文本
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 关闭按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 保存按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- // 验证信息是否完整
- bool validResult = IsValidData();
- if (validResult)
- {
- this.btnSave.Enabled = false;
- this.btnCancel.Enabled = false;
- ServiceResultEntity result = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(this.SaveOrder));//保存按钮方法
- this.btnSave.Enabled = true;
- this.btnCancel.Enabled = true;
- if (Convert.ToInt32(result.Result) > Constant.INT_IS_ZERO)//保存成功
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "生产订单", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- //this._organizationIDList.Add(Convert.ToInt32(result));
- this.DialogResult = DialogResult.OK;
- }
- else if (Convert.ToInt32(result.Result)==-1)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, result.Message),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (this._editStatus == Constant.FormMode.Edit)
- {
- this.Close();
- }
- else
- {
- // 重置窗口数据
- this.ResetFormData();
- }
- }
- }
- catch (Exception ex)
- {
- this.btnSave.Enabled = true;
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 获取组织机构结果集
- /// </summary>
- /// <returns></returns>
- private DataSet GetOrganizationDataSource()
- {
- try
- {
- OrganizationEntity organization = new OrganizationEntity();
- //// 票号开头字母
- //organization.LetterMarket = this.LetterMarket.Text.Trim();
- //// 联系电话
- //organization.Telephone = this.txtTelephone.Text.Trim();
- //// 地址
- //organization.Address = this.txtAddress.Text;
- //// 备注
- //organization.Remarks = this.txtRemarks.Text;
- //// 正常标识
- //organization.ValueFlags = null;
- //organization.in_UserID = LogInUserInfo.CurrentUser.CurrentUserEntity.UserID;
- //organization.in_AccountID = LogInUserInfo.CurrentUser.CurrentUserEntity.AccountID;
- //this._organization = organization;
- return SystemModuleProxy.Service.SelectOrganizationData(organization);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PM_2302_Load(object sender, EventArgs e)
- {
- try
- {
- this.dtpOrderDateFrom.Value = DateTime.Now.Date;
- // 若状态是添加,则有效标志为可用并且不显示
- if (this._editStatus == Constant.FormMode.Edit)
- {
- this.SetOrganizationData();
- }
- this.txtOrderNo.Focus();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 为窗体各个控赋值
- /// </summary>
- private void SetOrganizationData()
- {
- try
- {
- // 获取生产订单信息
- this._orderEntity = new OrderEntity();
- this._orderEntity.OrderID = this._orderID;
- DataSet result = (DataSet)DoAsync(new BaseAsyncMethod(this.GetOrderList));
- if (result != null && result.Tables.Count > Constant.INT_IS_ZERO && result.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- DataRow orderRow = result.Tables[0].Rows[0];
- // 生产号
- this.txtOrderNo.Text = orderRow["OrderNo"].ToString();
- // 订单日期
- this.dtpOrderDateFrom.Value = Convert.ToDateTime(orderRow["OrderDate"]);
- // 备注
- this.txtRemarks.Text = orderRow["Remarks"].ToString();
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 获取生产订单数据
- /// </summary>
- /// <returns></returns>
- private DataSet GetOrderList()
- {
- try
- {
- return PMModuleProxy.Service.GetOrderList(this._orderEntity);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 验证输入是否完整
- /// </summary>
- /// <returns></returns>
- private bool IsValidData()
- {
- try
- {
- // 订单号不能为空
- if (string.IsNullOrEmpty(this.txtOrderNo.Text.Trim()))
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "订单号"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtOrderNo.Focus();
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 保存组织机构
- /// </summary>
- /// <returns>影响的行数</returns>
- private ServiceResultEntity SaveOrder()
- {
- try
- {
- OrderEntity order = GetOrderEntity();
- return PMModuleProxy.Service.SaveOrder(order);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 给订单体类传值
- /// </summary>
- /// <returns></returns>
- private OrderEntity GetOrderEntity()
- {
- OrderEntity order = new OrderEntity();
- // 生产订单ID
- order.OrderID = this._orderID;
- // 生产订单号
- order.OrderNo = this.txtOrderNo.Text.Trim();
- // 生产订单日期
- order.OrderDate = this.dtpOrderDateFrom.Value;
- // 备注
- order.Remarks = this.txtRemarks.Text.Trim();
- order.ValueFlag = 1;
- return order;
- }
- /// <summary>
- /// 重置窗口数据
- /// </summary>
- private void ResetFormData()
- {
- this._orderID = Constant.INT_IS_ZERO;
- this.txtOrderNo.Text = string.Empty;
- this.dtpOrderDateFrom.Value = DateTime.Now;
- this.txtRemarks.Text = string.Empty;
- this.txtOrderNo.Focus();
- }
- #endregion
- }
- }
|