using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
using DBUtility;
|
|
namespace APSM
|
{
|
public partial class Gy_WorkTimes : Form
|
{
|
private int HItemIDCol = 0;
|
private int HNumberCol = 0;
|
private DateTime BDate;
|
private DateTime EDate;
|
private DateTime XQDate;
|
public DBUtility.frm_B_BillQueryCondition_New frmCondition;
|
public const string ViewName = "h_v_Gy_WorkTimesList";
|
//public string CheckProcName = "h_p_Gy_WorkTimes"; //20141020
|
public string ModName = "资源能力";
|
public const string BillName = "Gy_WorkTimes";
|
public const string ModRightNameEdit = BillName + "_Edit";
|
public const string ModRightNameDelete = BillName + "_Delete";
|
public DBUtility.ClsPub.Enum_InputMode InputMode; //录入状态标志(0-非录入状态 1-增加 2-修改)
|
public long HItemID;//项目ID
|
public long HSourceID;//资源ID
|
DAL.ClsGy_PlanShifts_Ctl oPs = new DAL.ClsGy_PlanShifts_Ctl();
|
DAL.ClsGy_PlanShifts_View oPsHlp = new DAL.ClsGy_PlanShifts_View();
|
TreeNode CurNode = new TreeNode();
|
|
public Gy_WorkTimes()
|
{
|
InitializeComponent();
|
}
|
#region 固定代码
|
//保存GRID列宽
|
|
//窗体加载
|
private void Gy_WorkTimes_Load(object sender, EventArgs e)
|
{
|
cmbYear.SelectedIndex = 1;
|
frmCondition = new DBUtility.frm_B_BillQueryCondition_New();
|
LoadTree();
|
initGrid();
|
RefreshTool();
|
}
|
//加载子结点
|
private void LoadAllNodes(TreeNode sNode)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
if (sNode != null)
|
{
|
try
|
{
|
long sName = Convert.ToInt64(sNode.Name.Substring(1, sNode.Name.Length - 1));
|
sNode.Nodes.Clear();
|
string sSQL = "";
|
if (HSourceID == 0)
|
{
|
sSQL = "select hitemid,hnumber,hname from Gy_Source where HParentID='" + sName + "' order by Hnumber";
|
}
|
else
|
{
|
sSQL = "select hitemid,hnumber,hname from Gy_Source where HItemID=" + HSourceID + " order by Hnumber";
|
}
|
DataSet Ds = oCn.RunProcReturn(sSQL, "Gy_Source", ref ClsPub.sExeReturnInfo);
|
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
|
{
|
TreeNode oNode = sNode.Nodes.Add("T" + Ds.Tables[0].Rows[i]["HItemID"].ToString(), Ds.Tables[0].Rows[i]["HNumber"].ToString() + "-" + Ds.Tables[0].Rows[i]["HName"].ToString(), 0, 1);
|
}
|
sNode.Expand();
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("加载子项目失败!" + e.Message, "提示");
|
}
|
}
|
}
|
//加载树形
|
private void LoadTree()
|
{
|
try
|
{
|
tv.Nodes.Clear();
|
tv.ImageList = imageList1;
|
TreeNode sNode = tv.Nodes.Add("T0", "生产资源", 0, 1);
|
LoadAllNodes(sNode);
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("加载树型失败!" + e.Message, "提示");
|
}
|
}
|
//树型 单击
|
private void tv_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
{
|
CurNode = e.Node;
|
if (CurNode != null)
|
{
|
if (CurNode.Nodes.Count == 0 && HSourceID == 0)
|
LoadAllNodes(CurNode);
|
Display();
|
}
|
}
|
//初始化GRID
|
private void initGrid()
|
{
|
Sc_ICMOSortBillFun.initGridVS_Times(grdMain, ref BDate, ref EDate, this.Name, ref XQDate, cmbYear);
|
}
|
//显示列表
|
private void Display()
|
{
|
DataSet DSet ;
|
DateTime Date;
|
Int64 sName;
|
////禁用 红色显示 20141020
|
//Sub_ShowStopFlag();
|
//得到工作中心默认上班时间
|
sName = Convert.ToInt64(CurNode.Name.Substring(1, CurNode.Name.Length - 1));
|
Single sWorkTimes = 0;
|
sWorkTimes = oPsHlp.GetInfoBySource_Line(sName); //根据资源得到工作中心的工时
|
//
|
for (int r = 0; r <= 22; r = r + 2)
|
{
|
BDate =DBUtility.ClsPub.isDate(cmbYear.Text.ToString() + "-" + Convert.ToString(r / 2 + 1) + "-01");
|
EDate = BDate.AddMonths(1);
|
EDate = EDate.AddDays(-1);
|
|
TimeSpan t = EDate - BDate;//获取2个时间的相隔天数
|
//
|
for (int c = 1; c <= DBUtility.ClsPub.isInt(t.Days + 1); c++)
|
{
|
if (DBUtility.ClsPub.isStrNull(CurNode.Name) != null && DBUtility.ClsPub.isStrNull(CurNode.Text) != "")
|
{
|
Date = DBUtility.ClsPub.isDate(cmbYear.Text.ToString() + "-" + Convert.ToString(r / 2 + 1) + "-" + grdMain.get_TextMatrix(r, c).ToString());
|
if (oPsHlp.GetInfoByDate_Line(sName, Date.ToShortDateString()))
|
{
|
grdMain.set_TextMatrix(r + 1, c,DBUtility.ClsPub.isDoule(oPsHlp.omodel.HOverTimes, 1));
|
}
|
else
|
{
|
grdMain.set_TextMatrix(r + 1, c, sWorkTimes.ToString());
|
}
|
}
|
}
|
}
|
}
|
//退出模块
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
//刷新
|
private void xs_Click(object sender, EventArgs e)
|
{
|
Display();
|
}
|
//刷新TOOLBAR
|
private void RefreshTool()
|
{
|
if (InputMode == DBUtility.ClsPub.Enum_InputMode.InputMode_View)
|
{
|
stTab.SelectedIndex = 0;
|
stTab.TabPages.Remove(this.tabPage1);
|
stTab.TabPages.Add(this.tabPage1);
|
grdMain.Enabled = true;
|
tc.Enabled = true;
|
tz.Enabled = true;
|
xs.Enabled = true;
|
}
|
else
|
{
|
stTab.SelectedIndex = 1;
|
stTab.TabPages.Remove(this.tabPage1);
|
stTab.TabPages[0].Hide();
|
grdMain.Enabled = false;
|
tc.Enabled = true;
|
tz.Enabled = false;
|
xs.Enabled = false;
|
}
|
}
|
//取消按钮
|
private void cmdCancel_Click(object sender, EventArgs e)
|
{
|
InputMode = DBUtility.ClsPub.Enum_InputMode.InputMode_View;
|
RefreshTool();
|
}
|
//得到对应列
|
private Int32 Fun_GetCol(string sCol)
|
{
|
return Sc_ICMOSortBillFun.Fun_GetCol_VS(sCol, grdMain);
|
}
|
private void bclk_Click(object sender, EventArgs e)
|
{
|
//保存列宽
|
Sc_ICMOSortBillFun.SaveGrid(grdMain, this.Name, DBUtility.ClsPub.AppPath);
|
}
|
|
private void mrlk_Click(object sender, EventArgs e)
|
{
|
grdMain.AutoSize(0, grdMain.Cols - 1, false, 1);
|
//参数解释 开始列 ,结束列,是否以最大列宽为准,最小列宽
|
Sc_ICMOSortBillFun.SaveGrid(grdMain, this.Name, DBUtility.ClsPub.AppPath);
|
}
|
//选中行是否正常
|
private bool AllowRow()
|
{
|
if (grdMain.Row >= grdMain.FixedRows && grdMain.Row <= grdMain.Rows - 1)
|
return true;
|
else
|
return false;
|
}
|
|
|
//时间控件
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
timer1.Enabled = false;
|
cmbYear.Items.Add(DateTime.Today.Year - 5);
|
cmbYear.Items.Add(DateTime.Today.Year - 4);
|
cmbYear.Items.Add(DateTime.Today.Year - 3);
|
cmbYear.Items.Add(DateTime.Today.Year - 2);
|
cmbYear.Items.Add(DateTime.Today.Year - 1);
|
cmbYear.Items.Add(DateTime.Today.Year);
|
cmbYear.Items.Add(DateTime.Today.Year + 1);
|
cmbYear.Items.Add(DateTime.Today.Year + 2);
|
cmbYear.Items.Add(DateTime.Today.Year + 3);
|
cmbYear.Items.Add(DateTime.Today.Year + 4);
|
cmbYear.Items.Add(DateTime.Today.Year + 5);
|
cmbYear.SelectedIndex = 5;
|
LoadTree();
|
initGrid();
|
}
|
|
#endregion
|
|
|
#region 类的读写
|
//读取类 到 控件
|
private void ShowData(long sItemID)
|
{
|
//
|
}
|
|
//写入类 从控件
|
private bool WriteClass(double sWorktimes,Int64 sSourceID,DateTime sDate)
|
{
|
oPs.oModel.HOverTimes = sWorktimes;
|
oPs.oModel.HRemark = "";
|
oPs.oModel.HShiftsID = 0;
|
oPs.oModel.HSourceID= sSourceID;
|
oPs.oModel.HDate = sDate;
|
return true;
|
}
|
#endregion
|
|
|
#region 界面控件处理
|
|
#endregion
|
|
////检测按钮 20141020
|
//private void jc_Click(object sender, EventArgs e)
|
//{
|
// BLL.ClsPub_BLL.Sub_CheckUseStatus(grdMain, HItemIDCol, CheckProcName);
|
// Display();
|
//}
|
|
|
////禁用项目 红色字体 20141020
|
//public void Sub_ShowStopFlag()
|
//{
|
// BLL.ClsPub_BLL.Sub_ShowStopFlag(grdMain, Fun_GetCol("禁用标记"));
|
//}
|
private void cmbYear_TextChanged(object sender, EventArgs e)
|
{
|
initGrid();
|
}
|
|
private void grdMain_BeforeEdit(object sender, AxVSFlex7._IVSFlexGridEvents_BeforeEditEvent e)
|
{
|
if (DBUtility.ClsPub.GridToColor(grdMain.get_Cell(VSFlex7.CellPropertySettings.flexcpBackColor, grdMain.Row, grdMain.Col, grdMain.Row, grdMain.Col)) ==DBUtility.ClsPub.Enum_Color.hx_Write)
|
{
|
//
|
}
|
else
|
{
|
e.cancel = true;
|
}
|
}
|
|
private void tz_Click(object sender, EventArgs e)
|
{
|
Gy_WorkTimesDlg oDlg = new Gy_WorkTimesDlg();
|
oDlg.ShowDialog();
|
Display();
|
}
|
|
private void grdMain_AfterEdit(object sender, AxVSFlex7._IVSFlexGridEvents_AfterEditEvent e)
|
{
|
|
DateTime Date = DBUtility.ClsPub.isDate(cmbYear.Text.ToString() + "-" + DBUtility.ClsPub.isInt(grdMain.Row / 2 + 1).ToString() + "-" + grdMain.get_TextMatrix(grdMain.Row - 1, grdMain.Col).ToString());
|
if (DBUtility.ClsPub.isStrNull(CurNode.Name) != null && DBUtility.ClsPub.isStrNull(CurNode.Text) != "")
|
{
|
Int64 sName = Convert.ToInt64(CurNode.Name.Substring(1, CurNode.Name.Length - 1));
|
double sWorktimes =DBUtility.ClsPub.isDoule(grdMain.get_TextMatrix(grdMain.Row, grdMain.Col));
|
//
|
WriteClass(sWorktimes, sName, Date);
|
oPs.AddNew();
|
Display();
|
}
|
}
|
|
private void cmdHSource_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
|
oSource.WherePart = txtHSource.Text.Trim();
|
if (oSource.RefreshView())
|
{
|
txtHSource.Text = oSource.oModel.HName;
|
txtHSource.Tag = oSource.oModel.HItemID;
|
HSourceID = oSource.oModel.HItemID;
|
}
|
else
|
{
|
txtHSource.Text = "";
|
txtHSource.Tag = "0";
|
HSourceID = 0;
|
}
|
LoadTree();
|
}
|
|
private void ww_Click(object sender, EventArgs e)
|
{
|
Gy_WorkTimesWWDlg oDlg = new Gy_WorkTimesWWDlg();
|
oDlg.HSourceID = DBUtility.ClsPub.isLong(txtHSource.Tag);
|
oDlg.ShowDialog();
|
Display();
|
}
|
|
}
|
}
|