using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace BLL
|
{
|
public partial class Gy_Material_Add : Form
|
{
|
|
public Int64 HItemID;
|
DAL.ClsGy_Material_Ctl oGroup = new DAL.ClsGy_Material_Ctl();
|
DAL.ClsGy_Material_View oGroupHlp = new DAL.ClsGy_Material_View();
|
|
public string ModName = "ÎïÁÏ";
|
public const string BillName = "Gy_Material";
|
public const string ModRightNameEdit = BillName + "_Edit";
|
public const string ModRightNameDelete = BillName + "_Delete";
|
|
public Gy_Material_Add()
|
{
|
InitializeComponent();
|
}
|
|
private void xz_Click(object sender, EventArgs e)
|
{
|
if (!WriteClass())
|
return;
|
if (Save())
|
{
|
MessageBox.Show("±£´æÍê±Ï£¡", "Ìáʾ");
|
}
|
else
|
{
|
MessageBox.Show("±£´æÊ§°Ü£¡ÔÒò£º" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
|
}
|
}
|
|
private bool AllowSave()
|
{
|
if (txtHNumber.Text.Trim() == "")
|
{
|
MessageBox.Show("ÎïÁÏ´úÂë²»ÄÜΪ¿Õ!", "Ìáʾ");
|
return false;
|
}
|
if (txtHName.Text.Trim() == "")
|
{
|
MessageBox.Show("ÎïÁÏÃû³Æ²»ÄÜΪ¿Õ!", "Ìáʾ");
|
return false;
|
}
|
//if (txtHModel.Text.Trim() == "")
|
//{
|
// MessageBox.Show("¹æ¸ñÐͺŲ»ÄÜΪ¿Õ!", "Ìáʾ");
|
// return false;
|
//}
|
//ÉóºË´úÂëÊÇ·ñºÏÀí
|
if (!DBUtility.ClsPub.AllowNumber(txtHNumber.Text.Trim()))
|
{
|
MessageBox.Show("´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
|
return false;
|
}
|
|
//ÊÇ·ñÖØ¸´´úÂë
|
if (oGroup.HavSameNumber(HItemID, txtHNumber.Text.Trim()))
|
{
|
MessageBox.Show("´úÂëÖØ¸´£¡", "Ìáʾ");
|
return false;
|
}
|
return true;
|
}
|
|
|
//дÈëÀà ´Ó¿Ø¼þ
|
private bool WriteClass()
|
{
|
//ÅжÏÊÇ·ñÔÊÐí ±£´æ
|
if (!AllowSave())
|
{
|
return false;
|
}
|
//¼ì²é¸¸¼¶ÊÇ·ñ´æÔÚ
|
string sParent;
|
sParent = DBUtility.ClsPub.GetParentCode(txtHNumber.Text.Trim());
|
if (sParent.Trim() == "")
|
{
|
oGroup.oModel.HParentID = 0;
|
}
|
else
|
{
|
if (oGroup.HavParentCode(sParent.Trim(), HItemID))
|
{
|
oGroup.oModel.HParentID = oGroup.oModel.HItemID;
|
}
|
else
|
{
|
MessageBox.Show("Éϼ¶´úÂë²»´æÔÚ»ò±»½ûÓã¡", "Ìáʾ");
|
return false;
|
}
|
}
|
//µÃµ½¶Ì´úÂë
|
string sShortNumber;
|
sShortNumber = DBUtility.ClsPub.GetShortNumber(txtHNumber.Text.Trim());
|
if (sShortNumber.Trim() == "")
|
{
|
return false;
|
}
|
//±£´æÔ´úÂë
|
if (oGroupHlp.GetInfoByID(HItemID))
|
{
|
oGroup.HOldNumber = oGroupHlp.omodel.HNumber;
|
//ÊÇ·ñдúÂëÊÇ×Ô¼º×ÓÏîÄ¿µÄ¡¡×ÓÏîÄ¿
|
if (sParent.Length >= oGroup.HOldNumber.Length)
|
{
|
if (sParent.Substring(0, oGroup.HOldNumber.ToString().Length) == oGroup.HOldNumber.Trim())
|
{
|
MessageBox.Show("дúÂë²»ÄÜÊÇ×Ô¼ºµÄϼ¶µÄ×ÓÏîÄ¿£¡", "Ìáʾ");
|
return false;
|
}
|
}
|
}
|
else
|
{
|
oGroup.HOldNumber = "";
|
}
|
//дÈëÐÅÏ¢
|
oGroup.oModel.HShortNumber = sShortNumber;
|
oGroup.oModel.HEndFlag = true;
|
oGroup.oModel.HLevel = DBUtility.ClsPub.GetLevel(txtHNumber.Text.Trim());
|
oGroup.oModel.HNumber = txtHNumber.Text.Trim();
|
oGroup.oModel.HHelpCode = txtHHelpCode.Text.Trim();
|
oGroup.oModel.HName = txtHName.Text.Trim();
|
oGroup.oModel.HStopflag = false;
|
oGroup.oModel.HRemark = txtHRemark.Text.Trim();
|
//--------------------
|
oGroup.oModel.HModel = txtHModel.Text.Trim();
|
oGroup.oModel.HUnitID = DBUtility.ClsPub.isLong(txtHUnitID.Tag);
|
oGroup.oModel.HMaterClsID = DBUtility.ClsPub.isLong(txtHMaterClsID.Tag);
|
oGroup.oModel.HMaterTypeID = DBUtility.ClsPub.isLong(txtHMaterTypeID.Tag);
|
oGroup.oModel.HUnitGroupID = DBUtility.ClsPub.isLong(txtHUnitGroupID.Tag);
|
oGroup.oModel.HWhID = DBUtility.ClsPub.isLong(txtHWhID.Tag);
|
oGroup.oModel.HRoutingID = DBUtility.ClsPub.isLong(txtHRoutingID.Tag);
|
oGroup.oModel.HBomID = DBUtility.ClsPub.isLong(txtHBomID.Tag);
|
oGroup.oModel.HSecUnitID = DBUtility.ClsPub.isLong(txtHSecUnitID.Tag);
|
oGroup.oModel.HSecUnitRate = DBUtility.ClsPub.isDoule(txtHSecUnitRate.Text);
|
oGroup.oModel.HHighStock = DBUtility.ClsPub.isDoule(txtHHighStock.Text);
|
oGroup.oModel.HLowStock = DBUtility.ClsPub.isDoule(txtHLowStock.Text);
|
oGroup.oModel.HSafeStock = DBUtility.ClsPub.isDoule(txtHSafeStock.Text);
|
oGroup.oModel.HOrderPrice = DBUtility.ClsPub.isDoule(txtHOrderPrice.Text);
|
oGroup.oModel.HSalePrice = DBUtility.ClsPub.isDoule(txtHSalePrice.Text);
|
oGroup.oModel.HKeepDays = DBUtility.ClsPub.isDoule(txtHKeepDays.Text);
|
oGroup.oModel.HPlanPrice = DBUtility.ClsPub.isDoule(txtHPlanPrice.Text);
|
oGroup.oModel.HstdPrice = DBUtility.ClsPub.isDoule(txtHstdPrice.Text);
|
oGroup.oModel.HQtyMin = DBUtility.ClsPub.isDoule(txtHQtyMin.Text);
|
oGroup.oModel.HQtyMax = DBUtility.ClsPub.isDoule(txtHQtyMax.Text);
|
oGroup.oModel.HVersion = txtHVersion.Text.Trim();
|
oGroup.oModel.HEngName = txtHEngName.Text.Trim();
|
oGroup.oModel.HEngModel = txtHEngModel.Text.Trim();
|
oGroup.oModel.HSubjoin = txtHSubjoin.Text.Trim();
|
oGroup.oModel.HSubjoin2 = txtHSubjoin2.Text.Trim();
|
oGroup.oModel.HColor = txtHColor.Text.Trim();
|
oGroup.oModel.HPropertyTypeID = DBUtility.ClsPub.isLong(txtHPropertyTypeID.Tag);
|
oGroup.oModel.HSPGroupID = DBUtility.ClsPub.isLong(txtHSPGroupID.Tag);
|
oGroup.oModel.HSPID = DBUtility.ClsPub.isLong(txtHSPID.Tag);
|
return true;
|
}
|
|
|
|
//±£´æ
|
private bool Save()
|
{
|
//ÅжÏȨÏÞ
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
|
{
|
return false;
|
}
|
//
|
if (oGroup.AddNew())
|
{
|
Init();
|
}
|
else
|
{
|
return false;
|
}
|
return true;
|
}
|
|
//³õʼ»¯½çÃæ
|
private bool Init()
|
{
|
Sub_Clear();
|
return true;
|
}
|
|
//ÐÂÔöʱÇå¿ÕÐÅÏ¢
|
private void Sub_Clear() //Lock
|
{
|
DBUtility.Gy_BaseFun.Sub_Clear(tabPage1, ref HItemID, txtHNumber);
|
}
|
|
private void cmdHUnitID_Click(object sender, EventArgs e)
|
{
|
BLL.ClsBaseSelect.SetTextByUnit(txtHUnitID);
|
}
|
|
private void cmdHUnitGroupID_Click(object sender, EventArgs e)
|
{
|
BLL.ClsBaseSelect.SetTextByUnitGroup(txtHUnitGroupID);
|
}
|
|
private void cmdHMaterClsID_Click(object sender, EventArgs e)
|
{
|
BLL.ClsBaseSelect.SetTextByMaterType(txtHMaterClsID);
|
}
|
|
private void cmdHWhID_Click(object sender, EventArgs e)
|
{
|
BLL.ClsBaseSelect.SetTextByWarehouse(txtHWhID);
|
}
|
|
private void cmdHSPGroupID_Click(object sender, EventArgs e)
|
{
|
BLL.ClsBaseSelect.SetTextByStockPlaceGroup(txtHSPGroupID);
|
}
|
|
private void cmdHSPID_Click(object sender, EventArgs e)
|
{
|
BLL.ClsBaseSelect.SetTextByStockPlace(txtHSPID);
|
}
|
|
private void cmdHRoutingID_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
private void cmdHSecUnitID_Click(object sender, EventArgs e)
|
{
|
BLL.ClsBaseSelect.SetTextByUnit(txtHSecUnitID);
|
}
|
|
private void cmdHPropertyTypeID_Click(object sender, EventArgs e)
|
{
|
BLL.ClsBaseSelect.SetTextByPropertyType(txtHPropertyTypeID);
|
}
|
|
private void txtHUnitID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHUnitID);
|
}
|
|
private void txtHUnitGroupID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHUnitGroupID);
|
}
|
|
private void txtHMaterClsID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHMaterClsID);
|
}
|
|
private void txtHMaterTypeID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHMaterTypeID);
|
}
|
|
private void txtHWhID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHWhID);
|
}
|
|
private void txtHSPGroupID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHSPGroupID);
|
}
|
|
private void txtHSPID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHSPID);
|
}
|
|
private void txtHRoutingID_TextChanged(object sender, EventArgs e)
|
{
|
|
}
|
|
private void txtHSecUnitID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHSecUnitID);
|
}
|
|
private void txtHPropertyTypeID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHPropertyTypeID);
|
}
|
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
}
|
}
|