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_StdWorkTimes : BLL.Gy_DataInTmp
|
{
|
public Gy_DataIn_StdWorkTimes()
|
{
|
InitializeComponent();
|
}
|
public int HItemIDCol = 0;
|
public int HMaterNumberCol = 0; //ÎïÁÏ´úÂë
|
public int HProcNumberCol = 0; //¹¤Ðò´úÂë
|
public int HStdWorkTimesCol = 0; //±ê×¼¹¤Ê±
|
public int HUpperlimitCol = 0; //ÉÏÏÞ±ÈÀý
|
public int HLowerlimitCol = 0; //ÏÂÏÞ±ÈÀý
|
public int HStdPieceCol = 0; //±ê×¼¼Æ¼þ
|
public int HStdPricCol = 0; //±ê×¼¼Æ¼Û
|
public int HUSEORGIDCol = 0; //×éÖ¯ID
|
public int HMakerCol = 0; //ÖÆµ¥ÈË
|
public int HMakeDateCol = 0; //ÖÆµ¥ÈÕÆÚ
|
//
|
public DAL.ClsGy_Process_View oProcHlp = new DAL.ClsGy_Process_View();
|
public DAL.ClsGy_StdWorkTimes_Ctl BillNew = new DAL.ClsGy_StdWorkTimes_Ctl();
|
DAL.ClsIF_Material_View oMaterHlp = new DAL.ClsIF_Material_View();
|
int c = 0;
|
|
public override bool OpenExcelData()
|
{
|
base.sSheetName = txtHSheetName.Text;
|
return base.OpenExcelData();
|
}
|
|
/// <summary>
|
/// ³õʼ»¯½çÃæ
|
/// </summary>
|
public override void initData()
|
{
|
base.initData();
|
base.sSheetName = "±ê×¼¹¤Ê±µ¼Èë";
|
base.ModRightName = "Gy_DataIn_StdWorkTimes";
|
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()
|
{
|
HStdWorkTimesCol = DBUtility.Gy_BaseFun.Fun_GetCol("±ê×¼¹¤Ê±", grdMain);
|
HProcNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤Ðò´úÂë", grdMain);
|
HMaterNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÎïÁÏ´úÂë", grdMain);
|
HUpperlimitCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÉÏÏß±ÈÀý", grdMain);
|
HLowerlimitCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÏÂÏß±ÈÀý", grdMain);
|
HStdPieceCol = DBUtility.Gy_BaseFun.Fun_GetCol("±ê×¼¼Æ¼þ", grdMain);
|
HStdPricCol = DBUtility.Gy_BaseFun.Fun_GetCol("±ê×¼¼Æ¼Û", grdMain);
|
|
//Åжϵ¼ÈëÎĵµÖÐÊÇ·ñ´æÔÚÒÔϱêÌâÁÐ
|
if (HStdWorkTimesCol == -1)
|
{
|
MessageBox.Show("ûÓÐÕÒµ½¡¾±ê×¼¹¤Ê±¡¿µÄ±êÌâ", "Ìáʾ");
|
return;
|
}
|
if (HProcNumberCol == -1)
|
{
|
MessageBox.Show("ûÓÐÕÒµ½¡¾¹¤Ðò´úÂë¡¿µÄ±êÌâ", "Ìáʾ");
|
return;
|
}
|
if (HMaterNumberCol == -1)
|
{
|
MessageBox.Show("ûÓÐÕÒµ½¡¾ÎïÁÏ´úÂë¡¿µÄ±êÌâ", "Ìáʾ");
|
return;
|
}
|
if (HUpperlimitCol == -1)
|
{
|
MessageBox.Show("ûÓÐÕÒµ½¡¾ÉÏÏß±ÈÀý¡¿µÄ±êÌâ", "Ìáʾ");
|
return;
|
}
|
if (HLowerlimitCol == -1)
|
{
|
MessageBox.Show("ûÓÐÕÒµ½¡¾ÏÂÏß±ÈÀý¡¿µÄ±êÌâ", "Ìáʾ");
|
return;
|
}
|
if (HStdPieceCol == -1)
|
{
|
MessageBox.Show("ûÓÐÕÒµ½¡¾±ê×¼¼Æ¼þ¡¿µÄ±êÌâ", "Ìáʾ");
|
return;
|
}
|
if (HStdPricCol == -1)
|
{
|
MessageBox.Show("ûÓÐÕÒµ½¡¾±ê×¼¼Æ¼Û¡¿µÄ±êÌâ", "Ìáʾ");
|
return;
|
}
|
//µ¼ÈëǰÊý¾ÝÊÇ·ñºÏÀíÅжÏ
|
if (!Checkdata())
|
{
|
return;
|
}
|
|
for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
|
{
|
//дÈëÀà
|
if (WriteClass(i))
|
{
|
bool b = false;
|
//±£´æ¼Ç¼
|
b = BillNew.AddNew();
|
if (b == false) return;
|
c++;
|
}
|
}
|
MessageBox.Show("µ¼ÈëÍê±Ï:¹²" + c.ToString() + "ÌõÊý¾Ý£¡");
|
grdMain.DataSource = null;
|
c = 0;
|
}
|
|
//дÈëÀà ´Ó¿Ø¼þ
|
private bool WriteClass(int row)
|
{
|
Model.ClsGy_StdWorkTimes_Model oSub = new Model.ClsGy_StdWorkTimes_Model();
|
BillNew.DetailColl.Clear();
|
string sHMaterNumber = "";
|
string sHProcNumber = "";
|
//
|
sHMaterNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMaterNumberCol].Value);
|
sHProcNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HProcNumberCol].Value);
|
|
//дÈëÐÅÏ¢
|
//µÃµ½ÎïÁÏÄÚÂë
|
if (oMaterHlp.GetInfoByNumber(sHMaterNumber))
|
{
|
oSub.HMaterID = oMaterHlp.omodel.HItemID;
|
}
|
//µÃµ½¹¤ÐòÄÚÂë
|
if (oProcHlp.GetInfoByNumber(sHProcNumber))
|
{
|
oSub.HProcID = oProcHlp.omodel.HItemID;
|
}
|
oSub.HRemark = "";
|
oSub.HStdWorkTimes = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[HStdWorkTimesCol].Value);
|
oSub.HUpperlimit = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[HUpperlimitCol].Value);
|
oSub.HLowerlimit = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[HLowerlimitCol].Value);
|
oSub.HStdPiece = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[HStdPieceCol].Value);
|
oSub.HStdPric = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[HStdPricCol].Value);
|
oSub.HUSEORGID = DBUtility.ClsPub.HOrgID;
|
oSub.HMaker = DBUtility.ClsPub.CurUserName;
|
oSub.HMakeDate = DateTime.Today.ToShortDateString();
|
BillNew.DetailColl.Add(oSub);
|
|
//·Ç×·¼Óģʽ£¬µ¼Èëǰ¸ù¾ÝÎïÁÏID¡¢¹¤ÐòID²éÕÒɾ³ý¶ÔÓ¦¼Ç¼
|
if (checkadd.Checked == false)
|
{
|
BillNew.DeleteByMaterIDAndHProcID(oSub.HMaterID, oSub.HProcID);
|
}
|
return true;
|
}
|
|
//¼ì²éµ¼ÈëÊý¾ÝÊÇ·ñºÏÀí
|
private bool Checkdata()
|
{
|
bool b = false;
|
string sErrMsg = "";
|
string sMsg = "";
|
for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
|
{
|
string sHMaterNumber = "";
|
string sHProcNumber = "";
|
double sHStdWorkTimes = 0;
|
double sHUpperlimit = 0;
|
double sHLowerlimit = 0;
|
double sHStdPiece = 0;
|
double sHStdPric = 0;
|
//
|
sHMaterNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value);
|
sHProcNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HProcNumberCol].Value);
|
sHStdWorkTimes = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[HStdWorkTimesCol].Value);
|
sHUpperlimit = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[HUpperlimitCol].Value);
|
sHLowerlimit = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[HLowerlimitCol].Value);
|
sHStdPiece = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[HStdPieceCol].Value);
|
sHStdPric = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[HStdPricCol].Value);
|
//
|
//ÉóºË´úÂëÊÇ·ñºÏÀí
|
if (!DBUtility.ClsPub.AllowNumber(sHMaterNumber))
|
{
|
sErrMsg = sErrMsg + "µÚ" + (i + 1).ToString() + "ÐÐ,ÎïÁÏ´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡\r\n";
|
b = true;
|
}
|
if (!DBUtility.ClsPub.AllowNumber(sHProcNumber))
|
{
|
sErrMsg = sErrMsg + "µÚ" + (i + 1).ToString() + "ÐÐ,¹¤Ðò´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡\r\n";
|
b = true;
|
}
|
|
//ÅжÏËùµ¼ÈëÊý¾ÝÊÇ·ñÕýÈ·
|
if (sHStdWorkTimes<=0)
|
{
|
sErrMsg = sErrMsg + "µÚ" + (i + 1).ToString() + "ÐÐ,±ê×¼¹¤Ê±²»ÄÜСÓÚ»òµÈÓÚ0£¡\r\n";
|
b = true;
|
}
|
if (sHUpperlimit < 0)
|
{
|
sErrMsg = sErrMsg + "µÚ" + (i + 1).ToString() + "ÐÐ,ÉÏÏÞ±ÈÀý²»ÄÜСÓÚ0£¡\r\n";
|
b = true;
|
}
|
if (sHLowerlimit < 0)
|
{
|
sErrMsg = sErrMsg + "µÚ" + (i + 1).ToString() + "ÐÐ,ÏÂÏÞ±ÈÀý²»ÄÜСÓÚ0£¡\r\n";
|
b = true;
|
}
|
if (sHStdPiece < 0)
|
{
|
sErrMsg = sErrMsg + "µÚ" + (i + 1).ToString() + "ÐÐ,±ê×¼¼Æ¼þ²»ÄÜСÓÚ0£¡\r\n";
|
b = true;
|
}
|
if (sHStdPric < 0)
|
{
|
sErrMsg = sErrMsg + "µÚ" + (i + 1).ToString() + "ÐÐ,±ê×¼¼Æ¼Û²»ÄÜСÓÚ0£¡\r\n";
|
b = true;
|
}
|
|
if (sHMaterNumber == "")
|
{
|
sErrMsg = sErrMsg + "µÚ" + (i + 1).ToString() + "ÐÐ,ÎïÁÏ´úÂë²»ÄÜΪ¿Õ£¡\r\n";
|
b = true;
|
}
|
else
|
{
|
//µÃµ½ÎïÁÏÄÚÂë
|
if (!oMaterHlp.GetInfoByNumber(sHMaterNumber))
|
{
|
sMsg = "[" + sHMaterNumber + "]ÎïÁϲ»´æÔÚ";
|
if (sErrMsg.Contains(sMsg) == false)
|
{
|
sErrMsg = sErrMsg + "[" + sHMaterNumber + "]ÎïÁϲ»´æÔÚ\r\n";
|
}
|
b = true;
|
}
|
}
|
|
if (sHProcNumber == "")
|
{
|
sErrMsg = sErrMsg + "µÚ" + (i + 1).ToString() + "ÐÐ,¹¤Ðò´úÂë²»ÄÜΪ¿Õ£¡\r\n";
|
b = true;
|
}
|
else
|
{
|
//µÃµ½¹¤ÐòÄÚÂë
|
if (!oProcHlp.GetInfoByNumber(sHProcNumber))
|
{
|
sMsg = "[" + sHProcNumber + "]¹¤Ðò²»´æÔÚ";
|
if (sErrMsg.Contains(sMsg) == false)
|
{
|
sErrMsg = sErrMsg + "[" + sHProcNumber + "]¹¤Ðò²»´æÔÚ\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;
|
}
|
}
|
|
private void Gy_DataIn_StdWorkTimes_Load(object sender, EventArgs e)
|
{
|
|
}
|
}
|
}
|