using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
using Pub_Class;
|
using SQLHelper;
|
|
namespace BaseSet
|
{
|
public partial class Gy_DataIn_RoutingBill :BLL.Gy_DataInTmp
|
{
|
public Gy_DataIn_RoutingBill()
|
{
|
InitializeComponent();
|
}
|
|
public int HCollectIDCol = 1; //²É¼¯Æ÷ÄÚÂë
|
public int HRoomIDCol = 5; //Òµ»§ÄÚÂë
|
public int HBeginDateCol = 13; //¿ªÊ¼ÈÕÆÚ
|
public int HEndDateCol = 10; //½áÊøÈÕÆÚ
|
public int HItMoneyIDCol = 5; //·ÑÓÃÏîÄ¿
|
public int HQtyCol = 6; //ÊýÁ¿
|
public int HPriceCol = 7; //µ¥¼Û
|
public int HMoneyCol = 8; //½ð¶î
|
public int HBeginBalanceCol = 12; //¿ªÊ¼ÊýÖµ
|
public int HEndBalanceCol = 9; //½áÊøÊýÖµ
|
//
|
public const int HBeginRow = 2; //ÓÐЧÊý¾Ý£¬¿ªÊ¼ÐÐÊý
|
//
|
public DAL.ClsGy_Process_Ctl oProc = new DAL.ClsGy_Process_Ctl();
|
public DAL.ClsGy_Process_View oProcHlp = new DAL.ClsGy_Process_View();
|
public DAL.ClsK3_Department_View oFactory = new DAL.ClsK3_Department_View();
|
DAL.ClsGy_WorkCenter_View oCen = new DAL.ClsGy_WorkCenter_View();
|
DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View();
|
DAL.ClsK3_Unit_View oUnit = new DAL.ClsK3_Unit_View();
|
public DAL.ClsGy_RoutingBill BillNew = new DAL.ClsGy_RoutingBill();
|
DAL.ClsK3_Material_View oMaterHlp = new DAL.ClsK3_Material_View();
|
long j = 0;
|
int c = 0;
|
//public DAL.ClsCB_ItemMoneyBill_Tmp oBill = new DAL.ClsCB_ItemMoneyBill_Tmp();
|
//public DAL.ClsGy_ItemMoney_View oItemMoney = new DAL.ClsGy_ItemMoney_View();
|
//public DAL.ClsGy_Room_View oRoom = new DAL.ClsGy_Room_View();
|
//public DAL.ClsGy_Collect_View oCollect = new DAL.ClsGy_Collect_View();
|
//public DAL.ClsGy_Building_View oBuilding = new DAL.ClsGy_Building_View();
|
|
/// <summary>
|
/// ³õʼ»¯½çÃæ
|
/// </summary>
|
public override void initData()
|
{
|
base.initData();
|
base.sSheetName = "¹¤ÒÕ·Ïß";
|
base.ModRightName = "Gy_DataIn_RoutingBill";
|
base.ModRightNameCheck = base.ModRightName + base.ModRightNameCheck;
|
base.ModRightNameClose = base.ModRightName + base.ModRightNameClose;
|
base.ModRightNameDelete = base.ModRightName + base.ModRightNameDelete;
|
base.ModRightNameEdit = base.ModRightName + base.ModRightNameEdit;
|
base.ModRightNameMoney = base.ModRightName + base.ModRightNameMoney;
|
base.ModRightNameQty = base.ModRightName + base.ModRightNameQty;
|
base.ModCaption = "¹¤ÒÕ·Ïßµ¼Èë";
|
this.Text = base.ModCaption;
|
lblCaption.Text = base.ModCaption;
|
//
|
DBUtility.Gy_BaseFun.SetComboxYear(cmbHYear);
|
DBUtility.Gy_BaseFun.SetComboxPeriod(cmbHPeriod);
|
//
|
}
|
//µ¼Èë
|
public override void Sub_DataIn()
|
{
|
string hnumber = "";
|
string HBillNo = "";
|
//
|
if (!Checkdata()) return;
|
if (grdMain.Rows.Count > 0)
|
{
|
hnumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[0].Cells[0].Value);
|
HBillNo = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);
|
BillNew.omodel.HStandard = false;
|
BillNew.omodel.HMainTimeUnit = "Сʱ";
|
BillNew.omodel.HYear = 2011;
|
BillNew.omodel.HPeriod = 1;
|
BillNew.omodel.HBillNo = HBillNo;
|
BillNew.omodel.HDate = DateTime.Today.Date;
|
BillNew.DetailColl.Clear();
|
}
|
for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
|
{
|
string sHNumber = "";
|
int sCol = DBUtility.Gy_BaseFun.Fun_GetCol("²úÆ·´úÂë", grdMain);
|
|
if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[0].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[3].Value) != "")
|
{
|
//
|
sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sCol].Value);
|
//ÉóºË´úÂëÊÇ·ñºÏÀí
|
if (!DBUtility.ClsPub.AllowNumber(sHNumber))
|
{
|
MessageBox.Show("ÎïÁÏ´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
|
return;
|
}
|
|
if (hnumber == DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[0].Value))
|
{
|
//µÃµ½ÎïÁÏÄÚÂë
|
if (oMaterHlp.GetInfoByNumber(sHNumber))
|
{
|
if (BillNew.omodel.HMaterID != oMaterHlp.omodel.HItemID)
|
{
|
BillNew.omodel.HMaterID = oMaterHlp.omodel.HItemID;
|
BillNew.omodel.HMaterNumber = oMaterHlp.omodel.HNumber;
|
BillNew.omodel.HUnitID = oMaterHlp.omodel.HUnitID;
|
BillNew.omodel.HUnitNumber = oMaterHlp.omodel.HUnitNumber;
|
}
|
|
}
|
else
|
{
|
BillNew.omodel.HMaterID = 0;
|
MessageBox.Show("µÚ" + i.ToString() + "ÐÐ," + sHNumber + "ûÓÐÕÒµ½¶ÔÓ¦µÄÎïÁÏ£¡");
|
return;
|
}
|
j++;
|
//дÈëÀà
|
WriteClass(i);
|
|
}
|
else
|
{
|
DataSet Ds;
|
ClsCN oCn=new ClsCN();
|
bool b = false;
|
Ds = oCn.RunProcReturn("Select HMaterID from Gy_RoutingBillMain Where HMaterID=" + BillNew.omodel.HMaterID.ToString(), "Gy_RoutingBillMain");
|
if (checkadd.Checked == true)
|
{
|
if (Ds.Tables[0].Rows.Count == 0)
|
{
|
b = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
|
if (b == false) return;
|
c++;
|
BillNew.CheckBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
|
}
|
}
|
else
|
{
|
b = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
|
if (b == false) return;
|
c++;
|
BillNew.CheckBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
|
}
|
|
|
BillNew.DetailColl.Clear();
|
hnumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[0].Value);
|
sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sCol].Value);
|
|
//ÉóºË´úÂëÊÇ·ñºÏÀí
|
if (!DBUtility.ClsPub.AllowNumber(sHNumber))
|
{
|
MessageBox.Show("ÎïÁÏ´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
|
return;
|
}
|
//µÃµ½ÎïÁÏÄÚÂë
|
if (oMaterHlp.GetInfoByNumber(sHNumber))
|
{
|
if (BillNew.omodel.HMaterID != oMaterHlp.omodel.HItemID)
|
{
|
BillNew.omodel.HMaterID = oMaterHlp.omodel.HItemID;
|
BillNew.omodel.HMaterNumber = oMaterHlp.omodel.HNumber;
|
BillNew.omodel.HUnitID = oMaterHlp.omodel.HUnitID;
|
BillNew.omodel.HUnitNumber = oMaterHlp.omodel.HUnitNumber;
|
}
|
|
}
|
else
|
{
|
BillNew.omodel.HMaterID = 0;
|
MessageBox.Show("µÚ" + i.ToString() + "ÐÐ," + sHNumber + "ûÓÐÕÒµ½¶ÔÓ¦µÄÎïÁÏ£¡");
|
return;
|
}
|
j = 1;
|
HBillNo = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);
|
BillNew.omodel.HBillNo = HBillNo;
|
//дÈëÀà
|
WriteClass(i);
|
|
}
|
|
}
|
else
|
{
|
//if (BillNew.DetailColl.Count > 0)
|
//{
|
// BillNew.AddBill(ref ClsPub.sExeReturnInfo);
|
// BillNew.CheckBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
|
//}
|
MessageBox.Show("ÎïÁÏ´úÂë»ò¹¤Ðò´úÂëΪ¿Õ!ÔÒò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
|
return;
|
}
|
}
|
//×îºóÒ»¸öÎïÁÏ´¦Àí
|
if (BillNew.DetailColl.Count > 0)
|
{
|
|
DataSet Ds;
|
ClsCN oCn = new ClsCN();
|
bool b = false;
|
Ds = oCn.RunProcReturn("Select HMaterID from Gy_RoutingBillMain Where HMaterID=" + BillNew.omodel.HMaterID.ToString(), "Gy_RoutingBillMain");
|
if (Ds.Tables[0].Rows.Count == 0)
|
{
|
b = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
|
if (b == false) return;
|
c++;
|
BillNew.CheckBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
|
}
|
MessageBox.Show("µ¼ÈëÍê±Ï:¹²"+c.ToString()+"¸ö¹¤ÒÕ·Ïß");
|
grdMain.DataSource = null;
|
}
|
c = 0;
|
}
|
|
//дÈëÀà ´Ó¿Ø¼þ
|
private bool WriteClass(int row)
|
{
|
string sHNumber = "";
|
string sHNamePoc = "";
|
string sHNumberProc = "";
|
string sHNumberCen = "";
|
Single sHWorkQty;
|
Single sHBeginDayQty;
|
Single sHBeginFixQty;
|
//long HItemID = 0;
|
int sCol = DBUtility.Gy_BaseFun.Fun_GetCol("²úÆ·´úÂë", grdMain);
|
int sColProc = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤Ðò´úÂë", grdMain);
|
int sHNamePocCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤ÐòÃû³Æ", grdMain);
|
int sCenCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤×÷ÖÐÐÄ´úÂë", grdMain);
|
//
|
sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sCol].Value);
|
sHNumberProc = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sColProc].Value);
|
sHNumberCen = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sCenCol].Value);
|
sHNamePoc = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sHNamePocCol].Value);
|
sHWorkQty = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[DBUtility.ClsPub.isInt(DBUtility.Gy_BaseFun.Fun_GetCol("¼Ó¹¤ÊýÁ¿", grdMain))].Value);
|
sHBeginDayQty = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[DBUtility.ClsPub.isInt(DBUtility.Gy_BaseFun.Fun_GetCol("±¾µÀ¹Ì¶¨¿ª¹¤ÌìÊý", grdMain))].Value);
|
sHBeginFixQty = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[DBUtility.ClsPub.isInt(DBUtility.Gy_BaseFun.Fun_GetCol("±¾µÀ¿ª¹¤ÓàÁ¿", grdMain))].Value);
|
//ÅжÏÊÇ·ñÔÊÐí ±£´æ
|
//ÉóºË´úÂëÊÇ·ñºÏÀí
|
//if (!DBUtility.ClsPub.AllowNumber(sHNumber))
|
//{
|
// MessageBox.Show("ÎïÁÏ´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
|
// return false;
|
//}
|
Model.ClsGy_RoutingBillSub oSub=new Model.ClsGy_RoutingBillSub();
|
|
//µÃµ½¹¤ÐòÄÚÂë
|
if (oProcHlp.GetInfoByNumber(sHNumberProc))
|
{
|
oSub.HProcID = oProcHlp.omodel.HItemID;
|
}
|
//else
|
//{
|
// oSub.HProcID = 0;
|
// MessageBox.Show("µÚ" + row.ToString() + "ÐÐ," + sHNumberProc + "ûÓÐÕÒµ½¶ÔÓ¦µÄ¹¤Ðò£¡");
|
// return false;
|
//}
|
|
//µÃµ½³µ¼äÄÚÂë
|
if (oCen.GetInfoByNumber(sHNumberCen))
|
{
|
oSub.HCenterID = oCen.omodel.HItemID;
|
}
|
//else
|
//{
|
// oProc.oModel.HDeptID = 0;
|
// MessageBox.Show("µÚ" + row.ToString() + "ÐÐ," + sHNumberCen + "ûÓÐÕÒµ½¶ÔÓ¦µÄ¹¤×÷ÖÐÐÄ£¡");
|
// return false;
|
//}
|
//дÈëÐÅÏ¢
|
oSub.HEntryID = j;
|
|
oSub.HProcNo = 0;
|
oSub.HUnitTime = 1;
|
oSub.HWorkQty = sHWorkQty;
|
oSub.HRemark = "";
|
oSub.HTimeUnit = "Сʱ";
|
oSub.HReadyTime = 0;
|
oSub.HQueueTime = 0;
|
oSub.HMoveTime = 0;
|
//
|
oSub.HCloseMan = "";
|
oSub.HCloseType = false;
|
oSub.HSourceInterID = 0;
|
oSub.HSourceEntryID = 0;
|
oSub.HSourceBillType = "";
|
oSub.HSourceBillNo ="";
|
oSub.HRelationQty = 0;
|
oSub.HRelationMoney = 0;
|
|
oSub.HFixPrice = 0;
|
oSub.HProcPrice = 0;
|
oSub.HBadPrice = 0;
|
oSub.HWasterPrice = 0;
|
oSub.HStdFlag = false;
|
oSub.HBeginDayQty = sHBeginDayQty;
|
oSub.HBeginFixQty = sHBeginFixQty;
|
|
BillNew.DetailColl.Add(oSub);
|
return true;
|
}
|
//¼ì²éÎïÁÏ
|
private bool Checkdata()
|
{
|
for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
|
{
|
string sHNumber = "";
|
string sHNamePoc = "";
|
string sHNumberProc = "";
|
string sHNumberCen = "";
|
int sCol = DBUtility.Gy_BaseFun.Fun_GetCol("²úÆ·´úÂë", grdMain);
|
int sColProc = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤Ðò´úÂë", grdMain);
|
int sHNamePocCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤ÐòÃû³Æ", grdMain);
|
int sCenCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤×÷ÖÐÐÄ´úÂë", grdMain);
|
//
|
sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sCol].Value);
|
sHNumberProc = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sColProc].Value);
|
sHNumberCen = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sCenCol].Value);
|
sHNamePoc = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sHNamePocCol].Value);
|
if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[0].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[3].Value) != "")
|
{
|
//
|
sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sCol].Value);
|
//ÉóºË´úÂëÊÇ·ñºÏÀí
|
if (!DBUtility.ClsPub.AllowNumber(sHNumber))
|
{
|
MessageBox.Show("ÎïÁÏ´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
|
return false;
|
}
|
if (!DBUtility.ClsPub.AllowNumber(sHNumberProc))
|
{
|
MessageBox.Show("¹¤Ðò´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
|
return false;
|
}
|
if (!DBUtility.ClsPub.AllowNumber(sHNumberCen))
|
{
|
MessageBox.Show("¹¤×÷ÖÐÐÄ´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
|
return false;
|
}
|
//µÃµ½ÎïÁÏÄÚÂë
|
int j = i + 2;
|
if (!oMaterHlp.GetInfoByNumber(sHNumber))
|
{
|
|
MessageBox.Show("µÚ" + j.ToString() + "ÐÐ," + sHNumber + "ûÓÐÕÒµ½¶ÔÓ¦µÄÎïÁÏ£¡");
|
return false;
|
}
|
//µÃµ½¹¤ÐòÄÚÂë
|
if (!oProcHlp.GetInfoByNumber(sHNumberProc))
|
{
|
MessageBox.Show("µÚ" + j.ToString() + "ÐÐ," + sHNumberProc + "ûÓÐÕÒµ½¶ÔÓ¦µÄ¹¤Ðò£¡");
|
return false;
|
}
|
|
//µÃµ½³µ¼äÄÚÂë
|
if (!oCen.GetInfoByNumber(sHNumberCen))
|
{
|
|
MessageBox.Show("µÚ" + j.ToString() + "ÐÐ," + sHNumberCen + "ûÓÐÕÒµ½¶ÔÓ¦µÄ¹¤×÷ÖÐÐÄ£¡");
|
return false;
|
|
}
|
return true;
|
|
}
|
}
|
return true;
|
|
}
|
}
|
}
|