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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace EAM
{
    public partial class Sc_MouldCost4 : Form
    {
        public int HCode;
        public string HPathBakServer;
        public string HHardDisk;
        public int HDelDays;
 
        public string HBDeptNumber;
        public string HEDeptNumber;
        public int HDeptType;    //ÎïÁ϶Î
        public int HSetType=0;    //ºËË㷽ʽ
        public int HYear;       //»á¼ÆÄê
        public int HPeriod;     //»á¼ÆÔÂ
 
        public Sc_MouldCost4()
        {
            InitializeComponent();
        }
 
        private void Sc_MouldCost4_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            HCode=1;
            this.Hide();
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            HCode = 2;
            this.Hide();
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            HCode = 3;
            this.Hide();
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
             
            timer1.Enabled = false;
            SetMateStdPrice();
        }
 
        //ÅжϺËËãÐÅÏ¢
        private bool AllowBegin()
        {
            return true;
        }
        //ºËËã
        private void SetMateStdPrice()
        {
            if (!AllowBegin())
            {
                MessageBox.Show("ÄúÉèÖúËËãÐÅÏ¢ÓдíÎ󣬲»ÄܽøÐкËË㣡ÇëÓë¹ÜÀíÔ±ÁªÏµ");
                return;
            }
            //ºËËãÀàÐÍ
            switch (HSetType)
            {
                case 0://°´²úÖµ
                    SetMateStdPrice_CZ();
                    break;
                case 1://°´²úÁ¿
                    break;
                case 2://×îÐÂ
                    break;
                default:
                    break;
            }
 
        }
        //°´²úÖµ
        private void SetMateStdPrice_CZ()
        {
            //µÃµ½ºËËãµÄ ²úÆ·ID£¬·ÑÓÃÏîÄ¿ID£¬±¾µ¥·ÑÓÃ=±¾ÆÚÈë¿â½ð¶î/±¾ÆÚÈë¿â×ܽð¶î*±¾ÆÚ·ÑÓýð¶î£¬×Ü·ÑÓ㬱ÈÀý=±¾µ¥·ÑÓÃ/±¾ÆÚ·ÑÓýð¶î
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DataSet oDs;
            oDs = oCn.RunProcReturn("exec h_p_Sc_MouldCost " + HYear + "," + HPeriod, "gy_czygl");
            if (oDs == null || oDs.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("´íÎóµÄºËËãÏîÄ¿£¡");
                return;
            }
            pb1.Maximum = oDs.Tables[0].Rows.Count;
            pb1.Value = 0;
            //ɾ³ý±¾ÆÚ¼Ç¼
            oCn.RunProc("delete Sc_MouldItemMoneyCost where HYear=" + HYear + " and HPeriod=" + HPeriod);
            for (int i = 0; i < oDs.Tables[0].Rows.Count; i++)
            {
                System.Windows.Forms.Application.DoEvents();
                
                //ÐÂÔö¼Ç¼
                oCn.RunProc("insert into Sc_MouldItemMoneyCost " + "(HYear,HPeriod,HMaterID,HQty,HPrice" +
               ",HMoney,HSumMoney,hrate,HMaker,HMakeDate" +
               ")values(" + HYear + "," + HPeriod + "," + oDs.Tables[0].Rows[i]["HMaterID"].ToString() + 
               "," + oDs.Tables[0].Rows[i]["HQty"].ToString() + "," + oDs.Tables[0].Rows[i]["HPrice"].ToString() +
               "," + oDs.Tables[0].Rows[i]["HMoney"].ToString() + "," + oDs.Tables[0].Rows[i]["HSumMoney"].ToString() + "," + oDs.Tables[0].Rows[i]["hrate"].ToString() +
               ",'" + DBUtility.ClsPub.CurUserName + "','" + DateTime.Today + "'" +
               ")");             
                System.Windows.Forms.Application.DoEvents();
                pb1.Value = i + 1;
                lblHCount.Text = pb1.Value.ToString() + "/" + pb1.Maximum.ToString();
                System.Windows.Forms.Application.DoEvents();
            }
        }
       
    }
}