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_WIPBalance_QCMX : Form
|
{
|
public CB_WIPBalance_QCMX()
|
{
|
InitializeComponent();
|
}
|
|
const string ViewName = "h_v_CB_WIPBalance_QCMX";
|
const string ModCaption = "ÆÚ³õ²ÄÁÏÃ÷ϸ";
|
public const string ModName = "1205";
|
public const string ModRightName = "CB_WIPBalance_QCMX";
|
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;//ˢР»ØÎ»
|
public int HYear;
|
public int HPeriod;
|
public long HMaterID;
|
|
public int HQtyCol;
|
public int HMoneyCol;
|
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 = "select * from h_v_CB_WIPBalance_QCMX where Äê=" + cmbHYear.Text + " and ÔÂ=" + cmbHPeriod.Text;
|
//string sSql = "exec h_p_CB_WIPBalance_QCMX " + HYear + " ," +HPeriod+","+HMaterID;
|
|
//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();
|
oCn.RunProc("exec h_p_CB_WIPBalance_QCMX_Update "+HYear+","+HPeriod+","+HMaterID);
|
MessageBox.Show("±£´æÍê±Ï£¡");
|
}
|
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private void CB_WIPBalance_QCMX_Load(object sender, EventArgs e)
|
{
|
|
DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View();
|
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.Items.Add("");
|
//cmbHYear.SelectedIndex = 0;
|
//cmbHPeriod.Text = DBUtility.ClsPub.CBCurPeriod.ToString();
|
|
cmbHYear.Text = HYear.ToString();
|
cmbHPeriod.Text = HPeriod.ToString();
|
if (oMater.GetInfoByID(HMaterID))
|
{
|
txtHMaterID.Text = oMater.omodel.HNumber;
|
txtHMaterName.Text= oMater.omodel.HName;
|
|
}
|
else
|
{
|
txtHMaterID.Text = "";
|
txtHMaterName.Text = "";
|
}
|
initGrid();
|
Show();
|
}
|
|
//³õʼ»¯GRID
|
private void initGrid()
|
{
|
DBUtility.Gy_BaseFun.initGrid(grdMain);
|
}
|
private void Show()
|
{
|
ClsCN SubCn = new ClsCN();
|
DataSet DSet;
|
string sSql = "select * from h_v_CB_WIPBalance_QCMX where Äê=" + HYear + " and ÔÂ=" + HPeriod + " and HProdID=" + HMaterID;
|
//string sSql = "exec h_p_CB_WIPBalance_QCMX " + HYear + " ," + HPeriod + "," + HMaterID;
|
|
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;
|
|
HQtyCol = Fun_GetCol("ÊýÁ¿");
|
HMoneyCol = Fun_GetCol("½ð¶î");
|
//ˢкó,»Ø¹öµ½ÔλÖÃ
|
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();
|
grdMain.ReadOnly = false;
|
}
|
|
private void grdMain_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
|
{
|
int HYear = DBUtility.ClsPub.isInt( cmbHYear.Text);
|
int HPeriod = DBUtility.ClsPub.isInt(cmbHPeriod.Text);
|
if (e.ColumnIndex != HQtyCol && e.ColumnIndex != HMoneyCol || HYear != DBUtility.ClsPub.CBCurYear || HPeriod != DBUtility.ClsPub.CBCurPeriod)
|
{
|
e.Cancel = true;
|
}
|
}
|
|
private void grdMain_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
{
|
Update(e.RowIndex, e.ColumnIndex);
|
}
|
private void Update(int sRow, int sCol)
|
{
|
ClsCN oCn = new ClsCN();
|
Int64 HItemID = 0;
|
HItemID = DBUtility.ClsPub.isLong(grdMain.Rows[sRow].Cells[Fun_GetCol("HItemID")].Value);
|
if (HItemID == 0)
|
return;
|
if (sCol == HQtyCol)
|
{
|
oCn.RunProc("update CB_WIPMaterBalance_QC set HQty=" + DBUtility.ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) + " where HItemID=" + HItemID);
|
|
}
|
else if (sCol == HMoneyCol)
|
{
|
oCn.RunProc("update CB_WIPMaterBalance_QC set HMoney=" + DBUtility.ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) + " where HItemID=" + HItemID);
|
}
|
else
|
{ }
|
|
|
}
|
|
private void toolStripButton1_Click(object sender, EventArgs e)
|
{
|
CB_WIPBalance_QCMXAdd oAdd= new CB_WIPBalance_QCMXAdd();
|
oAdd.HYear = HYear;
|
oAdd.HPeriod = HPeriod;
|
oAdd.HProdID = HMaterID;
|
oAdd.ShowDialog();
|
Show();
|
}
|
|
private void sc_Click(object sender, EventArgs e)
|
{
|
ClsCN oCn = new ClsCN();
|
Int64 HItemID = 0;
|
HItemID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("HItemID")].Value);
|
if (HItemID == 0)
|
return;
|
|
//»ñÈ¡±¾ÆÚ³É±¾»á¼ÆÆÚ¼ä
|
if (DBUtility.ClsPub.Sub_CBGetCurPeriod() == false)
|
{
|
MessageBox.Show("»ñÈ¡³É±¾»á¼ÆÆÚ¼äʧ°Ü!");
|
return;
|
}
|
//ÅжÏÊÇ·ñ±¾ÆÚ¼ä
|
int sYear = 0;
|
int sPeriod = 0;
|
sYear = DBUtility.ClsPub.isInt(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("Äê")].Value);
|
sPeriod = DBUtility.ClsPub.isInt(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("ÔÂ")].Value);
|
|
if (sYear != DBUtility.ClsPub.CBCurYear || sPeriod != DBUtility.ClsPub.CBCurPeriod)
|
{
|
MessageBox.Show("Ö»ÄÜɾ³ý±¾ÆÚÊý¾Ý£¡");
|
return;
|
}
|
//
|
if (MessageBox.Show("È·¶¨ÒªÉ¾³ýµ±Ç°Ñ¡ÖмǼ£¿", "Ìáʾ", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
{
|
oCn.RunProc("delete CB_WIPMaterBalance_QC where HItemID=" + HItemID);
|
MessageBox.Show("ɾ³ýÍê±Ï£¡");
|
Show();
|
|
}
|
}
|
}
|
}
|