using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Pub_Class; namespace OAM { public partial class frmGGView1 : Form { public frmGGView1() { 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; public long MainID; public const string ModName = "4508"; //µ¥¾ÝÀàÐÍ public const string ModCaption = "»áÒé֪ͨ"; //µ¥¾ÝÃû³Æ public const string ModRightName = "frmGGView1"; public const string ModRightNameEdit = ModRightName + "_Edit"; public const string ModRightNameCheck = ModRightName + "_Check"; public const string ModRightNameClose = ModRightName + "_Close"; public const string ModRightNameDelete = ModRightName + "_Delete"; public bool BillChange; //µ¥¾ÝÐÞ¸Ä״̬ // public DBUtility.ClsPub.Enum_BillStatus BillStatus; //µ¥¾Ý״̬£¨ÐÂÔö£¬Ð޸ģ¬ä¯ÀÀ£¬¸üе¥¼Û£¬±ä¸ü£© public Int64 KeyID; //µ¥¾ÝÖ÷ÄÚÂë public bool grdStatus; //Íø¸ñ״̬£¨²»¿É±à¼­£¬¿É±à¼­£© //------------------------------------------------------------------------- #region ¹Ì¶¨´úÂë //´°Ìå¼ÓÔØ private void frmGGView1_Load(object sender, EventArgs e) { initGridFJ(); dtpDate.Value = DateTime.Today; dtpHEDate.Value = DateTime.Today; dtpsdate.Value = DateTime.Today; this.Text = ModCaption; //ÃüÃû´°Ìå±êÌâ this.lblCaption.Text = ModCaption;//ÃüÃûµ¥¾Ý±êÌâ DBUtility.ClsPub.GetGridView(grdFJ, this.Name, DBUtility.ClsPub.AppPath); } 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 Command1_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; } oCn.RunProc("delete from oa_gg1sub where Mainid=" + ID); oCn.RunProc("delete from oa_gg1 where id=" + ID); MessageBox.Show("ɾ³ý³É¹¦£¡"); DBUtility.ClsPub.SaveGridView(grdFJ, this.Name, DBUtility.ClsPub.AppPath); this.Close(); } else { } } else { MessageBox.Show("¶Ô²»Æð!Ö»Óз¢ËÍÈ˲ÅÄÜɾ³ý£¡"); } } //Ìí¼Ó°´Å¥ private void cmdAdd_Click_1(object sender, EventArgs e) { 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_1(object sender, EventArgs e) { 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 frmGGView1_FormClosing(object sender, FormClosingEventArgs e) { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; } #endregion #region ¶ÁдÀà //ÏÔʾµ¥¾Ý public void Sub_ShowBill() { } #endregion private void cmdCancel_Click(object sender, EventArgs e) { DBUtility.ClsPub.SaveGridView(grdFJ, this.Name, DBUtility.ClsPub.AppPath); this.Close(); } private string GetReadEmp(long MID, string sBill) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet Ds; string GetReadEmp=""; Ds = oCn.RunProcReturn("select roperator from oa_readnum where MainID=" + MID + " and sBill='" + sBill + "'", "oa_readnum"); if (Ds == null || Ds.Tables[0].Rows.Count == 0) { GetReadEmp = ""; } else { for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { GetReadEmp = GetReadEmp + DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i][0]) + ","; } } if (GetReadEmp != "") { GetReadEmp = GetReadEmp.Remove(GetReadEmp.Length - 1, 1); } return GetReadEmp; } private long GetReadNum(long MID, string sBill) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet Ds; long GetReadNum=0; Ds = oCn.RunProcReturn("select count(*)as Num from oa_readnum where MainID=" + MID + " and sBill='" + sBill + "'", "oa_readnum"); if (Ds == null || Ds.Tables[0].Rows.Count == 0) { GetReadNum =0; } else { GetReadNum = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]); } return GetReadNum; } private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; Display(); } public void Display() { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet Ds; DataSet Ds2; Ds = oCn.RunProcReturn("Select * from oa_gg1 where id=" + ID, "oa_gg1", ref DBUtility.ClsPub.sExeReturnInfo); if (Ds == null || Ds.Tables[0].Rows.Count == 0) { MessageBox.Show("ÏÔʾʧ°Ü£¡Ô­Òò£º" + DBUtility.ClsPub.sExeReturnInfo); return; } txtManager.Text = Ds.Tables[0].Rows[0]["manager"].ToString(); dtpDate.Text = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["workdate"].ToString()).ToShortDateString(); dtpTime.Text = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["workdate"].ToString()).ToShortTimeString(); dtpHEDate.Text = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["hedate"].ToString()).ToShortDateString(); dtpHETime.Text = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["hedate"].ToString()).ToShortTimeString(); dtpsdate.Text = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["sDate"].ToString()).ToShortDateString(); dtpsTime.Text = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["sDate"].ToString()).ToShortTimeString(); txtContext.Text = Ds.Tables[0].Rows[0]["context"].ToString(); txtAddr.Text = Ds.Tables[0].Rows[0]["addr"].ToString(); txtHNoteMan.Text = Ds.Tables[0].Rows[0]["hnoteman"].ToString(); txtHSummary.Text = Ds.Tables[0].Rows[0]["HSummary"].ToString(); txtRemark.Text = Ds.Tables[0].Rows[0]["remark"].ToString(); txtOperator.Text = Ds.Tables[0].Rows[0]["operator"].ToString(); txtDesc.Text = Ds.Tables[0].Rows[0]["Description"].ToString(); if (Ds.Tables[0].Rows[0]["maker"].ToString() == DBUtility.ClsPub.CurUserName) { cmdSave.Visible = true; } else { cmdSave.Visible = false; } MainID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["MainID"].ToString()); oCn.RunProc("update oa_gg1sub set isread=1 where mainid=" + MainID + " and roperator='" + DBUtility.ClsPub.CurUserName + "'"); Ds2 = oCn.RunProcReturn("select * from oa_ReadNum where sbill='oa_gg1' and MainID=" + MainID + " and roperator='" + DBUtility.ClsPub.CurUserName + "'", "oa_ReadNum"); if (Ds != null && Ds2.Tables[0].Rows.Count == 0) { oCn.RunProc("insert into oa_ReadNum (MainID,sBill,rOPerator) values (" + MainID + ",'oa_gg1','" + DBUtility.ClsPub.CurUserName + "') "); } lblNum.Text = GetReadNum(MainID, "oa_gg1").ToString(); txtEmp.Text = GetReadEmp(MainID, "oa_gg1"); //¸½¼þ huan DisplayFJ(); //DBUtility.ClsPub.GetGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); 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 cmdSave_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); oCn.RunProc("update oa_gg1 set operator='" + txtOperator.Text+"'"+ ",context='" + txtContext.Text + "'" + ",HSummary='" + txtHSummary.Text + "'" + ",addr='" + txtAddr.Text + "'" + ",Description='" + txtDesc.Text + "'" + ",remark='" + txtRemark.Text + "'" + ",makedate=getdate()" + ",workdate='" + dtpDate.Text + " " + dtpTime.Text + "'" + " where id=" + ID); MessageBox.Show("±£´æ³É¹¦"); DBUtility.ClsPub.SaveGridView(grdFJ, this.Name, DBUtility.ClsPub.AppPath); this.Close(); } private void grdFJ_DoubleClick(object sender, EventArgs e) { 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)); } } }