using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
using gregn6Lib;
|
using SQLHelper;
|
|
|
namespace CostM
|
{
|
public partial class CB_WorkTimePeriodImport : Form
|
{
|
public CB_WorkTimePeriodImport()
|
{
|
InitializeComponent();
|
}
|
|
const string ViewName = "h_v_CB_WorkTimePeriodImport";
|
const string ModCaption = "ʵ¼Ê¹¤Ê±ÒýÈë";
|
public const string ModName = "1205";
|
public const string ModRightName = "CB_WorkTimePeriod";
|
public const string ModRightNameEdit = ModRightName + "_Edit";
|
public const string ModRightNameCheck = ModRightName + "_Check";
|
public const string ModRightNameClose = ModRightName + "_Close";
|
public const string ModRightNameDelete = ModRightName + "_Delete";
|
public const string ModRightNameMoney = ModRightName + "_Money";
|
public const string ModRightNameQty = ModRightName + "_Qty";
|
public Int32 iTopRow = 0;//»ºáÏß
|
int _ScrollValue = 0;//ˢР»ØÎ»
|
private void bclk_Click(object sender, EventArgs e)
|
{
|
//±£´æÁпí
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
|
}
|
|
private void mrlk_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name);
|
}
|
|
private void dc_Click(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.DataToExcel(grdMain);
|
}
|
|
|
#region //´òÓ¡ÉèÖÃ
|
GridppReport Report;
|
private void set_Click(object sender, EventArgs e)
|
{
|
//Ñ¡Ôñ´òÓ¡Ä£°å
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
}
|
|
private void dy_Click(object sender, EventArgs e)
|
{
|
//Ñ¡Ôñ´òÓ¡Ä£°å
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
//
|
Sub_SetReport(oFrm.sOpenTmp);
|
Report.Print(true);
|
}
|
}
|
|
private void yl_Click(object sender, EventArgs e)
|
{
|
//Ñ¡Ôñ´òÓ¡Ä£°å
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
//
|
Sub_SetReport(oFrm.sOpenTmp);
|
Report.PrintPreview(true);
|
}
|
}
|
|
private void Sub_SetReport(string sOpenTmp)
|
{
|
//ÅжÏÐÐÊý
|
//
|
Report = new GridppReport();
|
Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here .
|
Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
|
}
|
|
private void ReportFetchRecordByDataTable()
|
{
|
BLL.Utility.FillRecordToReport(Report, grdMain, grdPrint, 0);
|
}
|
|
#endregion
|
|
private void yr_Click(object sender, EventArgs e)
|
{
|
ClsCN SubCn = new ClsCN();
|
DataSet DSet;
|
string sSql = "exec kfmic_caiwu_depttasktime " + cmbHYear.Text + " ," + cmbHPeriod.Text;
|
|
DSet = SubCn.RunProcReturn(sSql, ViewName, ref DBUtility.ClsPub.sExeReturnInfo);
|
//Éú³ÉÊ×ÐбêÌâ
|
if (DSet == null)
|
{
|
MessageBox.Show("ûÓзµ»ØÈκνá¹û,Çë³¢ÊÔÔٴβéѯ£¡" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//ÊͷŶ³½á
|
DBUtility.Xt_BaseBillFun.CancelFrozenCol(grdMain);
|
//ˢкó,»Ø¹öµ½ÔλÖÃ
|
int selectRows = 0;
|
if (grdMain.CurrentRow != null)
|
{
|
selectRows = DBUtility.ClsPub.isInt(grdMain.CurrentRow.Index);
|
}
|
//°ó¶¨
|
grdMain.DataSource = DSet.Tables[0].DefaultView;
|
//ˢкó,»Ø¹öµ½ÔλÖÃ
|
if (grdMain.Rows.Count > _ScrollValue)
|
{
|
grdMain.FirstDisplayedScrollingRowIndex = _ScrollValue;
|
//iTopRow = _ScrollValue;
|
}
|
if (grdMain.Rows.Count > 0 && grdMain.Rows.Count > selectRows)
|
{
|
grdMain.Rows[selectRows].Selected = true;
|
}
|
//ÉèÖúϼÆÁÐ
|
//string sTotalCol = "";
|
//sTotalCol = DBUtility.Gy_BaseFun.GetTotalCols(DSet);
|
//string[] sT;
|
//sT = sTotalCol.Split(Convert.ToChar(","));
|
//oSumGrid.BuildTotalCols(sT);
|
//
|
//¶³½á
|
int FrCol = DBUtility.ClsPub.isInt(0);
|
string s = "";
|
DBUtility.Xt_BaseBillFun.DisplayGrid(grdMain, this.Name, s, FrCol);
|
//»Ïß
|
GraphLine();
|
//
|
//Total();
|
}
|
|
private void GraphLine()
|
{
|
//int MainIDCol = Fun_GetCol("hmainid");
|
//int SubIDCol = Fun_GetCol("hsubid");
|
//string s = frmCondition.cmbHComplete.Text;
|
//long n = 0;
|
//DBUtility.Xt_BaseBillFun.GraphLine(grdMain, MainIDCol, SubIDCol, s, ref n);
|
////ÏÔʾ
|
//lbldj.Text = "²éѯ³ö " + n.ToString() + " Õŵ¥¾Ý";
|
//lbljl.Text = "¹²ÓÐ " + grdMain.RowCount.ToString() + " Ìõ¼Ç¼";
|
|
}
|
|
|
private Int32 Fun_GetCol(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain);
|
}
|
|
private void xz_Click(object sender, EventArgs e)
|
{
|
//»ñÈ¡±¾ÆÚ³É±¾»á¼ÆÆÚ¼ä
|
if (DBUtility.ClsPub.Sub_CBGetCurPeriod() == false)
|
{
|
MessageBox.Show("»ñÈ¡³É±¾»á¼ÆÆÚ¼äʧ°Ü!");
|
return;
|
}
|
//ÅжÏÊÇ·ñ±¾ÆÚ¼ä
|
if (Pub_Class.ClsPub.isInt(cmbHYear.Text) != DBUtility.ClsPub.CBCurYear || Pub_Class.ClsPub.isInt(cmbHPeriod.Text) != DBUtility.ClsPub.CBCurPeriod)
|
{
|
MessageBox.Show("Ö»Äܱ£´æ±¾ÆÚÊý¾Ý£¡");
|
return;
|
}
|
//
|
ClsCN oCn = new ClsCN();
|
DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View();
|
int HYear;
|
int HPeriod;
|
long HMaterID;
|
string HMaterNumber;
|
double HRelWorkTimes;
|
long HDeptID;
|
string HMESDeptName;
|
HYear = Pub_Class.ClsPub.isInt(cmbHYear.Text);
|
HPeriod = Pub_Class.ClsPub.isInt(cmbHPeriod.Text);
|
string HDeptName="";
|
for (int j = 0; j < grdMain.RowCount; j++)
|
{
|
HDeptID = Pub_Class.ClsPub.isLong(grdMain.Rows[j].Cells[Fun_GetCol("HDeptID")].Value);
|
if (HDeptID == 0)
|
{
|
if (HDeptName.IndexOf(Pub_Class.ClsPub.isStrNull(grdMain.Rows[j].Cells[Fun_GetCol("MES²¿ÃÅ")].Value)) > -1)
|
{
|
continue;
|
}
|
else
|
{
|
HDeptName = HDeptName + "," + Pub_Class.ClsPub.isStrNull(grdMain.Rows[j].Cells[Fun_GetCol("MES²¿ÃÅ")].Value);
|
}
|
}
|
}
|
if (HDeptName != "")
|
{
|
HDeptName = HDeptName.Remove(0, 1);
|
if (MessageBox.Show("´æÔÚÎÞERP²¿ÃżÇ¼£¬ÊÇ·ñ¼ÌÐø±£´æ£¡\r\n MES²¿ÃÅ£º" + HDeptName, "Ìáʾ", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
{
|
AddNew();
|
}
|
}
|
else
|
{
|
AddNew();
|
}
|
}
|
private void AddNew()
|
{
|
ClsCN oCn = new ClsCN();
|
DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View();
|
int HYear;
|
int HPeriod;
|
long HMaterID;
|
string HMaterNumber;
|
double HRelWorkTimes;
|
long HDeptID;
|
string HMESDeptName;
|
HYear = Pub_Class.ClsPub.isInt(cmbHYear.Text);
|
HPeriod = Pub_Class.ClsPub.isInt(cmbHPeriod.Text);
|
|
oCn.RunProc("delete CB_WorkTimePeriod where HYear=" + HYear + " and HPeriod=" + HPeriod);
|
for (int i = 0; i < grdMain.RowCount; i++)
|
{
|
HDeptID = Pub_Class.ClsPub.isLong(grdMain.Rows[i].Cells[Fun_GetCol("HDeptID")].Value);
|
HMaterNumber = Pub_Class.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("²úÆ·´úÂë")].Value);
|
HMESDeptName = Pub_Class.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("MES²¿ÃÅ")].Value);
|
if (oMater.GetInfoByNumber(HMaterNumber))
|
{
|
HMaterID = oMater.omodel.HItemID;
|
}
|
else
|
{
|
HMaterID = 0;
|
}
|
HRelWorkTimes = Pub_Class.ClsPub.isDoule(grdMain.Rows[i].Cells[Fun_GetCol("ʵ¼Ê¹¤Ê±")].Value);
|
if (HMaterID == 0)
|
continue;
|
//if (HDeptID == 0)
|
// continue;
|
oCn.RunProc("insert into CB_WorkTimePeriod (HYear,HPeriod" +
|
",HDeptID,HMaterID,HMaterNumber,HMESDeptName,HRelWorkTimes" +
|
")" +
|
"values('" + HYear + "','" + HPeriod + "'" +
|
"," + HDeptID + "," + HMaterID + ",'" + HMaterNumber + "','" + HMESDeptName + "'," + HRelWorkTimes + ")");
|
}
|
MessageBox.Show("±£´æÍê±Ï£¡");
|
}
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private void CB_WorkTimePeriodImport_Load(object sender, EventArgs e)
|
{
|
|
cmbHYear.Items.Clear();
|
//»ñÈ¡±¾ÆÚ³É±¾»á¼ÆÆÚ¼ä
|
if (DBUtility.ClsPub.Sub_CBGetCurPeriod() == false)
|
{
|
MessageBox.Show("»ñÈ¡³É±¾»á¼ÆÆÚ¼äʧ°Ü!");
|
return;
|
}
|
cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear);
|
cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 1);
|
cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 2);
|
cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 3);
|
cmbHYear.SelectedIndex = 0;
|
cmbHPeriod.Text = DBUtility.ClsPub.CBCurPeriod.ToString();
|
initGrid();
|
}
|
|
//³õʼ»¯GRID
|
private void initGrid()
|
{
|
DBUtility.Gy_BaseFun.initGrid(grdMain);
|
}
|
}
|
}
|