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_MaterSP :BLL.Gy_DataInTmp
|
{
|
public Gy_DataIn_MaterSP()
|
{
|
InitializeComponent();
|
}
|
|
public int HMaterNumberCol = 0; //²úÆ·´úÂë
|
public int HSPNumberCol = 0; //²Öλ
|
//
|
public const int HBeginRow = 2; //ÓÐЧÊý¾Ý£¬¿ªÊ¼ÐÐÊý
|
//
|
DAL.ClsGy_MaterStockPlace_Ctl oMaterSP = new DAL.ClsGy_MaterStockPlace_Ctl();
|
DAL.ClsIF_StockPlace_View oSPHlp = new DAL.ClsIF_StockPlace_View();
|
DAL.ClsIF_Material_View oMaterHlp = new DAL.ClsIF_Material_View();
|
long j = -1;
|
int c = 0;
|
|
public override bool OpenExcelData()
|
{
|
base.sSheetName = txtHSheetName.Text;
|
return base.OpenExcelData();
|
}
|
|
/// <summary>
|
/// ³õʼ»¯½çÃæ
|
/// </summary>
|
public override void initData()
|
{
|
base.initData();
|
base.sSheetName = txtHSheetName.Text ;
|
base.ModRightName = "Gy_DataIn_MaterSP";
|
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;
|
//
|
//
|
}
|
//µ¼Èë
|
public override void Sub_DataIn()
|
{
|
string hnumber = "";
|
string HBillNo = "";
|
//
|
HMaterNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÎïÁϳ¤´úÂë", grdMain);
|
HSPNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("²Öλ", grdMain);
|
//ûÓÐÕÒµ½ÁÐ
|
if (HMaterNumberCol == -1)
|
{
|
MessageBox.Show("ûÓÐÕÒµ½¡¾ÎïÁϳ¤´úÂë¡¿µÄ±êÌâ", "Ìáʾ");
|
return;
|
}
|
if (HSPNumberCol == -1)
|
{
|
MessageBox.Show("ûÓÐÕÒµ½¡¾²Öλ¡¿µÄ±êÌâ", "Ìáʾ");
|
return;
|
}
|
//
|
if (!Checkdata())
|
{
|
return;
|
}
|
for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
|
{
|
string sHNumber = "";
|
if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value) != "")
|
{
|
//
|
//дÈëÀà
|
if (WriteClass(i))
|
{
|
//±£´æ¼Ç¼
|
if (!oMaterSP.AddNew())
|
{
|
MessageBox.Show("µ¼Èëʧ°Ü!ÔÒò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
|
return;
|
}
|
}
|
}
|
else
|
{
|
MessageBox.Show("ÎïÁÏ´úÂë»òÃû³ÆÎª¿Õ!ÔÒò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
|
return;
|
}
|
}
|
MessageBox.Show("µ¼ÈëÍê±Ï");
|
grdMain.DataSource = null;
|
}
|
|
//дÈëÀà ´Ó¿Ø¼þ
|
private bool WriteClass(int row)
|
{
|
string sHNumber = "";
|
string sHNameSP = "";
|
//
|
sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMaterNumberCol].Value);
|
sHNameSP = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HSPNumberCol].Value);
|
//ÅжÏÊÇ·ñÔÊÐí ±£´æ
|
|
Model.ClsGy_MaterStockPlace_Model oSub = new Model.ClsGy_MaterStockPlace_Model();
|
oMaterSP.DetailColl.Clear();
|
//µÃµ½²ÖλÄÚÂë
|
if (oSPHlp.GetInfoByNumber(sHNameSP))
|
{
|
oSub.HSPID = oSPHlp.omodel.HItemID;
|
}
|
|
//µÃµ½ÎïÁÏÄÚÂë
|
if (oMaterHlp.GetInfoByNumber(sHNumber))
|
{
|
oSub.HMaterID = oMaterHlp.omodel.HItemID;
|
}
|
//дÈëÐÅÏ¢
|
oSub.HSPGroupID = 0;
|
oSub.HDeptID = 0;
|
oSub.HQty = 1000000;
|
oSub.HStopflag = true;
|
oSub.HRemark = "";
|
oSub.HMaker = DBUtility.ClsPub.CurUserName;
|
oSub.HMakeDate = DBUtility.ClsPub.GetServerDate(-1);
|
|
oMaterSP.DetailColl.Add(oSub);
|
return true;
|
}
|
|
//¼ì²éÎïÁÏ
|
private bool Checkdata()
|
{
|
bool b=false;
|
string sErrMsg = "";
|
string sMsg = "";
|
for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
|
{
|
string sHNumber = "";
|
string sHNameSP = "";
|
|
//
|
sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value);
|
sHNameSP = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HSPNumberCol].Value);
|
if (sHNumber != "" )
|
{
|
//
|
//ÉóºË´úÂëÊÇ·ñºÏÀí
|
if (!DBUtility.ClsPub.AllowNumber(sHNumber))
|
{
|
MessageBox.Show("ÎïÁÏ´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
|
return false;
|
}
|
//µÃµ½ÎïÁÏÄÚÂë
|
int j = i + HBeginRow;
|
if (!oMaterHlp.GetInfoByNumber(sHNumber))
|
{
|
sMsg = "[" + sHNumber + "]ÎïÁϲ»´æÔÚ";
|
if (sErrMsg.Contains(sMsg)==false)
|
{
|
sErrMsg = sErrMsg + "[" + sHNumber + "]ÎïÁϲ»´æÔÚ\r\n" ;
|
}
|
b = true;
|
}
|
//µÃµ½²ÖλÄÚÂë
|
if (!oSPHlp.GetInfoByName(sHNameSP))
|
{
|
sMsg = "[" + sHNameSP + "]²Öλ²»´æÔÚ";
|
if (sErrMsg.Contains(sMsg) == false)
|
{
|
sErrMsg = sErrMsg + "[" + sHNameSP + "]²Öλ²»´æÔÚ\r\n";
|
}
|
b = true;
|
}
|
}
|
}
|
if (b == true)
|
{
|
Pub_Control.ErrMsgBox oMsgbox = new Pub_Control.ErrMsgBox();
|
oMsgbox.txtHErrMsg.Text = sErrMsg;
|
oMsgbox.ShowDialog();
|
return false;
|
}
|
else
|
{
|
return true;
|
}
|
|
}
|
|
}
|
}
|