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 frmFKView : Form { public frmFKView() { InitializeComponent(); } public const int HFileNameCol = 0;//huan public const int HFilePathCol = 1; public const int HUpManCol = 2; public const int HItemIDCol = 3; public long ID; private void cmdHasten_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (MessageBox.Show("确认要催促对方?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { return; } lblHasten.Text =DBUtility.ClsPub.isStrNull( DBUtility.ClsPub.isInt(lblHasten.Text) + 1); oCn.RunProc("update oa_fkmain set Hasten=Hasten+1,isback=0,isread=0 where id=" + ID); oCn.RunProc("update oa_fksub2 set isread=0 where mainid=" + ID); } 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) { txtRtransmitMan.Text = oUser.sReturn; } else { txtRtransmitMan.Text = ""; } } private void button2_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (txtRtransmitMan.Text.Trim() == "") { MessageBox.Show("请选择转发人"); } oCn.RunProc("update oa_fkmain set RtransmitMan='" + txtRtransmitMan.Text.ToString()+"',transmitMan='"+DBUtility.ClsPub.CurUserName+"' where id="+ID); DataSet Ds; long i=0; Ds = oCn.RunProcReturn("select max(subid) as MaxID from oa_fksub2 where mainid=" + ID, "oa_fksub2"); if (Ds != null && Ds.Tables[0].Rows.Count != 0) { i = DBUtility.ClsPub.isLong( Ds.Tables[0].Rows[0][0]); } if (txtRtransmitMan.Text != "") { string[] s = txtRtransmitMan.Text.Split(','); int len = s.Length; for (int z = 0; z < len; z++) { i = i + 1; string k = s[z].ToString(); oCn.RunProc("insert into oa_fksub2 (MainID,SubID,ROperator,isRead,isKnow) " + "values (" + ID + "," + i + ",'" + k + "',0,0)"); } } MessageBox.Show("已经成功转发!"); } private void button1_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (txtOperator.Text == DBUtility.ClsPub.CurUserName) { DialogResult dr = MessageBox.Show("确定要删除此单据吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { if (!DBUtility.ClsPub.Security_Log("OA_Manager", 1, true, DBUtility.ClsPub.CurUserName)) { return; } //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); oCn.RunProc("delete from oa_fksub where Mainid=" + ID); oCn.RunProc("delete from oa_fksub2 where Mainid=" + ID); oCn.RunProc("delete from oa_fkMain where id=" + ID); MessageBox.Show("删除成功!"); this.Close(); } else { } } else { MessageBox.Show("对不起!只有发送人才能删除!"); } } private void button3_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (txtHReceiveMan.Text == DBUtility.ClsPub.CurUserName) { if (txtContext_New.Text == "") { MessageBox.Show("请填写内容!"); return; } string Context_New = txtContext_New.Text.Replace("'", "‘"); int Rows=grdMain.Rows.Count+1; oCn.RunProc("Insert into oa_fksub(mainid,id,context,operator,opdate,sisEnd) values(" + ID + "," + Rows + ",'" + Context_New+"','"+DBUtility.ClsPub.CurUserName+"',getdate(),1)"); oCn.RunProc("update oa_fkmain set isend=1 where id=" + ID + " and roperator='" + DBUtility.ClsPub.CurUserName+"'"); oCn.RunProc("insert into oa_fksub2(mainid,subid,roperator,isread,isknow) values(" + ID + "," + GetMaxSubID(ID) + ",'" + txtOperator.Text.ToString() + "',0,0)"); Display(); } else { MessageBox.Show("对不起,你不能结案!"); } } private long GetMaxSubID(long MainID) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet Ds; long MaxSubID; Ds = oCn.RunProcReturn("select max(subid)as subid from oa_fksub2 where mainid=" + MainID, "oa_fksub2"); if (Ds == null || Ds.Tables[0].Rows.Count == 0) { MaxSubID = 0; } else { MaxSubID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]) + 1; } return MaxSubID; } public void Display() { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet Ds; Ds = oCn.RunProcReturn("Select * from oa_fkmain where id=" + ID, "oa_fkmain", ref DBUtility.ClsPub.sExeReturnInfo); if (Ds == null ) { MessageBox.Show("显示失败!原因:" + DBUtility.ClsPub.sExeReturnInfo); return; } txtHContext.Text = Ds.Tables[0].Rows[0]["context"].ToString(); txtDesc.Text = Ds.Tables[0].Rows[0]["Description"].ToString(); txtHPlanNo.Text = Ds.Tables[0].Rows[0]["planno"].ToString(); txtHItemNumber.Text = Ds.Tables[0].Rows[0]["ItemNumber"].ToString(); txtHItemModel.Text = Ds.Tables[0].Rows[0]["ItemModel"].ToString(); if (Ds.Tables[0].Rows[0]["FDate"].ToString() != "") { dtpHDate.Value =DBUtility.ClsPub.isDate( Ds.Tables[0].Rows[0]["FDate"].ToString()); } txtHErrTypeID.Text = Ds.Tables[0].Rows[0]["herrtypeid"].ToString(); txtOperator.Text = Ds.Tables[0].Rows[0]["operator"].ToString(); txtHReceiveMan.Text = Ds.Tables[0].Rows[0]["roperator"].ToString(); txtHCopyMan.Text = Ds.Tables[0].Rows[0]["roperator2"].ToString(); txtRtransmitMan.Text = Ds.Tables[0].Rows[0]["rtransmitman"].ToString(); txttransmitMan.Text = Ds.Tables[0].Rows[0]["transmitman"].ToString(); if (Ds.Tables[0].Rows[0]["roperator"].ToString() == DBUtility.ClsPub.CurUserName) { oCn.RunProc("update oa_fkmain set isread=1 where id="+ID); } lblHasten.Text = Ds.Tables[0].Rows[0]["hasten"].ToString(); if (Ds.Tables[0].Rows[0]["operator"].ToString() == DBUtility.ClsPub.CurUserName) { cmdHasten.Visible = true; button4.Visible = true; } else { cmdHasten.Visible = false; button4.Visible = false; } if (Ds.Tables[0].Rows[0]["roperator"].ToString() == DBUtility.ClsPub.CurUserName) { if (Ds.Tables[0].Rows[0]["isend"].ToString() == "") { button3.Visible = true; } else { button3.Visible = false; } } else { button3.Visible = false; } // //异常类型 //Dim oItem As New t_HErrTypeID //oItem.GetInfoByID oRs!HErrTypeID //If Val(oItem.HItemID) <> 0 Then // txtHErrTypeID.Tag = oItem.HItemID // txtHErrTypeID = oItem.HName //Else // txtHErrTypeID = "" // txtHErrTypeID.Tag = "" //End If // oCn.RunProc("update oa_fksub2 set isread=1 where mainid=" + ID + " and roperator='" + DBUtility.ClsPub.CurUserName+"'"); Ds = oCn.RunProcReturn("Select Operator 发送人,convert(varchar(5),opdate,110)+' '+convert(varchar(5),opdate,108) 发送日期,case when isnull(sisend,0)<>0 then '结案:'+Context else case when isnull(sislast,0)<>0 then '验证:'+Context else '回复:'+Context end end 内容 from oa_fksub where mainid=" + ID + " and id>=0 order by opdate desc", "oa_fksub", ref DBUtility.ClsPub.sExeReturnInfo); if (Ds == null) { MessageBox.Show("显示失败!原因:" + DBUtility.ClsPub.sExeReturnInfo); return; } grdMain.DataSource = Ds.Tables[0].DefaultView; //附件 huan DisplayFJ(); DBUtility.ClsPub.GetGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); DBUtility.ClsPub.GetGridView(grdFJ, this.Name + "grdFJ", DBUtility.ClsPub.AppPath); // } private void button4_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (txtOperator.Text == DBUtility.ClsPub.CurUserName) { if (txtContext_New.Text == "") { MessageBox.Show("请填写内容!"); return; } string Context_New = txtContext_New.Text.Replace("'", "‘"); int Rows = grdMain.Rows.Count + 1; oCn.RunProc("Insert into oa_fksub(mainid,id,context,operator,opdate,sislast) values(" + ID + "," + Rows + ",'" + Context_New + "','" + DBUtility.ClsPub.CurUserName + "',getdate(),1)"); oCn.RunProc("update oa_fkmain set islast=1 where id=" + ID); oCn.RunProc("insert into oa_fksub2(mainid,subid,roperator,isread,isknow) values(" + ID + "," + GetMaxSubID(ID) + ",'" + txtHReceiveMan.Text + "',0,0)"); Display(); } else { MessageBox.Show("对不起,你不能验证"); } } private void cmdSend_Click(object sender, EventArgs e) { DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); DBUtility.ClsPub.SaveGridView(grdFJ, this.Name + "grdFJ", DBUtility.ClsPub.AppPath); SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (txtContext_New.Text == "") { MessageBox.Show("请填写回复内容!"); return; } int Rows = grdMain.Rows.Count + 1; oCn.RunProc("Insert into oa_fksub(mainid,id,context,operator,opdate) values(" + ID + "," + Rows + ",'" + txtContext_New.Text.ToString()+"','"+DBUtility.ClsPub.CurUserName+"',getdate())"); oCn.RunProc("update oa_fkmain set isback=1 where id=" + ID + " and roperator='"+DBUtility.ClsPub.CurUserName+"'"); oCn.RunProc("insert into oa_fksub2(mainid,subid,roperator,isread,isknow) values(" + ID + "," + GetMaxSubID(ID) + ",'" + txtOperator.Text.ToString() + "',0,0)"); Display(); } private void cmdCancel_Click(object sender, EventArgs e) { DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); DBUtility.ClsPub.SaveGridView(grdFJ, this.Name + "grdFJ", DBUtility.ClsPub.AppPath); this.Close(); } private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; timer1.Interval = 60000; Display(); } private void cmdAdd_Click(object sender, EventArgs e)//huan { OpenFileDialog oDlg = new OpenFileDialog(); oDlg.Filter = "所有文件|*.*"; if (oDlg.ShowDialog() == DialogResult.OK) { if (oDlg.FileName != "") { grdFJ.Rows.Add(); grdFJ.Rows[grdFJ.Rows.Count - 1].Cells[HFileNameCol].Value = oDlg.SafeFileName; grdFJ.Rows[grdFJ.Rows.Count - 1].Cells[HFilePathCol].Value = oDlg.FileName; grdFJ.Rows[grdFJ.Rows.Count - 1].Cells[HUpManCol].Value = DBUtility.ClsPub.CurUserName; //直接上传 BLL.ClsXt_FileCtrl oFile = new BLL.ClsXt_FileCtrl(); if (oFile.LoadUpFile(ID, 1, DBUtility.ClsPub.isStrNull(grdFJ.Rows[grdFJ.Rows.Count - 1].Cells[HFilePathCol].Value), 0, DBUtility.ClsPub.isStrNull(grdFJ.Rows[grdFJ.Rows.Count - 1].Cells[HFileNameCol].Value), DBUtility.ClsPub.CurUserName) == false) { MessageBox.Show("上传文件时失败!"); } // } } } private void cmdDel_Click(object sender, EventArgs e)//huan { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (grdFJ.CurrentRow == null) { return; } if (DBUtility.ClsPub.isStrNull(grdFJ.Rows[grdFJ.CurrentRow.Index].Cells[HUpManCol].Value) != DBUtility.ClsPub.CurUserName) { MessageBox.Show("只能删除自己上传的附件!"); return; } DialogResult dr = MessageBox.Show("确定要删除此单据吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { //if (!DBUtility.ClsPub.Security_Log("OA_Manager", 1, true, DBUtility.ClsPub.CurUserName)) //{ // return; //} //删除附件 BLL.ClsXt_FileCtrl oFile = new BLL.ClsXt_FileCtrl(); SQLHelper.ClsCNK3 oCNK3 = new SQLHelper.ClsCNK3(); if (oFile.DeleteFile(DBUtility.ClsPub.isLong(grdFJ.Rows[grdFJ.CurrentRow.Index].Cells[HItemIDCol].Value), ref DBUtility.ClsPub.sExeReturnInfo, oCNK3) == false) { MessageBox.Show("删除文件时失败!"); } // grdFJ.Rows.RemoveAt(grdFJ.CurrentRow.Index); } else { } } private void initGridFJ()//huan { grdFJ.ColumnCount = 4; //总列数 DBUtility.Xt_BaseBillFun.initGridFst(grdFJ, this.Name + "grdFJ"); grdFJ.ReadOnly = true; grdFJ.RowCount = 0; //= grdFJ.Columns[HFileNameCol].HeaderText = "文件名称"; grdFJ.Columns[HFilePathCol].HeaderText = "文件路径"; grdFJ.Columns[HUpManCol].HeaderText = "上传人"; DBUtility.ClsPub.GetGridView(grdFJ, this.Name + "grdFJ", DBUtility.ClsPub.AppPath); } private void DisplayFJ()//huan { SQLHelper.ClsCNK3 oCn = new SQLHelper.ClsCNK3(); DataSet Ds; Ds = oCn.RunProcReturn("Select FItemID,fupman,ffilename,fpath from OA_Accessories where FFileID=" + ID, "OA_Accessories"); if (Ds == null || Ds.Tables[0].Rows.Count == 0) { return; } for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { grdFJ.Rows.Add(); grdFJ.Rows[i].Cells[HFileNameCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["FFileName"]); grdFJ.Rows[i].Cells[HFilePathCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["FPath"]); grdFJ.Rows[i].Cells[HUpManCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["FUpMan"]); grdFJ.Rows[i].Cells[HItemIDCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["FItemID"]); } } private void grdFJ_DoubleClick(object sender, EventArgs e)//huan { if (grdFJ.CurrentRow == null) { return; } //下载附件到本地,并执行 BLL.ClsXt_FileCtrl oFile = new BLL.ClsXt_FileCtrl(); SQLHelper.ClsCNK3 oCNK3 = new SQLHelper.ClsCNK3(); if (oFile.WriteFile("FFile" , DBUtility.ClsPub.AppPath + @"\a\" + DBUtility.ClsPub.isStrNull(grdFJ.Rows[grdFJ.CurrentRow.Index].Cells[HFileNameCol].Value) , DBUtility.ClsPub.isLong(grdFJ.Rows[grdFJ.CurrentRow.Index].Cells[HItemIDCol].Value), oCNK3) == false) { MessageBox.Show("读取文件时失败!"); } System.Diagnostics.Process.Start(DBUtility.ClsPub.AppPath + @"\a\" + DBUtility.ClsPub.isStrNull(grdFJ.Rows[grdFJ.CurrentRow.Index].Cells[HFileNameCol].Value)); } private void frmFKView_Load(object sender, EventArgs e) //huan { initGridFJ(); } private void grdMain_DoubleClick(object sender, EventArgs e) { frmUserset ofrmUserset = new frmUserset(); string sName = ""; if (grdMain.CurrentRow == null) return; sName = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("发送人")].Value); if (sName == "") return; ofrmUserset.UserName = sName; ofrmUserset.cmdOK.Enabled = false; timer1.Enabled = false; ofrmUserset.ShowDialog(); timer1.Enabled = true; } private Int32 Fun_GetCol(string sCol) { return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain); } private void grdMain_Scroll(object sender, ScrollEventArgs e) { grdMain.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True; } } }