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 Pub_Class;
|
namespace WorkM
|
{
|
public partial class Sc_ProcessExchangeBill_PL : Form
|
{
|
public Sc_ProcessExchangeBill_PL()
|
{
|
InitializeComponent();
|
}
|
|
public const Int16 HTagCol = 0;
|
public const Int16 HSnoCol = 1;
|
public const Int16 HBillNoCol = 2;
|
public const Int16 HQtyCol = 3;
|
|
|
public DataSet oXT;
|
public DAL.ClsSc_ProcessExchangeBill BillNew = new DAL.ClsSc_ProcessExchangeBill(); //¶ÔÓ¦µ¥¾ÝÀà
|
public bool grdStatus; //Íø¸ñ״̬£¨²»¿É±à¼£¬¿É±à¼£©
|
ClsGridViewSum oSumGrid = new ClsGridViewSum();
|
|
private void Sc_ProcessExchangeBill_PL_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
|
}
|
|
private void Sc_ProcessExchangeBill_PL_Load(object sender, EventArgs e)
|
{
|
oSumGrid.NoCol = HSnoCol;
|
oSumGrid.ogrdMain = grdMain;
|
oSumGrid.oGridsum = grdSum;
|
grdStatus = true;
|
initGrid();
|
}
|
|
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 initGrid()
|
{
|
//
|
//grdMain.RowCount = 0;
|
grdMain.ColumnCount = 4; //×ÜÁÐÊý
|
DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name);
|
grdMain.Columns[HSnoCol].HeaderText = "ÐòºÅ";
|
grdMain.Columns[HBillNoCol].HeaderText = "µ¥¾ÝºÅ";
|
grdMain.Columns[HQtyCol].HeaderText = "ÊýÁ¿";
|
//¸ñʽ»¯
|
grdMain.Columns[HTagCol].Visible = false; //Òþ²ØÁÐ
|
//ÉèÖÿɱà¼ÁÐ
|
string sAllowCol = HQtyCol.ToString() ;
|
string sTotalCol = HQtyCol.ToString();
|
//
|
DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid);
|
}
|
|
//Íø¸ñ±à¼Ç°ÅжÏ
|
private void grdMain_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
|
{
|
int i = grdMain.CurrentCell.ColumnIndex;
|
if (DBUtility.Xt_BaseBillFun.AllowEdit(grdStatus, oSumGrid, i))
|
{
|
e.Cancel = true;
|
}
|
}
|
|
//Íø¸ñ±à¼ºó´¦Àí
|
private void grdMain_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
//
|
if (this.EditingControl != null) //ÊÍ·Åʼþ
|
{
|
EditingControl.KeyDown -= new KeyEventHandler(this.EditingControl_KeyDown);
|
this.EditingControl = null;
|
}
|
}
|
DataGridViewTextBoxEditingControl EditingControl;
|
|
private void grdMain_CellLeave(object sender, DataGridViewCellEventArgs e)
|
{
|
//
|
if (!grdStatus)
|
{
|
return;
|
}
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
//
|
//if (oSumGrid.Changelock)
|
// return;
|
//if(oSumGrid.EditStatus)
|
//{
|
if (!CheckGridRow(oSumGrid.OldCell.Row))
|
return;
|
//}
|
}
|
//'ÅжÏÍø¸ñÐеļÈëÊÇ·ñÕýÈ·
|
private bool CheckGridRow(int Row)
|
{
|
Cell oCell = new Cell();
|
int c = 0;
|
for (c = 0; c < grdMain.ColumnCount; c++)
|
{
|
oCell.Row = Row;
|
oCell.Col = c;
|
//if (!CheckGridCell(oCell))
|
// return false;
|
|
}
|
return true;
|
}
|
|
private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
}
|
|
private void grdMain_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
|
{
|
if (grdMain.CurrentCell != null)
|
{
|
if (e.Control is DataGridViewTextBoxEditingControl)
|
{
|
this.EditingControl = (DataGridViewTextBoxEditingControl)e.Control;
|
//Ôö¼ÓίÍд¦Àí
|
this.EditingControl.KeyDown += new KeyEventHandler(this.EditingControl_KeyDown);
|
}
|
}
|
}
|
private void EditingControl_KeyDown(object sender, KeyEventArgs e)
|
{
|
//ÒµÎñ´¦Àí
|
Sub_GridKey(e.KeyValue, grdMain.CurrentRow.Index, grdMain.CurrentCell.ColumnIndex, EditingControl);
|
}
|
private void grdMain_RowHeadersWidthChanged(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
}
|
|
private void grdMain_Scroll(object sender, ScrollEventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
oSumGrid.DisplayCurRow();
|
}
|
|
//°ïÖúº¯Êý
|
private void Sub_GridKey(int sKeyCode, int sRow, int sCol, DataGridViewTextBoxEditingControl oEdit)
|
{ }
|
|
private void tim_Click(object sender, EventArgs e)
|
{
|
if (ClsPub.isDoule(txtHLastQty.Text) < 0)
|
{
|
MessageBox.Show("β¿òÊýÁ¿²»ÄÜΪ¸º£¡");
|
return;
|
}
|
if (DBUtility.ClsPub.isDoule(txtHQty.Text) > DBUtility.ClsPub.isDoule(txtHICMOBillQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text))
|
{
|
MessageBox.Show("±¾´ÎÉú³ÉÊýÁ¿²»ÄÜ´óÓÚ " + ClsPub.isStrNull(DBUtility.ClsPub.isDoule(txtHICMOBillQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text)) + " £¡");
|
return;
|
}
|
initGrid();
|
for (int i = 0; i < ClsPub.isInt(txtHCardQty.Text); i++)
|
{
|
grdMain.Rows[i].Cells[HSnoCol].Value = ClsPub.isStrNull(i + 1);
|
grdMain.Rows[i].Cells[HBillNoCol].Value = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);//µÃµ½Ðµ¥ºÅ
|
|
|
if (i != ClsPub.isInt(txtHCardQty.Text) - 1)
|
{
|
grdMain.Rows[i].Cells[HQtyCol].Value = txtHMinQty.Text;
|
}
|
else
|
{
|
grdMain.Rows[i].Cells[HQtyCol].Value = txtHLastQty.Text;
|
}
|
|
}
|
gbUp.Enabled = false;
|
tim.Enabled = false;
|
}
|
|
private void txtHQty_Leave(object sender, EventArgs e)
|
{
|
txtHCardQty.Text = ClsPub.isStrNull(Math.Ceiling(ClsPub.isDoule(txtHQty.Text) / ClsPub.isDoule(txtHMinQty.Text)));
|
if (ClsPub.isDoule(txtHCardQty.Text) == 0)
|
{
|
txtHLastQty.Text = "0";
|
}
|
else
|
{
|
txtHLastQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHQty.Text) - (ClsPub.isDoule(txtHMinQty.Text) * (ClsPub.isDoule(txtHCardQty.Text) - 1)));
|
}
|
}
|
|
private void txtHCardQty_Leave(object sender, EventArgs e)
|
{
|
if (ClsPub.isDoule(txtHCardQty.Text) == 0)
|
{
|
txtHLastQty.Text = "0";
|
}
|
else
|
{
|
txtHLastQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHQty.Text) - (ClsPub.isDoule(txtHMinQty.Text) * (ClsPub.isDoule(txtHCardQty.Text) - 1)));
|
}
|
}
|
|
private void txtHMinQty_Leave(object sender, EventArgs e)
|
{
|
txtHCardQty.Text = ClsPub.isStrNull(Math.Ceiling(ClsPub.isDoule(txtHQty.Text) / ClsPub.isDoule(txtHMinQty.Text)));
|
if (ClsPub.isDoule(txtHCardQty.Text) == 0)
|
{
|
txtHLastQty.Text = "0";
|
}
|
else
|
{
|
txtHLastQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHQty.Text) - (ClsPub.isDoule(txtHMinQty.Text) * (ClsPub.isDoule(txtHCardQty.Text) - 1)));
|
}
|
}
|
|
private void txtHQty_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
txtHCardQty.Text = ClsPub.isStrNull(Math.Ceiling(ClsPub.isDoule(txtHQty.Text) / ClsPub.isDoule(txtHMinQty.Text)));
|
if (ClsPub.isDoule(txtHCardQty.Text) == 0)
|
{
|
txtHLastQty.Text = "0";
|
}
|
else
|
{
|
txtHLastQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHQty.Text) - (ClsPub.isDoule(txtHMinQty.Text) * (ClsPub.isDoule(txtHCardQty.Text) - 1)));
|
}
|
}
|
}
|
|
private void txtHCardQty_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
if (ClsPub.isDoule(txtHCardQty.Text) == 0)
|
{
|
txtHLastQty.Text = "0";
|
}
|
else
|
{
|
txtHLastQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHQty.Text) - (ClsPub.isDoule(txtHMinQty.Text) * (ClsPub.isDoule(txtHCardQty.Text) - 1)));
|
}
|
}
|
}
|
|
private void txtHMinQty_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
txtHCardQty.Text = ClsPub.isStrNull(Math.Ceiling(ClsPub.isDoule(txtHQty.Text) / ClsPub.isDoule(txtHMinQty.Text)));
|
if (ClsPub.isDoule(txtHCardQty.Text) == 0)
|
{
|
txtHLastQty.Text = "0";
|
}
|
else
|
{
|
txtHLastQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHQty.Text) - (ClsPub.isDoule(txtHMinQty.Text) * (ClsPub.isDoule(txtHCardQty.Text) - 1)));
|
}
|
}
|
}
|
|
private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
|
{
|
|
}
|
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private void bc_Click(object sender, EventArgs e)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet Ds;
|
Ds = oCn.RunProcReturn(" select isnull(Á÷ת¿¨¹ØÁªÊýÁ¿,0) HQty from h_v_Sc_ICMOBillList where hmainid=" + DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[0]["hmainid"]), "h_v_Sc_ICMOBillList");
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("¹ØÁªÊý´íÎó£¬ÇëÖØÐÂÏÂÍÆ£¡");
|
return;
|
}
|
else
|
{
|
if (DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0][0]) != DBUtility.ClsPub.isDoule(txtHRelationQty.Text))
|
{
|
MessageBox.Show("¹ØÁªÊýÒѱ»¸üУ¬ÇëÖØÐÂÏÂÍÆ£¡");
|
}
|
}
|
if (DBUtility.ClsPub.isDoule(txtHQty.Text) <= 0)
|
{
|
MessageBox.Show("±¾´ÎÉú³ÉÊýÁ¿²»ÄÜСÓÚµÈÓÚ0£¡");
|
return;
|
}
|
if (DBUtility.ClsPub.isDoule(txtHQty.Text) > DBUtility.ClsPub.isDoule(txtHICMOBillQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text))
|
{
|
MessageBox.Show("±¾´ÎÉú³ÉÊýÁ¿²»ÄÜ´óÓÚ " +ClsPub.isStrNull( DBUtility.ClsPub.isDoule(txtHICMOBillQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text))+" £¡");
|
return;
|
}
|
|
for (int z = 0; z < grdMain.Rows.Count; z++)
|
{
|
if (ClsPub.isStrNull(grdMain.Rows[z].Cells[HBillNoCol].Value) != "")
|
{
|
Model.ClsSc_ProcessExchangeBillSub oBillSub = new Model.ClsSc_ProcessExchangeBillSub();
|
Int32 i;
|
bool bResult;
|
BillNew = new DAL.ClsSc_ProcessExchangeBill();
|
//Ö÷Àำֵ
|
//ÅÐ¶Ï»á¼ÆÆÚÊÇ·ñºÏÀí
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(DateTime.Now, ref sYear, ref sPeriod, ref s) == false)
|
{
|
MessageBox.Show(s, "Ìáʾ");
|
return;
|
}
|
//Ô´µ¥ÐÅÏ¢
|
//BillNew.omodel.HMainSourceBillType = cmbSourceBillType.Text;
|
//
|
BillNew.omodel.HYear = sYear;
|
BillNew.omodel.HPeriod = sPeriod;
|
//¹Ì¶¨¸³Öµ=================================
|
BillNew.omodel.HBillNo = grdMain.Rows[z].Cells[HBillNoCol].Value.ToString();
|
BillNew.omodel.HDate = DateTime.Now;
|
BillNew.omodel.HRemark = "";
|
//====================================================
|
BillNew.omodel.HWWOrderInterID = 0;
|
BillNew.omodel.HWWOrderEntryID = 0;
|
BillNew.omodel.HWWOrderBillNo = "";
|
BillNew.omodel.HICMOInterID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[0]["hmainid"]);
|
BillNew.omodel.HICMOBillNo = DBUtility.ClsPub.isStrNull(oXT.Tables[0].Rows[0]["ÈÎÎñµ¥ºÅ"]);
|
BillNew.omodel.HMaterID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[0]["hmaterid"]);
|
BillNew.omodel.HMaterNumber = DBUtility.ClsPub.isStrNull(oXT.Tables[0].Rows[0]["ÎïÁÏ´úÂë"]);
|
BillNew.omodel.HUnitID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[0]["hunitid"]);
|
BillNew.omodel.HUnitNumber = DBUtility.ClsPub.isStrNull(oXT.Tables[0].Rows[0]["¼ÆÁ¿µ¥Î»´úÂë"]);
|
|
BillNew.omodel.HEmpID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[0]["HEmpID"]);
|
|
BillNew.omodel.HPlanQty = DBUtility.ClsPub.isDoule(grdMain.Rows[z].Cells[HQtyCol].Value);
|
|
BillNew.omodel.HPlanBeginDate = DBUtility.ClsPub.isDate(oXT.Tables[0].Rows[0]["¼Æ»®¿ª¹¤ÈÕÆÚ"]);
|
BillNew.omodel.HPlanEndDate = DBUtility.ClsPub.isDate(oXT.Tables[0].Rows[0]["¼Æ»®Í깤ÈÕÆÚ"]);
|
BillNew.omodel.HJHDate = DBUtility.ClsPub.isDate(oXT.Tables[0].Rows[0]["½»»õÈÕÆÚ"]);
|
BillNew.omodel.HExplanation = "";
|
BillNew.omodel.HInnerBillNo = "";
|
BillNew.omodel.HWorkShopID = 0;
|
BillNew.omodel.HSupID = 0;
|
//Ã÷ϸÀำֵ
|
BillNew.DetailColl = new List<Model.ClsSc_ProcessExchangeBillSub>();
|
for (i = 0; i < oXT.Tables[0].Rows.Count; i++)
|
{
|
if (DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[i]["hprocid"]) != 0)
|
{
|
Model.ClsSc_ProcessExchangeBillSub oSub = new Model.ClsSc_ProcessExchangeBillSub();
|
//¹Ì¶¨¸³Öµ========================================
|
oSub.HEntryID = i + 1;
|
oSub.HRemark = DBUtility.ClsPub.isStrNull(oXT.Tables[0].Rows[i]["±¸×¢"]);
|
oSub.HSourceInterID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[i]["hmainid"]);
|
oSub.HSourceEntryID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[i]["hsubid"]);
|
oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(oXT.Tables[0].Rows[i]["HBillType"]);
|
oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(oXT.Tables[0].Rows[i]["ÈÎÎñµ¥ºÅ"]);
|
oSub.HRelationQty = 0;
|
oSub.HRelationMoney = 0;
|
oSub.HCloseMan = "";
|
//oSub.HEntryCloseDate = null;
|
//oSub.HCloseType = 0;
|
//=============================
|
oSub.HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[z].Cells[HQtyCol].Value);
|
|
oSub.HProcNo = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[i]["¹¤ÐòºÅ"]);
|
oSub.HProcID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[i]["hprocid"]);
|
oSub.HProcNumber = DBUtility.ClsPub.isStrNull(oXT.Tables[0].Rows[i]["¹¤Ðò´úÂë"]);
|
oSub.HWorkRemark = "";
|
oSub.HCenterID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[i]["HCenterID"]);
|
oSub.HDeptID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[i]["hdeptid"]);
|
oSub.HDeptNumber = DBUtility.ClsPub.isStrNull(oXT.Tables[0].Rows[i]["Éú²ú³µ¼ä´úÂë"]);
|
oSub.HGroupID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[i]["HGroupID"]);
|
oSub.HGroupNumber = DBUtility.ClsPub.isStrNull(oXT.Tables[0].Rows[i]["°à×é´úÂë"]);
|
oSub.HWorkerID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[i]["HWorkerID"]);
|
oSub.HWorkerNumber = DBUtility.ClsPub.isStrNull(oXT.Tables[0].Rows[i]["²Ù×÷¹¤´úÂë"]);
|
oSub.HSourceID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[i]["HSourceID"]);
|
oSub.HTimeUnit = DBUtility.ClsPub.isStrNull(oXT.Tables[0].Rows[i]["ʱ¼äµ¥Î»"]);
|
|
oSub.HPlanWorkTimes = 0;
|
|
oSub.HPlanBeginDate = DBUtility.ClsPub.isDate(oXT.Tables[0].Rows[i]["¼Æ»®¿ª¹¤ÈÕÆÚ"]);
|
oSub.HPlanEndDate = DBUtility.ClsPub.isDate(oXT.Tables[0].Rows[i]["¼Æ»®Í깤ÈÕÆÚ"]);
|
//oSub.HRelBeginDate = "";
|
//oSub.HRelEndDate = "";
|
|
oSub.HReadyTime = DBUtility.ClsPub.isSingle(oXT.Tables[0].Rows[i]["×¼±¸Ê±¼ä"]);
|
oSub.HQueueTime = DBUtility.ClsPub.isSingle(oXT.Tables[0].Rows[i]["ÅŶÓʱ¼ä"]);
|
oSub.HMoveTime = DBUtility.ClsPub.isSingle(oXT.Tables[0].Rows[i]["×ªÒÆÊ±¼ä"]);
|
oSub.HBeginDayQty = 0;
|
oSub.HBeginFixQty = 0;
|
oSub.HFixWorkDays = 0;
|
oSub.HTrunWorkDays = 0;
|
oSub.HReadyTimes = 0;
|
oSub.HMyWorkDays = 0;
|
oSub.HOutPrice = 0;
|
oSub.HOutMoney = 0;
|
oSub.HLastProc = "";
|
oSub.HFstProc = "";
|
|
//if (oSub.HSourceID == 0)
|
//{
|
// MessageBox.Show("µÚ" + ClsPub.isStrNull(i + 1) + "ÐУ¬Éú²ú×ÊÔ´²»ÄÜΪ¿Õ");
|
// return false;
|
//}
|
//
|
oSub.HICMOBillNo = DBUtility.ClsPub.isStrNull(oXT.Tables[0].Rows[i]["ÈÎÎñµ¥ºÅ"]);
|
oSub.HICMOInterID = DBUtility.ClsPub.isLong(oXT.Tables[0].Rows[i]["hmainid"]);
|
oSub.HSeOrderInterID = 0;
|
oSub.HSeOrderEntryID = 0;
|
oSub.HSeOrderBillNo = "";
|
oSub.HWWOrderInterID = 0;
|
oSub.HWWOrderEntryID = 0;
|
oSub.HWWOrderBillNo = "";
|
BillNew.DetailColl.Add(oSub);
|
}
|
}
|
//±£´æÍê±Ïºó´¦Àí
|
bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
|
//Ìáʾ
|
if (bResult == true)
|
{
|
//MessageBox.Show("µ¥¾Ý´æÅÌÍê±Ï!µ¥¾ÝºÅ:" + this.txtHBillNo.Text.Trim(), "Ìáʾ");
|
//return true;
|
}
|
else
|
{
|
MessageBox.Show("±£´æÊ§°Ü!ÔÒò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
|
return;
|
}
|
}
|
}
|
MessageBox.Show("Á÷ת¿¨Éú³ÉÍê±Ï!", "Ìáʾ");
|
gbUp.Enabled = false;
|
grdMain.Enabled = false;
|
tim.Enabled = false;
|
bc.Enabled = false;
|
}
|
|
}
|
}
|