using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace CostM
|
{
|
public partial class CB_ActualPayBalance_QCAdd : Form
|
{
|
public CB_ActualPayBalance_QCAdd()
|
{
|
InitializeComponent();
|
}
|
|
public int HYear;
|
public int HPeriod;
|
long HMaterID;
|
long HCostItemID;
|
double HMoney;
|
private void cmdHMaterID_Click(object sender, EventArgs e)
|
{
|
|
DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View();
|
if (oMater.RefreshView())
|
{
|
txtHMaterID.Tag = oMater.omodel.HItemID;
|
txtHMaterID.Text = oMater.omodel.HNumber;
|
txtHMaterName.Text = oMater.omodel.HName;
|
}
|
else
|
{
|
txtHMaterID.Tag = 0;
|
txtHMaterID.Text = "";
|
txtHMaterName.Text = "";
|
}
|
}
|
|
private void txtHMaterID_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHMaterID.Text.Trim() == "")
|
txtHMaterID.Tag = "0";
|
}
|
|
private void cmdHCostItemID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_CostItem_View oCI = new DAL.ClsGy_CostItem_View();
|
if (oCI.RefreshView())
|
{
|
txtHCostItemID.Text = oCI.oModel.HName;
|
txtHCostItemID.Tag = oCI.oModel.HItemID;
|
}
|
else
|
{
|
txtHCostItemID.Text = "";
|
txtHCostItemID.Tag = 0;
|
}
|
}
|
|
private void txtHCostItemID_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHCostItemID.Text.Trim() == "")
|
txtHCostItemID.Tag = "0";
|
}
|
|
private void CB_ActualPayBalance_QCAdd_Load(object sender, EventArgs e)
|
{
|
|
//获取本期成本会计期间
|
if (DBUtility.ClsPub.Sub_CBGetCurPeriod() == false)
|
{
|
MessageBox.Show("获取成本会计期间失败!");
|
return;
|
}
|
cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear);
|
cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 1);
|
cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 2);
|
cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 3);
|
//cmbHYear.SelectedIndex = 0;
|
//cmdHPeriod.Text = DBUtility.ClsPub.CBCurPeriod.ToString();
|
cmbHYear.Text = DBUtility.ClsPub.isStrNull(HYear);
|
cmbHPeriod.Text = DBUtility.ClsPub.isStrNull(HPeriod);
|
}
|
|
private void button2_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private void button1_Click(object sender, EventArgs e)
|
{
|
//获取本期成本会计期间
|
if (DBUtility.ClsPub.Sub_CBGetCurPeriod() == false)
|
{
|
MessageBox.Show("获取成本会计期间失败!");
|
return;
|
}
|
//判断是否本期间
|
if (Pub_Class.ClsPub.isInt(cmbHYear.Text) != DBUtility.ClsPub.CBCurYear || Pub_Class.ClsPub.isInt(cmbHPeriod.Text) != DBUtility.ClsPub.CBCurPeriod)
|
{
|
MessageBox.Show("只能保存本期数据!");
|
return;
|
}
|
//
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet Ds;
|
HYear = DBUtility.ClsPub.isInt( cmbHYear.Text);
|
HPeriod = DBUtility.ClsPub.isInt(cmbHPeriod.Text);
|
HMaterID = DBUtility.ClsPub.isLong(txtHMaterID.Tag);
|
HCostItemID = DBUtility.ClsPub.isLong(txtHCostItemID.Tag);
|
HMoney = DBUtility.ClsPub.isDoule(txtHMoney.Text);
|
if (HMaterID == 0)
|
{
|
MessageBox.Show("物料不能为空!");
|
return;
|
}
|
if (HCostItemID == 0)
|
{
|
MessageBox.Show("成本项目不能为空!");
|
return;
|
}
|
Ds = oCn.RunProcReturn("select * from CB_ActualPayBalance_QC where HYear=" + HYear + " and HPeriod=" + HPeriod + " and HMaterID=" + HMaterID + " and HCostItemID=" + HCostItemID, "CB_ActualPayBalance_QC");
|
if (Ds.Tables[0].Rows.Count > 0)
|
{
|
if (MessageBox.Show("该产品对应成本项目已存在期初,是否覆盖?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
{
|
oCn.RunProc("delete CB_ActualPayBalance_QC where HYear=" + HYear + " and HPeriod=" + HPeriod + " and HMaterID=" + HMaterID + " and HCostItemID=" + HCostItemID);
|
}
|
else
|
{
|
return;
|
}
|
}
|
oCn.RunProc("insert into CB_ActualPayBalance_QC (HYear,HPeriod " +
|
" ,HMaterID,HCostItemID,HMoney_QC) values (" +
|
HYear + "," + HPeriod +
|
"," + HMaterID + "," + HCostItemID + "," + HMoney +
|
")");
|
MessageBox.Show("保存完毕!");
|
}
|
}
|
}
|