using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace BaseSet
|
{
|
public partial class Gy_DataIn_BOM_K3 :BLL.Gy_DataInTmp
|
{
|
public Gy_DataIn_BOM_K3()
|
{
|
InitializeComponent();
|
}
|
|
public int HMaterIDCol =1; //²úÆ·´úÂë
|
public int HJJGCol = 4; //»ú¼Ó¹¤´úÂë
|
public int HMPCol = 7; //ëÅ÷ID
|
public int HCLCol = 11; //²ÄÁÏ´úÂë
|
//
|
public const int HBeginRow = 0; //ÓÐЧÊý¾Ý£¬¿ªÊ¼ÐÐÊý
|
//
|
public DAL.ClsGy_ICBomBill_K3 BillNew = new DAL.ClsGy_ICBomBill_K3();
|
public DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View();
|
|
/// <summary>
|
/// ³õʼ»¯½çÃæ
|
/// </summary>
|
public override void initData()
|
{
|
base.initData();
|
base.sSheetName = "Sheet1";
|
base.ModRightName = "Gy_DataIn_BOM_K3";
|
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 = "K3BOMµ¼Èë";
|
this.Text = base.ModCaption;
|
lblCaption.Text = base.ModCaption;
|
//
|
//DBUtility.Gy_BaseFun.SetComboxYear(cmbHYear);
|
//DBUtility.Gy_BaseFun.SetComboxPeriod(cmbHPeriod);
|
//
|
}
|
|
public override void Sub_DataIn()
|
{
|
//base.Sub_DataIn();
|
//
|
int m = 0;
|
string smsg = "";
|
bool b = false;
|
//ɾ³ý Ïàͬ»á¼ÆÆÚ¼ä£¬Ïàͬ·ÑÓÃÏîÄ¿£¬µÄËùÓмǼ
|
for (int i = HBeginRow; i <= grdMain.Rows.Count - 1; i++)
|
{
|
if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterIDCol].Value) != "")
|
{
|
//дÈëÀà
|
if (WriteClass(i))
|
{
|
//±£´æ¼Ç¼
|
if (!BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
smsg = smsg + ",," + i.ToString();
|
}
|
else
|
{
|
m++;
|
}
|
}
|
else
|
{
|
smsg = smsg + ",," + i.ToString();
|
}
|
}
|
//
|
if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HJJGCol].Value) != "")
|
{
|
//дÈëÀà
|
if (WriteClass2(i))
|
{
|
//±£´æ¼Ç¼
|
if (!BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
smsg = smsg + "," + i.ToString();
|
}
|
else
|
{
|
m++;
|
}
|
}
|
else
|
{
|
smsg = smsg + "," + i.ToString();
|
}
|
}
|
if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMPCol].Value) != "")
|
{
|
if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HCLCol].Value) != "")
|
{
|
//дÈëÀà
|
if (WriteClass3(HMPCol,i))
|
{
|
m++;
|
}
|
else
|
{
|
smsg = smsg + "," + i.ToString();
|
}
|
}
|
}
|
}
|
MessageBox.Show("µ¼ÈëÍê±Ï" + smsg + " || " + m.ToString());
|
grdMain.DataSource = null;
|
}
|
|
//дÈëÀà ´Ó¿Ø¼þ
|
private bool WriteClass(int row)
|
{
|
//ÅжÏÊÇ·ñÔÊÐí ±£´æ
|
//µÃµ½Òµ»§ÄÚÂ룬·ÑÓÃÏîÄ¿ÄÚÂë
|
SQLHelper.ClsCNK3 oK3Cn = new SQLHelper.ClsCNK3();
|
DataSet Ds;
|
string sBillNo = "";
|
Ds = oK3Cn.RunProcReturn("exec HX_GetICBillNo 1,50", "t_billcodeby");
|
if (Ds.Tables[0].Rows.Count == 0 || Ds == null)
|
{
|
return false;
|
}
|
sBillNo = Ds.Tables[0].Rows[0][0].ToString().Trim();
|
//дÈëÐÅÏ¢
|
BillNew.omodel.HYear = 2011;
|
BillNew.omodel.HPeriod = 1;
|
BillNew.omodel.HBillNo = sBillNo;
|
BillNew.omodel.HDate = DateTime.Today;
|
BillNew.omodel.HRemark = "BOMµ¼Èë";
|
//
|
BillNew.omodel.HParentID = DBUtility.ClsPub.isLong(this.txtHICBOMGroupID.Tag);
|
BillNew.omodel.HVersion = "1";
|
BillNew.omodel.HStatus = "";
|
BillNew.omodel.HPicNo = "";
|
|
if (oMater.GetInfoByNumber(DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMaterIDCol].Value)))
|
{
|
BillNew.omodel.HMaterID = oMater.omodel.HItemID;
|
BillNew.omodel.HUnitID = oMater.omodel.HUnitID;
|
}
|
else
|
{
|
BillNew.omodel.HMaterID = 0;
|
BillNew.omodel.HUnitID = 0;
|
return false;
|
}
|
BillNew.omodel.HMaterTypeID = 0;
|
BillNew.omodel.HPropertyID = 0;
|
BillNew.omodel.HQty = 1;
|
BillNew.omodel.HProdRate = 100;
|
BillNew.omodel.HJump = "1059";
|
//
|
//BillNew.HExRate = ClsPub.isDoule(this.txtHMaterName.Text.ToString());
|
//Ã÷ϸÀำֵ
|
BillNew.DetailColl = new List<Model.ClsGy_ICBomBillSub_K3>();
|
if (DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMaterIDCol].Value) != "")
|
{
|
if (DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HJJGCol].Value) != "")
|
{
|
Model.ClsGy_ICBomBillSub_K3 oSub = new Model.ClsGy_ICBomBillSub_K3();
|
oSub.HEntryID = 1;
|
//
|
if (oMater.GetInfoByNumber(DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HJJGCol].Value)))
|
{
|
oSub.HMaterID = oMater.omodel.HItemID;
|
oSub.HUnitID = oMater.omodel.HUnitID;
|
}
|
else
|
{
|
oSub.HMaterID = 0;
|
oSub.HUnitID = 0;
|
return false;
|
}
|
oSub.HChildType = "";
|
oSub.HQty = 1;
|
oSub.HRelQty = 1;
|
oSub.HWasteRate = 0;
|
oSub.HWhID = 0;
|
oSub.HProcID = 0;
|
oSub.HRemark2 = "";
|
oSub.HRemark3 = "";
|
oSub.HRemark4 = "";
|
//
|
oSub.HRemark = "";
|
oSub.HSourceInterID = 0;
|
oSub.HSourceEntryID = 0;
|
oSub.HSourceBillType = "";
|
oSub.HSourceBillNo = "";
|
oSub.HRelationQty = 0;
|
oSub.HRelationMoney = 0;
|
BillNew.DetailColl.Add(oSub);
|
return true;
|
}
|
else if (DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMPCol].Value) != "")
|
{
|
Model.ClsGy_ICBomBillSub_K3 oSub = new Model.ClsGy_ICBomBillSub_K3();
|
oSub.HEntryID =1;
|
//
|
if (oMater.GetInfoByNumber(DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMPCol].Value)))
|
{
|
oSub.HMaterID = oMater.omodel.HItemID;
|
oSub.HUnitID = oMater.omodel.HUnitID;
|
}
|
else
|
{
|
oSub.HMaterID = 0;
|
oSub.HUnitID = 0;
|
return false;
|
}
|
oSub.HChildType = "";
|
oSub.HQty = 1;
|
oSub.HRelQty = 1;
|
oSub.HWasteRate = 0;
|
oSub.HWhID = 0;
|
oSub.HProcID = 0;
|
oSub.HRemark2 = "";
|
oSub.HRemark3 = "";
|
oSub.HRemark4 = "";
|
//
|
oSub.HRemark = "";
|
oSub.HSourceInterID = 0;
|
oSub.HSourceEntryID = 0;
|
oSub.HSourceBillType = "";
|
oSub.HSourceBillNo = "";
|
oSub.HRelationQty = 0;
|
oSub.HRelationMoney = 0;
|
BillNew.DetailColl.Add(oSub);
|
return true;
|
}
|
}
|
return true;
|
}
|
|
//дÈëÀà ´Ó¿Ø¼þ2
|
private bool WriteClass2(int row)
|
{
|
//ÅжÏÊÇ·ñÔÊÐí ±£´æ
|
//µÃµ½Òµ»§ÄÚÂ룬·ÑÓÃÏîÄ¿ÄÚÂë
|
SQLHelper.ClsCNK3 oK3Cn = new SQLHelper.ClsCNK3();
|
DataSet Ds;
|
string sBillNo = "";
|
Ds = oK3Cn.RunProcReturn("exec HX_GetICBillNo 1,50", "t_billcodeby");
|
if (Ds.Tables[0].Rows.Count == 0 || Ds == null)
|
{
|
return false;
|
}
|
sBillNo = Ds.Tables[0].Rows[0][0].ToString().Trim();
|
//дÈëÐÅÏ¢
|
BillNew.omodel.HYear = 2011;
|
BillNew.omodel.HPeriod = 1;
|
BillNew.omodel.HBillNo = sBillNo;
|
BillNew.omodel.HDate = DateTime.Today;
|
BillNew.omodel.HRemark = "BOMµ¼Èë";
|
//
|
BillNew.omodel.HParentID = DBUtility.ClsPub.isLong(this.txtHICBOMGroupID.Tag);
|
BillNew.omodel.HVersion = "1";
|
BillNew.omodel.HStatus = "";
|
BillNew.omodel.HPicNo = "";
|
BillNew.omodel.HMaterTypeID = 0;
|
BillNew.omodel.HPropertyID = 0;
|
if (oMater.GetInfoByNumber(DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HJJGCol].Value)))
|
{
|
BillNew.omodel.HMaterID = oMater.omodel.HItemID;
|
BillNew.omodel.HUnitID = oMater.omodel.HUnitID;
|
}
|
else
|
{
|
BillNew.omodel.HMaterID = 0;
|
BillNew.omodel.HUnitID = 0;
|
return false;
|
}
|
BillNew.omodel.HQty = 1;
|
BillNew.omodel.HProdRate = 100;
|
BillNew.omodel.HJump = "1059";
|
//
|
//BillNew.HExRate = ClsPub.isDoule(this.txtHMaterName.Text.ToString());
|
//Ã÷ϸÀำֵ
|
BillNew.DetailColl = new List<Model.ClsGy_ICBomBillSub_K3>();
|
if (DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HJJGCol].Value) != "")
|
{
|
if (DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMPCol].Value) != "")
|
{
|
Model.ClsGy_ICBomBillSub_K3 oSub = new Model.ClsGy_ICBomBillSub_K3();
|
oSub.HEntryID = 1;
|
//
|
if (oMater.GetInfoByNumber(DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMPCol].Value)))
|
{
|
oSub.HMaterID = oMater.omodel.HItemID;
|
oSub.HUnitID = oMater.omodel.HUnitID;
|
}
|
else
|
{
|
oSub.HMaterID = 0;
|
oSub.HUnitID = 0;
|
return false;
|
}
|
oSub.HChildType = "";
|
oSub.HQty = 1;
|
oSub.HRelQty = 1;
|
oSub.HWasteRate = 0;
|
oSub.HWhID = 0;
|
oSub.HProcID = 0;
|
oSub.HRemark2 = "";
|
oSub.HRemark3 = "";
|
oSub.HRemark4 = "";
|
//
|
oSub.HRemark = "";
|
oSub.HSourceInterID = 0;
|
oSub.HSourceEntryID = 0;
|
oSub.HSourceBillType = "";
|
oSub.HSourceBillNo = "";
|
oSub.HRelationQty = 0;
|
oSub.HRelationMoney = 0;
|
BillNew.DetailColl.Add(oSub);
|
return true;
|
}
|
else if (DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HCLCol].Value) != "")
|
{
|
WriteClass3(HJJGCol, row);
|
return true;
|
}
|
}
|
return true;
|
}
|
|
//дÈëÀà ´Ó¿Ø¼þ3 ²ÄÁÏ
|
private bool WriteClass3(int HCol, int row)
|
{
|
//ÅжÏÊÇ·ñÔÊÐí ±£´æ
|
//µÃµ½Òµ»§ÄÚÂ룬·ÑÓÃÏîÄ¿ÄÚÂë
|
SQLHelper.ClsCNK3 oK3Cn = new SQLHelper.ClsCNK3();
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet Ds;
|
string sBillNo = "";
|
long HInterID = 0;
|
long HMaterID = 0;
|
long HClID = 0;
|
long HCLUnitID = 0;
|
Ds = oK3Cn.RunProcReturn("exec HX_GetICBillNo 1,50", "t_billcodeby");
|
if (Ds.Tables[0].Rows.Count == 0 || Ds == null)
|
{
|
return false;
|
}
|
sBillNo = Ds.Tables[0].Rows[0][0].ToString().Trim();
|
///
|
Ds = oK3Cn.RunProcReturn("declare @InterID int set @InterID=0 exec GetICMaxNum 'ICBom', @InterID output, 1, 16394 select ltrim(@InterID)", "GetICMaxNum");
|
HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]) + 10000000;
|
//дÈëÐÅÏ¢
|
if (oMater.GetInfoByNumber(DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HCol].Value)))
|
{
|
HMaterID = oMater.omodel.HItemID;
|
}
|
else
|
{
|
return false;
|
}
|
if (oMater.GetInfoByNumber(DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HCLCol].Value)))
|
{
|
HClID = oMater.omodel.HItemID;
|
HCLUnitID=oMater.omodel.HUnitID;
|
}
|
else
|
{
|
return false;
|
}
|
oCn.RunProc("exec h_p_ICBomAdd_K3 " + HInterID.ToString() + ",'" + sBillNo + "'," + DBUtility.ClsPub.isLong(this.txtHICBOMGroupID.Tag).ToString() + "," + HMaterID.ToString() + "," + HClID.ToString() + "," + HCLUnitID.ToString());
|
return true;
|
}
|
|
private void cmdHBOMGroupID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsK3_ICBOMGroup_View oBOMGroupID = new DAL.ClsK3_ICBOMGroup_View();
|
if (oBOMGroupID.RefreshView())
|
{
|
this.txtHICBOMGroupID.Text = oBOMGroupID.oModel.HName;
|
this.txtHICBOMGroupID.Tag = oBOMGroupID.oModel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHICBOMGroupID.Text = "";
|
}
|
}
|
|
private void txtHICBOMGroupID_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHICBOMGroupID.Text.Trim() == "")
|
{
|
txtHICBOMGroupID.Tag = "0";
|
}
|
}
|
|
|
}
|
}
|