using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace PayM
|
{
|
public partial class Pay_SingleBalBill_YR : Form
|
{
|
public Pay_SingleBalBill_YR()
|
{
|
InitializeComponent();
|
}
|
|
public DAL.ClsPay_SingleBalBill BillNew = new DAL.ClsPay_SingleBalBill(); //¶ÔÓ¦µ¥¾ÝÀà
|
private void Pay_SingleBalBill_YR_Load(object sender, EventArgs e)
|
{
|
cmbHYear.Items.Clear();
|
//»ñÈ¡±¾ÆÚ³É±¾»á¼ÆÆÚ¼ä
|
int CurYear=0;
|
int CurPeriod=0;
|
if (DBUtility.ClsPub.Sub_GetCurPeriod(ref CurYear,ref CurPeriod) == false)
|
{
|
MessageBox.Show("»ñÈ¡³É±¾»á¼ÆÆÚ¼äʧ°Ü!");
|
return;
|
}
|
cmbHYear.Items.Add(CurYear);
|
cmbHYear.Items.Add(CurYear - 1);
|
cmbHYear.Items.Add(CurYear - 2);
|
cmbHYear.Items.Add(CurYear - 3);
|
cmbHYear.Items.Add("");
|
cmbHYear.SelectedIndex = 0;
|
cmbHPeriod.Text = CurPeriod.ToString();
|
}
|
|
private void button1_Click(object sender, EventArgs e)
|
{
|
SQLHelper.ClsCN oCn=new SQLHelper.ClsCN();
|
DataSet Ds;
|
Ds = oCn.RunProcReturn("select * from xt_AccountPeriod where HYear="+cmbHYear.Text+" and HPeriod="+cmbHPeriod.Text+" and HEndFlag=0", "xt_AccountPeriod",ref DBUtility.ClsPub.sErrInfo);
|
if (Ds == null)
|
{
|
MessageBox.Show("»ñÈ¡»á¼ÆÆÚ¼ä³ö´í£º"+DBUtility.ClsPub.sErrInfo);
|
return;
|
}
|
if (Ds.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("±¾»á¼ÆÆÚ¼äÒѽáÕË£¬²»ÔÊÐíÒýÈ룡" );
|
return;
|
}
|
|
Ds = oCn.RunProcReturn("select * from Pay_SingleBalBillMain where HSaveFlag=1 and HYear=" + cmbHYear.Text + " and HPeriod=" + cmbHPeriod.Text, "Pay_SingleBalBillMain", ref DBUtility.ClsPub.sErrInfo);
|
if (Ds == null)
|
{
|
MessageBox.Show("ÅжÏÊÇ·ñÒÑÒýÈë³ö´í£º" + DBUtility.ClsPub.sErrInfo);
|
return;
|
}
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
if (MessageBox.Show("±¾»á¼ÆÆÚ¼äÒÑÒýÈ룬ÊÇ·ñ¸²¸Ç£¿", "Ìáʾ", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
{
|
oCn.RunProc("delete Pay_SingleBalBillMain where HSaveFlag=1 and HYear=" + cmbHYear.Text + " and HPeriod=" + cmbHPeriod.Text);
|
}
|
else
|
{
|
return;
|
}
|
}
|
Ds = oCn.RunProcReturn("exec h_p_Pay_SingleBalBill_YR " + cmbHYear.Text + "," + cmbHPeriod.Text, "h_p_Pay_SingleBalBill_YR");
|
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
|
{
|
if (DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HPrice"]) == 0)
|
{
|
MessageBox.Show("ÎïÁÏ´úÂ룺" + Ds.Tables[0].Rows[i]["HMaterNumber"].ToString() + "£¬¹¤Ðò£º" + Ds.Tables[0].Rows[i]["HProcName"].ToString() + " ¹¤¼ÛΪ0£¬²»ÔÊÐíÒýÈ룡");
|
return;
|
}
|
}
|
bool bResult;
|
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
|
{
|
BillNew.omodel.HYear = DBUtility.ClsPub.isLong(cmbHYear.Text);
|
BillNew.omodel.HPeriod = DBUtility.ClsPub.isLong(cmbHPeriod.Text);
|
//¹Ì¶¨¸³Öµ=================================
|
BillNew.omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillNew.BillType, ref DBUtility.ClsPub.sExeReturnInfo, true); //ÔÚ¸³ÖµÀàǰ¾Í´¦ÀíºÃ×Ö·û´®ºÍÊý×Ö
|
BillNew.omodel.HDate = DBUtility.ClsPub.isDate(cmbHYear.Text + "-" + cmbHPeriod.Text + "-01");
|
BillNew.omodel.HRemark = "";
|
//====================================================
|
BillNew.omodel.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HGroupID"]);
|
BillNew.omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HDeptID"]);
|
BillNew.omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HEmpID"]);
|
BillNew.omodel.HPayType = 0;
|
BillNew.omodel.HExplanation = "";
|
BillNew.omodel.HInnerBillNo = "";
|
BillNew.omodel.HSaveFlag = true;
|
//Ã÷ϸÀำֵ
|
BillNew.DetailColl = new List<Model.ClsPay_SingleBalBillSub>();
|
|
Model.ClsPay_SingleBalBillSub oSub = new Model.ClsPay_SingleBalBillSub();
|
//¹Ì¶¨¸³Öµ========================================
|
oSub.HEntryID = 1;
|
oSub.HRemark = "";
|
oSub.HSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HInterID"]);
|
oSub.HSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HEntryID"]);
|
oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HBillType"]);
|
oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HBillNo"]);
|
oSub.HRelationQty = 0;
|
oSub.HRelationMoney = 0;
|
oSub.HCloseMan = "";
|
oSub.HEntryCloseDate = DBUtility.ClsPub.isDate("1900-01-01");
|
oSub.HCloseType = false;
|
//=============================
|
oSub.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HMaterID"]);
|
oSub.HProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcID"]);
|
oSub.HSourceID = 0;
|
oSub.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HEmpID"]);
|
oSub.HTimes = 0;
|
oSub.HQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HQty"]);
|
oSub.HPrice = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HPrice"]);
|
oSub.HPriceRate = 1;
|
|
oSub.HSubsidyTotal = 0;
|
oSub.HDeuctTotal = 0;
|
//
|
oSub.HSubsidyID = 0;
|
oSub.HDeuctID = 0;
|
|
oSub.HMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HMoney"]);
|
oSub.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HICMOInterID"]);
|
oSub.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HICMOBillNo"]);
|
oSub.HProcReportInterID = 0;
|
oSub.HProcReportEntryID = 0;
|
oSub.HProcReportBillNo = "";
|
oSub.HProcPlanInterID = 0;
|
oSub.HProcPlanEntryID = 0;
|
oSub.HProcPlanBillNo = "";
|
oSub.HPackQty = 0;
|
oSub.HPackPrice = 0;
|
oSub.HPackMoney = 0;
|
oSub.HPackMaterID = 0;
|
oSub.HSubsidyQty = 0;
|
oSub.HSubsidyMoney = 0;
|
oSub.HSqty = 0;
|
BillNew.DetailColl.Add(oSub);
|
|
bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
|
if(bResult==false)
|
{
|
MessageBox.Show("±£´æÊ§°Ü!ÔÒò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
|
oCn.RunProc("delete Pay_SingleBalBillMain where HSaveFlag=1 and HYear=" + cmbHYear.Text + " and HPeriod=" + cmbHPeriod.Text);
|
return;
|
}
|
}
|
MessageBox.Show("ÒýÈëÍê±Ï£¡");
|
this.Close();
|
}
|
|
private void button2_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
}
|
}
|