yangle
2023-03-03 c2a9a460e38c7c196fe98a94e29e6330eac3626f
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace OAM
{
    public partial class frmWorkBill : Form
    {
        public frmWorkBill()
        {
            InitializeComponent();
        }
        public const int HFileNameCol = 0;//huan
        public const int HFilePathCol = 1;
        public const int HUpManCol = 2;
        string BillType = "9005";
        public const int MainType = 2;
        private void cmdSelectEmps_Click(object sender, EventArgs e)
        {
            DBUtility.Gy_UserSelect oUser = new DBUtility.Gy_UserSelect();
            oUser.bSingle = true;
            oUser.ShowDialog();
            if (oUser.IsOk == 1)
            {
                txtrOperator.Text = oUser.sReturn;
            }
            else
            {
                txtrOperator.Text = "";
            }
        }
 
        private void cmdCheckFlow_Click(object sender, EventArgs e)
        {
 
        }
 
        private void cmdSelectEmps2_Click(object sender, EventArgs e)
        {
            DBUtility.Gy_UserSelect oUser = new DBUtility.Gy_UserSelect();
            oUser.bSingle = false;
            oUser.ShowDialog();
            if (oUser.IsOk == 1)
            {
                txtRoperator2.Text = oUser.sReturn;
            }
            else
            {
                txtRoperator2.Text = "";
            }
        }
 
        private void cmdAdd_Click(object sender, EventArgs e)//huan
        {
            OpenFileDialog oDlg = new OpenFileDialog();
            oDlg.Filter = "所有文件|*.*";
            if (oDlg.ShowDialog() == DialogResult.OK)
            {
                if (oDlg.FileName != "")
                {
                    grdMain.Rows.Add();
                    grdMain.Rows[grdMain.Rows.Count - 1].Cells[HFileNameCol].Value = oDlg.SafeFileName;
                    grdMain.Rows[grdMain.Rows.Count - 1].Cells[HFilePathCol].Value = oDlg.FileName;
                    grdMain.Rows[grdMain.Rows.Count - 1].Cells[HUpManCol].Value = DBUtility.ClsPub.CurUserName;
                }
            }
        }
 
        private void cmdSend_Click(object sender, EventArgs e)
        {
            //DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath);//huan
            if (txtContext.Text == "")
            {
                MessageBox.Show("请录入主题");
                return;
            }
            if (txtrOperator.Text == "")
            {
                if (MessageBox.Show("接受人尽量不要为空?是否确认要使用空接受人?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                {
                    return;
                }
            }
            if (Add())
            {
                DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath);
                this.Close();
            }
        }
 
        private void cmdCancel_Click(object sender, EventArgs e)
        {
            DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); //huan
            this.Close();
        }
        private bool Add()
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            long MainID;
            MainID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo); 
            string Context = txtContext.Text.Replace("'", "‘");
            string Desc = txtDesc.Text.Replace("'", "‘");
            if (rdbGG.Checked == true)
            {
                oCn.RunProc("Insert into oa_workbillmain(id,operator,context,description" +
                                                    ",opdate,roperator,ispublic,roperator2,fdate,HBillType" +
                                                    ",HBillNo,HCommDate,HLevel,HEvaluateStatus,HRemark,hcheckflowmainid,HBillStatus) " +
                                                    " values (" +
                                                    MainID + ",'" + DBUtility.ClsPub.CurUserName + "','" + Context + "'" +
                                                    ",'" + Desc + "',getdate(),'" + txtrOperator.Text + "',1,'" + txtRoperator2.Text + "',getdate(),4501" +
                                                    ",'" + txtHBillNo.Text + "','" + DtpHCommDate.Value + "','" + cmbHLevel.Text + "','" + cmbHEvaluateStatus.Text + "','" + txtHRemark.Text + "',0,2)");
            }
            else
            {
                oCn.RunProc("Insert into oa_workbillmain(id,operator,context,description" +
                                                     ",opdate,roperator,ispublic,roperator2,fdate,HBillType" +
                                                     ",HBillNo,HCommDate,HLevel,HEvaluateStatus,HRemark,hcheckflowmainid,HBillStatus) " +
                                                     " values (" +
                                                     MainID + ",'" + DBUtility.ClsPub.CurUserName + "','" + Context + "'" +
                                                     ",'" + Desc + "',getdate(),'" + txtrOperator.Text + "',0,'" + txtRoperator2.Text + "',getdate(),4501" +
                                                     ",'" + txtHBillNo.Text + "','" + DtpHCommDate.Value + "','" + cmbHLevel.Text + "','" + cmbHEvaluateStatus.Text + "','" + txtHRemark.Text + "',0,2)");
            }
            oCn.RunProc("Insert into oa_workbillsub(id,mainid,operator,context,opdate)" +
                                            " values (" +
                                            "-1," + MainID + ",'" + DBUtility.ClsPub.CurUserName + "','" + Context + "',getdate())");
            if (txtRoperator2.Text != "")
            {
                string[] s = txtRoperator2.Text.Split(',');
                int len = s.Length;
                for (int i = 0; i < len; i++)
                {
                    int j = i + 2;
                    string k = s[i].ToString();
                    oCn.RunProc("insert into oa_workbillsub2 (MainID,SubID,ROperator,isRead,isKnow) " +
                                "values (" +
                                MainID + "," + j + ",'" + k + "',0,0)");
                }
            }
            oCn.RunProc("insert into oa_workbillsub2 (MainID,SubID,ROperator,isRead,isKnow) " +
                           "values (" +
                           MainID + ",1,'" + txtrOperator.Text + "',0,0)");
            //上传附件
            BLL.ClsXt_FileCtrl oFile = new BLL.ClsXt_FileCtrl();
            for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
            {
                if (oFile.LoadUpFile(MainID, MainType, DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HFilePathCol].Value), 0,
                    DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HFileNameCol].Value), DBUtility.ClsPub.CurUserName) == false)
                {
                    MessageBox.Show("上传文件时失败!");
                }
            }
            //
            return true;
        }
 
        private void frmWorkBill_Load(object sender, EventArgs e)
        { 
            this.txtHBillNo.Text = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//得到新单号 
            initGrid();//huan
        }
 
        public void initGrid()//huan
        {
            grdMain.ColumnCount = 3;                       //总列数
            DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name);
            grdMain.ReadOnly = true;
            grdMain.RowCount = 0;
            //= 
            grdMain.Columns[HFileNameCol].HeaderText = "文件名称";
            grdMain.Columns[HFilePathCol].HeaderText = "文件路径";
            grdMain.Columns[HUpManCol].HeaderText = "上传人";
            DBUtility.ClsPub.GetGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath);
        }
 
        private void cmdDel_Click(object sender, EventArgs e) //huan
        {
            if (grdMain.CurrentRow == null)
            {
                return;
            }
            grdMain.Rows.RemoveAt(grdMain.CurrentRow.Index);
        }
    }
}