duhe
2023-06-13 bff338f3b532b0bf2a8f3f2d6b662adb9a222f13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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_WIPBalance_QCAdd : Form
    {
        public CB_WIPBalance_QCAdd()
        {
            InitializeComponent();
        }
 
        public int HYear;
        public int HPeriod;
        long HMaterID;
        long HCostItemID;
        double HProdMoney;
        double HMaterMoney;
        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_WIPBalance_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);
            HProdMoney = DBUtility.ClsPub.isDoule(txtHProdMoney.Text);
            HMaterMoney = DBUtility.ClsPub.isDoule(txtHMaterMoney.Text);
            HMoney = DBUtility.ClsPub.isDoule(txtHMoney.Text);
            Ds = oCn.RunProcReturn("select * from CB_WIPBalance_QC where HYear=" + HYear + " and HPeriod=" + HPeriod + " and HMaterID=" + HMaterID, "CB_WIPBalance_QC");
            if (Ds.Tables[0].Rows.Count > 0)
            {
                if (MessageBox.Show("该产品已存在期初,是否覆盖?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    oCn.RunProc("delete CB_WIPBalance_QC where HYear=" + HYear + " and HPeriod=" + HPeriod + " and HMaterID=" + HMaterID);
                }
                else
                {
                    return; 
                }
            }
            oCn.RunProc("insert into  CB_WIPBalance_QC (HYear,HPeriod" +
                                ",HMaterID,HProdMoney_QC,HMaterMoney_QC,HMoney_QC" +
                                ") values (" +
                                HYear + "," + HPeriod + 
                                "," + HMaterID + "," + HProdMoney + "," + HMaterMoney + "," + HMoney + 
                                ")");
            MessageBox.Show("保存完毕!"); 
        } 
    }
}