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 frmGG1 : Form { public frmGG1() { InitializeComponent(); } public const int HFileNameCol = 0;//huan public const int HFilePathCol = 1; public const int HUpManCol = 2; public const int MainType = 5; public const string ModName = "4508"; //µ¥¾ÝÀàÐÍ public const string ModCaption = "»áÒé֪ͨ"; //µ¥¾ÝÃû³Æ public const string ModRightName = "frmGG1"; 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 frmGG1_Load(object sender, EventArgs e) { initGrid();//huan dtpDate.Value = DateTime.Today; dtpEDate.Value = DateTime.Today; dtpsDate.Value = DateTime.Today; txtOperator.Text = DBUtility.ClsPub.CurUserName; this.Text = ModCaption; //ÃüÃû´°Ìå±êÌâ this.lblCaption.Text = ModCaption;//ÃüÃûµ¥¾Ý±êÌâ DBUtility.ClsPub.GetGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); } //н¨°´Å¥ private void cmdSend_Click(object sender, EventArgs e) { if (txtContext.Text == "") { MessageBox.Show("Çë¼ÈëÖ÷Ìâ"); return; } if (Sub_SaveBill()) { DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); this.Close(); } } //È¡Ïû°´Å¥ private void cmdCancel_Click(object sender, EventArgs e) { DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); this.Close(); } //Ìí¼Ó°´Å¥ private void cmdAdd_Click(object sender, EventArgs e) { 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; } } } 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 cmdDel_Click(object sender, EventArgs e) { if (grdMain.CurrentRow == null) { return; } grdMain.Rows.RemoveAt(grdMain.CurrentRow.Index); } //´°ÌåÐ¶ÔØ private void frmGG1_FormClosing(object sender, FormClosingEventArgs e) { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; } #endregion #region ¶ÁдÀà //ÏÔʾµ¥¾Ý public void Sub_ShowBill() { } //µ¥¾ÝÍêÕûÐÔÅÐ¶Ï Î´Íê³É private bool Sub_AllowSave() { //±ØÊäÏîÄ¿ÊÇ·ñΪ¿Õ if (DBUtility.ClsPub.isLong(txtManager.Tag) == 0) { MessageBox.Show("Ö÷³ÖÈËûÓÐÑ¡Ôñ£¡", "Ìáʾ"); return false; } // if (DBUtility.ClsPub.isLong(txtHNoteMan.Tag) == 0) { MessageBox.Show("¼Ç¼ÈËûÓÐÑ¡Ôñ£¡", "Ìáʾ"); return false; } // if (DBUtility.ClsPub.isLong(txtDesc.Tag) == 0) { MessageBox.Show("²Î»áÈËԱûÓÐÑ¡Ôñ£¡", "Ìáʾ"); return false; } // if (DBUtility.ClsPub.isStrNull(txtContext.Text) == "") { MessageBox.Show("»áÒéÖ÷ÌâûÓÐÌîд£¡", "Ìáʾ"); return false; } // if (DBUtility.ClsPub.isStrNull(txtAddr.Text) == "") { MessageBox.Show("»áÒ鵨µãûÓÐÌîд£¡", "Ìáʾ"); return false; } return true; } //±£´æµ¥¾Ý private bool Sub_SaveBill() { string sDate; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); long MainID; MainID = DBUtility.ClsPub.CreateBillID(ModName, ref DBUtility.ClsPub.sExeReturnInfo); sDate = DateTime.Now.ToString(); string Context = txtContext.Text.Replace("'", "¡®"); string Desc = txtDesc.Text.Replace("'", "¡®"); string Addr = txtAddr.Text.Replace("'", "¡®"); string Remark = txtRemark.Text.Replace("'", "¡®"); // SaveFile MainID ±£´æÎļþ oCn.RunProc("Insert into oa_gg1(id,manager,context,workdate,opdate"+ ",operator,description,addr,remark"+ ",MainID,sDate,Maker,MakeDate,HEDate,HNoteMan,HSummary) " + " values (" + MainID + ",'" + txtManager.Text + "','" + Context + "','" + dtpDate.Text + " " + dtpTime.Text + "',getdate()" + ",'" + txtOperator.Text + "','" + Desc + "','" + Addr + "','" + Remark + "'" + "," + MainID + ",'" + dtpsDate.Text + " " + dtpsTime.Text + "','" + DBUtility.ClsPub.CurUserName + "',getdate(),'" + dtpEDate.Text + " " + dtpHETime.Text + "','" + txtHNoteMan.Text + "','" + txtHSummary.Text + "')"); if (txtDesc.Text != "") { string[] s = txtDesc.Text.Split(','); int len = s.Length; for (int i = 0; i < len; i++) { int j = i + 1; string k = s[i].ToString(); oCn.RunProc("insert into oa_gg1sub (MainID,SubID,ROperator,isRead,isKnow,Description) " + "values (" + MainID + "," + j + ",'" + k + "',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; } #endregion private void cmdManager_Click(object sender, EventArgs e) { DBUtility.Gy_UserSelect oUser = new DBUtility.Gy_UserSelect(); oUser.bSingle = true; oUser.ShowDialog(); if (oUser.IsOk == 1) { txtManager.Text = oUser.sReturn; } else { txtManager.Text = ""; } } // private void cmdHNoteMan_Click(object sender, EventArgs e) { DBUtility.Gy_UserSelect oUser = new DBUtility.Gy_UserSelect(); oUser.bSingle = true; oUser.ShowDialog(); if (oUser.IsOk == 1) { txtHNoteMan.Text = oUser.sReturn; } else { txtHNoteMan.Text = ""; } } // private void cmdDesc_Click(object sender, EventArgs e) { DBUtility.Gy_UserSelect oUser = new DBUtility.Gy_UserSelect(); oUser.bSingle = false; oUser.ShowDialog(); if (oUser.IsOk == 1) { txtDesc.Text = oUser.sReturn; } else { txtDesc.Text = ""; } } } }