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 frmFK : Form
|
{
|
public frmFK()
|
{
|
InitializeComponent();
|
}
|
|
public const int HFileNameCol = 0;//huan
|
public const int HFilePathCol = 1;
|
public const int HUpManCol = 2;
|
string BillType = "9004";
|
|
public const int MainType = 1;
|
|
private void cmdHReceiveMan_Click(object sender, EventArgs e)
|
{
|
DBUtility.Gy_UserSelect oUser = new DBUtility.Gy_UserSelect();
|
oUser.bSingle = true;
|
oUser.ShowDialog();
|
if (oUser.IsOk == 1)
|
{
|
txtHReceiveMan.Text = oUser.sReturn;
|
}
|
else
|
{
|
txtHReceiveMan.Text = "";
|
}
|
}
|
|
private void cmdHCopyMan_Click(object sender, EventArgs e)
|
{
|
DBUtility.Gy_UserSelect oUser = new DBUtility.Gy_UserSelect();
|
oUser.bSingle = false;
|
oUser.ShowDialog();
|
if (oUser.IsOk == 1)
|
{
|
txtHCopyMan.Text = oUser.sReturn;
|
}
|
else
|
{
|
txtHCopyMan.Text = "";
|
}
|
}
|
|
private void cmdHErrTypeID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_ErrType_View oET = new DAL.ClsGy_ErrType_View();
|
if (oET.RefreshView())
|
{
|
this.txtHErrTypeID.Text = oET.oModel.HName;
|
this.txtHErrTypeID.Tag = oET.oModel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHErrTypeID.Text = "";
|
}
|
}
|
|
private void cmdAdd_Click(object sender, EventArgs e)//huanxin
|
{
|
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)
|
{
|
if (txtHContext.Text == "")
|
{
|
MessageBox.Show("请录入主题");
|
return;
|
}
|
if (txtHReceiveMan.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 bool Add()
|
{
|
string sDate;
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
long MainID;
|
MainID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
|
sDate = DateTime.Now.ToString();
|
string Context = txtHContext.Text.Replace("'", "‘");
|
string Desc = txtDesc.Text.Replace("'", "‘");
|
string PlanNo = txtHPlanNo.Text.Replace("'", "‘");
|
string ItemModel = txtHItemModel.Text.Replace("'", "‘");
|
long HErrTypeID =DBUtility.ClsPub.isLong( txtHErrTypeID.Tag);
|
// SaveFile MainID 保存文件
|
if (rdbGG.Checked == true)
|
{
|
oCn.RunProc("Insert into oa_fkmain(isRead,id,HErrTypeID,operator,context" +
|
",description,opdate,PlanNo,ItemNumber" +
|
",ItemModel,roperator,ispublic,Fdate,roperator2) " +
|
" values (" +
|
" 0," + MainID + "," + HErrTypeID + ",'" + DBUtility.ClsPub.CurUserName + "','" + Context + "'" +
|
",'" + Desc + "','" + sDate + "','" + PlanNo + "','" + txtHItemNumber.Text + "'" +
|
",'" + ItemModel + "','" + txtHReceiveMan.Text + "',1,'" + dtpHDate.Value + "','" + txtHCopyMan.Text + "')");
|
}
|
else
|
{
|
oCn.RunProc("Insert into oa_fkmain(isRead,id,HErrTypeID,operator,context" +
|
",description,opdate,PlanNo,ItemNumber" +
|
",ItemModel,roperator,ispublic,Fdate,roperator2) " +
|
" values (" +
|
" 0," + MainID + "," + HErrTypeID + ",'" + DBUtility.ClsPub.CurUserName + "','" + Context + "'" +
|
",'" + Desc + "','" + sDate + "','" + PlanNo + "','" + txtHItemNumber.Text + "'" +
|
",'" + ItemModel + "','" + txtHReceiveMan.Text + "',0,'" + dtpHDate.Value + "','" + txtHCopyMan.Text + "')");
|
}
|
oCn.RunProc("Insert into oa_fksub(id,mainid,operator,context,opdate) "+
|
" values ("+
|
"-1," + MainID + ",'" + DBUtility.ClsPub.CurUserName + "','" + Context + "','" + sDate+"')");
|
if(txtHCopyMan.Text!="")
|
{
|
string[] s = txtHCopyMan.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_fksub2 (MainID,SubID,ROperator,isRead,isKnow) "+
|
"values ("+
|
MainID+"," + j + ",'"+ k +"',0,0)");
|
}
|
}
|
oCn.RunProc("insert into oa_fksub2 (MainID,SubID,ROperator,isRead,isKnow) " +
|
"values (" +
|
MainID + ",1,'" + txtHReceiveMan.Text + "',0,0)");
|
//上传附件 huanxin
|
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;
|
}
|
|
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 frmFK_Load(object sender, EventArgs e)
|
{
|
initGrid();//huan
|
}
|
|
private void cmdCancel_Click(object sender, EventArgs e)
|
{
|
DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); //huan
|
this.Close();
|
}
|
|
private void cmdDel_Click(object sender, EventArgs e) //huan
|
{
|
if (grdMain.CurrentRow == null)
|
{
|
return;
|
}
|
grdMain.Rows.RemoveAt(grdMain.CurrentRow.Index);
|
}
|
|
private void txtHErrTypeID_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHErrTypeID.Text.Trim() == "")
|
{
|
txtHErrTypeID.Tag = "0";
|
}
|
}
|
|
private void txtHCopyMan_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHCopyMan.Text.Trim() == "")
|
{
|
txtHCopyMan.Tag = "0";
|
}
|
}
|
|
private void txtHReceiveMan_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHReceiveMan.Text.Trim() == "")
|
{
|
txtHReceiveMan.Tag = "0";
|
}
|
}
|
|
|
|
|
}
|
}
|