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 frm_YF_PicUpLoad2 : Form { TreeNode CurNode = new TreeNode(); public frm_YF_PicUpLoad2() { InitializeComponent(); } public const int PicCol = 0;//huan public const int PicTypeCol = 1;//huan public const int PicNameCol = 2; public const int LoadDateCol = 3; public const int LoadManCol = 4; public const int RemarkCol = 5; public const int BbNumberCol = 6; public const int PicPathCol = 7; public const int YF_PictureIDCol = 8; //public const int HFileNameCol = 0;//huan //public const int HFilePathCol = 1; //public const int HUpManCol = 2; //public const int HItemIDCol = 3; //public const int HItemIDCol = 4; //public const int HItemIDCol = 5; public long ID; public long YF_PictureID; public Int64 FFileSize; public const int MainType = 5; public const string ModName = "4520"; //ÏÔʾÁбí private void Display() // »ÃÐÄ { SQLHelper.ClsCN SubCn = new SQLHelper.ClsCN(); DataSet DSet; string sSql = ""; string sWhere = ""; //sSql = "Select * from h_v_EmployeeConList order by ¹ÜÀíÎļþ´úÂë"; DisplayFJ(); //DBUtility.ClsPub.GetGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); DBUtility.ClsPub.GetGridView(grdMain, this.Name + "grdMain", DBUtility.ClsPub.AppPath); } //¼ÓÔØÊ÷ÐÎ public static void LoadTree(TreeView tv, ImageList imageList1, string Text)//Lock { try { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); tv.Nodes.Clear(); tv.ImageList = imageList1; TreeNode sNode = tv.Nodes.Add("T0", Text, 0, 1); LoadAllNodes(sNode); } catch (Exception e) { MessageBox.Show("¼ÓÔØÊ÷ÐÍʧ°Ü£¡" + e.Message, "Ìáʾ"); } } //¼ÓÔØ×Ó±í private static void LoadAllNodes(TreeNode sNode) //Lock { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (sNode != null) { try { frm_YF_PicUpLoad2 ofrm_YF_PicUpLoad2 = new frm_YF_PicUpLoad2(); //long sName = Convert.ToInt64(sNode.Name.Substring(1, sNode.Name.Length - 1)); sNode.Nodes.Clear(); long sName = Convert.ToInt64(sNode.Name.Substring(1, sNode.Name.Length - 1)); //sNode.Nodes.Clear(); DataSet Ds; Ds = oCn.RunProcReturn("select YF_PicObjectBillID,ObjectBillName,ParentID from OA_PicObjectBill2 where ParentID=" + sName + " order by ObjectBillName", "OA_PicObjectBill2", ref ClsPub.sExeReturnInfo); for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { // Ds.Tables[0].Rows[i]["FileName"].ToString() + "-" + Ds.Tables[0].Rows[i]["HName"].ToString(), //if() TreeNode oNode = sNode.Nodes.Add("T" + Ds.Tables[0].Rows[i]["YF_PicObjectBillID"].ToString(), Ds.Tables[0].Rows[i]["ObjectBillName"].ToString(), 0, 1); } //SQLHelper.ClsCNK3 oCn = new SQLHelper.ClsCNK3(); //string oDeptid = CurNode.Name.Replace("T", ""); //if (oDeptid == "") //{ // oDeptid = "ParentID"; //} //DataSet Ds; sNode.Expand(); } catch (Exception e) { MessageBox.Show("¼ÓÔØ×ÓÏîĿʧ°Ü£¡" + e.Message, "Ìáʾ"); } } } private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { CurNode = e.Node; if (CurNode != null) { if (CurNode.Nodes.Count == 0) LoadAllNodes(CurNode); //ÕÒµ½Ñ¡Öнáµã Display(); } } private void button1_Click(object sender, EventArgs e) { LoadTree(TreeView, imageList1, this.Text); } private void dj_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (CurNode != null) { if (CurNode.Name == "T0") { MessageBox.Show("´Ë½Úµã²»¿Éɾ³ý£¡"); } else { DialogResult dr = MessageBox.Show("È·¶¨ÒªÉ¾³ý´ËĿ¼Âð£¿", "Ìáʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { string parentid = CurNode.Name.Substring(1); oCn.RunProc("DELETE FROM OA_PicObjectBill2 WHERE YF_PicObjectBillID =" + parentid + " ", ref DBUtility.ClsPub.sExeReturnInfo); LoadTree(TreeView, imageList1, this.Text); MessageBox.Show("×é" + "¡¾" + CurNode.Text + "¡¿" + "ÒÑɾ³ý"); } else { } } } } private void xz_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (CurNode.Name == "") { MessageBox.Show("ÇëÑ¡ÔñÐèÒªÌí¼Ó×éµÄ½Úµã£¡", "Ìáʾ"); return; } if (DBUtility.ClsPub.isStrNull(txtName.Text) == "") { MessageBox.Show("Ìí¼Ó×éÃû²»ÄÜΪ¿Õ£¡", "Ìáʾ"); return; } else { if (CurNode != null) { string parentid = CurNode.Name.Substring(1); //int result; //if (int.TryParse(parentid, out result)) //{ // Console.WriteLine("ת»»ºóµÄÕûÐÍÊýֵΪ£º{0}", result); //} //else //{ // Console.WriteLine("ÎÞ·¨Íê³Éת»»£¡"); //} //result = result + 1; DialogResult dr = MessageBox.Show("È·¶¨ÒªÔÚ¡¾" + CurNode.Text + "¡¿ÏÂÌí¼ÓÒ»¸öÃûΪ¡¾" + txtName.Text + "¡¿µÄÐÂ×éÂð£¿", "Ìáʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { oCn.RunProc("Insert into OA_PicObjectBill2 " + " (ObjectBillName,ParentID,YF_CmpolderMainID,YF_CmpolderSubID,YF_CMpolderType,closeMan) " + " Values('" + txtName.Text.Trim() + "','" + parentid + "'," + 0 + "," + 0 + ",'" + "" + "','" + Pub_Class.ClsPub.CurUserName + "')", ref DBUtility.ClsPub.sExeReturnInfo); LoadTree(TreeView, imageList1, this.Text); MessageBox.Show("ÐÂÔö³É¹¦"); } else { } } else { MessageBox.Show("δѡÖÐÕýÈ·µÄÏî"); } } } private void cmdFilePath_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Multiselect = true; fileDialog.Title = "ÇëÑ¡ÔñÎļþ"; fileDialog.Filter = "ËùÓÐÎļþ(*.*)|*.*"; if (fileDialog.ShowDialog() == DialogResult.OK) { txtPath.Text = fileDialog.FileName; txtFilePath.Text = fileDialog.SafeFileName.ToString(); } } private Int32 Fun_GetCol(string sCol) { return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain); } private void sx_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); long YF_PictureID; YF_PictureID = DBUtility.ClsPub.CreateBillID(ModName, ref DBUtility.ClsPub.sExeReturnInfo); if (CurNode.Text == "") { MessageBox.Show("δѡÖÐÕýÈ·µÄÏî"); } else { string parentid = CurNode.Name.Substring(1); if (DBUtility.ClsPub.isStrNull(txtPath.Text) == "") { MessageBox.Show("Îļþ·¾¶²»ÄÜΪ¿Õ£¡", "Ìáʾ"); return; } if (DBUtility.ClsPub.isStrNull(txtFilePath.Text) == "") { MessageBox.Show("ÎļþÃû³Æ²»ÄÜΪ¿Õ£¡", "Ìáʾ"); return; } // string sDate; sDate = DateTime.Now.ToString(); string Remark = txtRemark.Text.Replace("'", "¡®"); BLL.ClsXt_FileCtrl oFile = new BLL.ClsXt_FileCtrl(); string oDeptid = CurNode.Name.Replace("T", ""); int result; if (int.TryParse(oDeptid, out result)) { Console.WriteLine("ת»»ºóµÄÕûÐÍÊýֵΪ£º{0}", result); } else { Console.WriteLine("ÎÞ·¨Íê³Éת»»£¡"); } if (oFile.LoadUpFile3(FFileSize, txtFilePath.Text, txtType.Text, txtPath.Text, DateTime.Now.ToString(), txtRemark.Text, result, DBUtility.ClsPub.CurUserName) == false) { MessageBox.Show("ÉÏ´«Îļþʱʧ°Ü!"); return; } else { //grdMain.Columns[PicTypeCol].HeaderText = "ÎļþÀàÐÍ"; //grdMain.Columns[PicNameCol].HeaderText = "ÎļþÃû³Æ"; //grdMain.Columns[LoadDateCol].HeaderText = "ÉÏ´«ÈÕÆÚ"; //grdMain.Columns[LoadManCol].HeaderText = "ÉÏ´«ÈË"; //grdMain.Columns[RemarkCol].HeaderText = "ÃèÊö"; //grdMain.Columns[BbNumberCol].HeaderText = "ÐòºÅ"; oCn.RunProc("Insert into OA_PictureBill2 " + " (PicType,PicName,PicPath,LoadDate,LoadMan,Remark,YF_CmpolderMainID,YF_CmpolderSubID,YF_CmpolderType,ParentID,BbNumber" + ",FFileSize,FFile,BbID) " + " Values('" + txtType.Text.Trim() + "','" + txtFilePath.Text + "','" + txtPath.Text.Trim() + "','" + DateTime.Now.ToString() + "'" + ",'" + Pub_Class.ClsPub.CurUserName + "','" + txtRemark.Text.Trim() + "'," + 0 + "," + 0 + ",'" + "" + "'," + parentid + ",'" + "" + "','" + "" + "','" + "" + "'," + 0 + ")", ref DBUtility.ClsPub.sExeReturnInfo); LoadTree(TreeView, imageList1, this.Text); txtType.Text = ""; txtPath.Text = ""; txtRemark.Text = ""; txtFilePath.Text = ""; MessageBox.Show("ÉÏ´«³É¹¦"); Display(); return; } } } private void tc_Click(object sender, EventArgs e) { this.Close(); } private void sc_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (grdMain.CurrentRow == null) { return; } if (DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[LoadManCol].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.DeleteFile3(DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[YF_PictureIDCol].Value), ref DBUtility.ClsPub.sExeReturnInfo, oCNK3) == false) { MessageBox.Show("ɾ³ýÎļþʱʧ°Ü!"); } int col = 9; //string id = grdMain.Rows[grdMain.CurrentRow.Index].Cells[col].Value.ToString(); //oCn.RunProc("DELETE FROM OA_PictureBill2 WHERE YF_PictureID =" + id + " ", ref DBUtility.ClsPub.sExeReturnInfo); // grdMain.Rows.RemoveAt(grdMain.CurrentRow.Index); } else { } } private void frm_YF_PicUpLoad2_Load(object sender, EventArgs e) { initGridFJ(); initGrid();//huan LoadTree(TreeView, imageList1, this.Text); DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); Display(); } //public const int PicTypeCol = 0;//huan //public const int PicNameCol = 1; //public const int LoadDateCol = 2; //public const int LoadManCol = 3; //public const int RemarkCol = 4; //public const int BbNumberCol = 5; //public const int PicPathCol = 6;PicType ÎļþÀàÐÍ,PicName ÎļþÃû³Æ,LoadDate ÉÏ´«ÈÕÆÚ,LoadMan ÉÏ´«ÈË //,Remark ÃèÊö //,convert(int,YF_PictureID) YF_PictureID,BbNumber ÐòºÅ private void initGridFJ()//huan { grdMain.ColumnCount = 9; //×ÜÁÐÊý DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name + "grdMain"); grdMain.ReadOnly = true; grdMain.RowCount = 0; //= grdMain.Columns[PicTypeCol].HeaderText = "ÎļþÀàÐÍ"; grdMain.Columns[PicNameCol].HeaderText = "ÎļþÃû³Æ"; grdMain.Columns[LoadDateCol].HeaderText = "ÉÏ´«ÈÕÆÚ"; grdMain.Columns[LoadManCol].HeaderText = "ÉÏ´«ÈË"; grdMain.Columns[RemarkCol].HeaderText = "ÃèÊö"; grdMain.Columns[BbNumberCol].HeaderText = "ÐòºÅ"; //Òþ²Ø grdMain.Columns[PicCol].Visible = false; grdMain.Columns[PicPathCol].Visible = false; grdMain.Columns[YF_PictureIDCol].Visible = false; DBUtility.ClsPub.GetGridView(grdMain, this.Name + "grdMain", DBUtility.ClsPub.AppPath); } public void initGrid()//huan { DBUtility.Xt_BaseBillFun.initGridList(grdMain, this.Name); } //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++) // { // grdMain.Rows.Add(); // grdMain.Rows[i].Cells[PicTypeCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["PicTypeCol"]); // grdMain.Rows[i].Cells[PicNameCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["PicNameCol"]); // grdMain.Rows[i].Cells[LoadDateCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["LoadDateCol"]); // grdMain.Rows[i].Cells[LoadManCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["LoadManCol"]); // grdMain.Rows[i].Cells[RemarkCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["RemarkCol"]); // grdMain.Rows[i].Cells[BbNumberCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["BbNumberCol"]); // } //¸½¼þ huan // DisplayFJ(); // //DBUtility.ClsPub.GetGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); // DBUtility.ClsPub.GetGridView(grdMain, this.Name + "grdMain", DBUtility.ClsPub.AppPath); //} //ÏÔʾ¸½¼þ private void DisplayFJ()//huan { SQLHelper.ClsCNK3 oCn = new SQLHelper.ClsCNK3(); string oDeptid = CurNode.Name.Replace("T", ""); if (oDeptid == "") { oDeptid = "ParentID"; } grdMain.RowCount = 0; DataSet Ds; Ds = oCn.RunProcReturn("select * from oa_picturebill a,(select max(bbid)as BbID,picname from oa_picturebill where ParentID=" + oDeptid + " group by picname ) as b where a.bbid=b.bbid and a.picname=b.picname and ParentID=" + oDeptid + " order by a.picname", "oa_picturebill"); if (Ds == null || Ds.Tables[0].Rows.Count == 0) { return; } for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { grdMain.Rows.Add(); grdMain.Rows[i].Cells[PicTypeCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["PicType"]); grdMain.Rows[i].Cells[PicNameCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["PicName"]); grdMain.Rows[i].Cells[LoadDateCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["LoadDate"]); grdMain.Rows[i].Cells[LoadManCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["LoadMan"]); grdMain.Rows[i].Cells[RemarkCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["Remark"]); grdMain.Rows[i].Cells[BbNumberCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["BbNumber"]); grdMain.Rows[i].Cells[PicPathCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["PicPath"]); grdMain.Rows[i].Cells[YF_PictureIDCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["YF_PictureID"]); } } private void grdMain_DoubleClick(object sender, EventArgs e) { //if (grdMain.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(grdMain.Rows[grdMain.CurrentRow.Index].Cells[HFileNameCol].Value) // , DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[HItemIDCol].Value), oCNK3) == false) //{ // MessageBox.Show("¶ÁÈ¡Îļþʱʧ°Ü!"); //} //System.Diagnostics.Process.Start(DBUtility.ClsPub.AppPath + @"\a\" + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[HFileNameCol].Value)); } private void sh_Click(object sender, EventArgs e) { if (grdMain.CurrentRow == null) { return; } //ÏÂÔØ¸½¼þµ½±¾µØ£¬²¢Ö´ÐÐ BLL.ClsXt_FileCtrl oFile = new BLL.ClsXt_FileCtrl(); SQLHelper.ClsCNK3 oCNK3 = new SQLHelper.ClsCNK3(); if (oFile.WriteFile3("FFile" , DBUtility.ClsPub.AppPath + @"\a\" + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[PicNameCol].Value) , DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[YF_PictureIDCol].Value), oCNK3) == false) { MessageBox.Show("¶ÁÈ¡Îļþʱʧ°Ü!"); } System.Diagnostics.Process.Start(DBUtility.ClsPub.AppPath + @"\a\" + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[PicNameCol].Value)); } private void qsh_Click(object sender, EventArgs e) { if (grdMain.CurrentRow == null) { return; } //FolderBrowserDialog fbd = new FolderBrowserDialog(); //fbd.ShowDialog(); //string folderName = fbd.SelectedPath; //»ñµÃÑ¡ÔñµÄÎļþ¼Ð·¾¶ SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[PicNameCol].Value); //sfd.Filter = "all|*.*"; //ɾѡ¡¢É趨ÎļþÏÔʾÀàÐÍ sfd.AddExtension = false; sfd.ShowDialog(); string path = sfd.FileName; //ÏÂÔØ¸½¼þµ½±¾µØ£¬²¢Ö´ÐÐ BLL.ClsXt_FileCtrl oFile = new BLL.ClsXt_FileCtrl(); SQLHelper.ClsCNK3 oCNK3 = new SQLHelper.ClsCNK3(); if (oFile.WriteFile3("FFile" , DBUtility.ClsPub.AppPath + @"\a\" + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[PicNameCol].Value) , DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[YF_PictureIDCol].Value), oCNK3) == false) { MessageBox.Show("¶ÁÈ¡Îļþʱʧ°Ü!"); } //System.Diagnostics.Process.Start(DBUtility.ClsPub.AppPath + @"\a\" + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[PicNameCol].Value)); } } }