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 frmWorkBillView : Form { public frmWorkBillView() { InitializeComponent(); } public const int HFileNameCol = 0;//huan public const int HFilePathCol = 1; public const int HUpManCol = 2; public const int HItemIDCol = 3; // public const int MainType = 2; 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_workbillmain set Hasten=Hasten+1,isback=0,isread=0 where id=" + ID); oCn.RunProc("update oa_workbillsub2 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_workbillmain 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_workbillsub2 where mainid=" + ID, "oa_workbillsub2"); 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_workbillsub2 (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_workbillsub where Mainid=" + ID); oCn.RunProc("delete from oa_workbillsub2 where Mainid=" + ID); oCn.RunProc("delete from oa_workbillMain 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 (txtROperator.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_workbillsub(mainid,id,context,operator,opdate,sisEnd) values(" + ID + "," + Rows + ",'" + Context_New + "','" + DBUtility.ClsPub.CurUserName + "',getdate(),1)"); oCn.RunProc("update oa_workbillmain set isend=1 where id=" + ID + " and roperator='" + DBUtility.ClsPub.CurUserName + "'"); oCn.RunProc("insert into oa_workbillsub2(mainid,subid,roperator,isread,isknow) values(" + ID + "," + GetMaxSubID(ID) + ",'" + txtOperator.Text.ToString() + "',0,0)"); Display(); } else { MessageBox.Show("对不起,你不能结案!"); } } private void button4_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (txtOperator.Text == DBUtility.ClsPub.CurUserName) { frmWorkBillView_Dlg oDlg = new frmWorkBillView_Dlg(); oDlg.ShowDialog(); if (oDlg.isOK == 1) { string Context_New = oDlg.txtHContext.Text.Replace("'", "‘"); int Rows = grdMain.Rows.Count + 1; oCn.RunProc("Insert into oa_workbillsub(mainid,id,context,operator,opdate,sislast) values(" + ID + "," + Rows + ",'" + Context_New + "','" + DBUtility.ClsPub.CurUserName + "',getdate(),1)"); oCn.RunProc("update oa_workbillmain set islast=1 , HEvaluateStatusID=" + oDlg.txtHEvaluateStatusID.SelectedIndex + " where id=" + ID); oCn.RunProc("insert into oa_workbillsub2(mainid,subid,roperator,isread,isknow) values(" + ID + "," + GetMaxSubID(ID) + ",'" + txtROperator.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_workbillsub(mainid,id,context,operator,opdate) values(" + ID + "," + Rows + ",'" + txtContext_New.Text.ToString() + "','" + DBUtility.ClsPub.CurUserName + "',getdate())"); oCn.RunProc("update oa_workbillmain set isback=1 where id=" + ID + " and roperator='" + DBUtility.ClsPub.CurUserName + "'"); oCn.RunProc("insert into oa_workbillsub2(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(); } public void Display() { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet Ds; Ds = oCn.RunProcReturn("Select * from oa_workbillmain where id=" + ID, "oa_workbillmain", ref DBUtility.ClsPub.sExeReturnInfo); if (Ds == null ) { MessageBox.Show("显示失败!原因:" + DBUtility.ClsPub.sExeReturnInfo); return; } txtContext.Text = Ds.Tables[0].Rows[0]["context"].ToString(); txtDesc.Text = Ds.Tables[0].Rows[0]["Description"].ToString(); if (Ds.Tables[0].Rows[0]["roperator"].ToString() == DBUtility.ClsPub.CurUserName) { oCn.RunProc("update oa_workbillmain set isread=1 where id=" + ID); } // If Trim(oRs!operator & "") = Trim(CurUserName) Then // Toolbar1.Buttons("cchu").Enabled = True // Toolbar1.Buttons("yzh").Enabled = True // Else // Toolbar1.Buttons("cchu").Enabled = False // Toolbar1.Buttons("yzh").Enabled = False // End If // If Trim(oRs!roperator & "") = Trim(CurUserName) Then // Toolbar1.Buttons("ja").Enabled = True // Else // Toolbar1.Buttons("ja").Enabled = False // End If // lblHasten.Text = Ds.Tables[0].Rows[0]["hasten"].ToString(); txtOperator.Text = Ds.Tables[0].Rows[0]["operator"].ToString(); txtROperator.Text = Ds.Tables[0].Rows[0]["roperator"].ToString(); txtRoperator2.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(); txtHRemark.Text = Ds.Tables[0].Rows[0]["HRemark"].ToString(); txtHBillNo.Text = Ds.Tables[0].Rows[0]["hbillno"].ToString(); cmbHLevel.Text = Ds.Tables[0].Rows[0]["HLevel"].ToString(); // //If (Eva.GetInfoByID(Val(oRs!HEvaluateStatusID))) Then // cmbHEvaluateStatus.Text = Trim(Eva.HName & "") //Else // cmbHEvaluateStatus.Text = "" //End If // cmbHEvaluateStatus.SelectedIndex =DBUtility.ClsPub.isInt( Ds.Tables[0].Rows[0]["HEvaluateStatusID"].ToString()); if (Ds.Tables[0].Rows[0]["FDate"].ToString() != "") { dtpFDate.Value = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["FDate"].ToString()); } if (Ds.Tables[0].Rows[0]["HCommDate"].ToString() != "") { DtpHCommDate.Value = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HCommDate"].ToString()); } oCn.RunProc("update oa_workbillsub2 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_workbillsub where mainid=" + ID + " and id>=0 order by opdate desc", "oa_workbillsub", 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); } private void frmWorkBillView_Load(object sender, EventArgs e)//huan { initGridFJ(); } private void initGridFJ()//huanxin { 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 timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; timer1.Interval = 60000; Display(); } private void fsh_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); oCn.RunProc(""); } 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_workbillsub2 where mainid=" + MainID, "oa_workbillsub2"); 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; } 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, MainType, 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 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 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 splitContainer4_SplitterMoved(object sender, SplitterEventArgs e) { } 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; } } }