/*******************************************************************************
* Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PP_0202.cs
* 2.功能描述:月计划新建
* 编辑履历:
* 作者 日期 版本 修改内容
* 徐伟 2019/08/27 1.00 新建
*******************************************************************************/
using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.Client.Controls;
using Dongke.IBOSS.PRD.Client.DataModels;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
namespace Dongke.IBOSS.PRD.Client.PPModule
{
///
/// 月计划窗体
///
public partial class F_PP_0202 : DKDockPanelBase
{
#region 单例模式 防止窗体被重复创建
private static F_PP_0202 _instance = null;
public static F_PP_0202 Instance
{
get
{
if (_instance == null)
{
_instance = new F_PP_0202();
}
return _instance;
}
}
private void F_PP_0202_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
#endregion
#region 构造函数
///
/// 月计划窗体
///
public F_PP_0202()
{
InitializeComponent();
//this.Text = "月计划";
}
#endregion
//月计划id,0:插入操作,>0更新操作
public int planId = 0;
///
/// 画面加载
///
///
///
private void F_PP_0202_Load(object sender, System.EventArgs e)
{
try
{
// 加载权限
FormPermissionManager.FormPermissionControl(this.Name, this,
LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
private void BtnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void BtnSave_Click(object sender, EventArgs e)
{
PlanMonthUpdate();
this.Close();
}
//更新操作
private void PlanMonthUpdate()
{
//月计划 插入
ClientRequestEntity cre = new ClientRequestEntity();
//用户填写的数据
cre.Properties["YEARNO"] = Convert.ToInt32(planYearNo.Text);
cre.Properties["MONTHNO"] = planMonthNo.Text.Trim().PadLeft(2, '0');
cre.Properties["PLANNAME"] = planName.Text;
cre.Properties["PLANTYPEID"] = Convert.ToInt32(planType.SelectedValue);
cre.Properties["REMARKS"] = planRemarks.Text;
//自动填写的数据
cre.Properties["STARTDATE"] = Convert.ToDateTime($"{planYearNo.Text}-{planMonthNo.Value.ToString()}-01");
cre.Properties["ENDDATE"] = Convert.ToDateTime($"{planYearNo.Text}-{planMonthNo.Value.ToString()}-1").AddMonths(1).AddDays(-1);
cre.Properties["UPDATETIME"] = DateTime.Now;
cre.Properties["UPDATEUSERID"] = LogInUserInfo.CurrentUser.CurrentUserEntity.UserID;
ServiceResultEntity result;
if (planId == 0)
{
//新建专属的列
cre.Properties["PLANVER"] = PPModuleProxy.Service.PlanMonthVer(Convert.ToInt32(planType.SelectedValue));
cre.Properties["ACCOUNTID"] = LogInUserInfo.CurrentUser.CurrentUserEntity.AccountID;
cre.Properties["CREATETIME"] = DateTime.Now;
cre.Properties["CREATEUSERID"] = LogInUserInfo.CurrentUser.CurrentUserEntity.UserID;
result = PPModuleProxy.Service.PlanMonthInsert(cre);
}
else
{
//更新时主键要指定值
cre.Properties["PLANID"] = planId;
result = PPModuleProxy.Service.PlanMonthUpdate(cre);
}
}
}
}