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 frmGG2 : Form
|
{
|
public frmGG2()
|
{
|
InitializeComponent();
|
}
|
|
|
public const int HFileNameCol = 0;//huan
|
public const int HFilePathCol = 1;
|
public const int HUpManCol = 2;
|
|
public const int MainType = 6;
|
public const string ModName = "4507"; //单据类型
|
public const string ModCaption = "行政公告"; //单据名称
|
public const string ModRightName = "frmGG2";
|
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 frmGG2_Load(object sender, EventArgs e)
|
{
|
initGrid();//huan
|
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 (txtZ.Text == "")
|
{
|
MessageBox.Show("请录入‘字’");
|
}
|
if (txtH.Text == "")
|
{
|
MessageBox.Show("请录入‘号’");
|
}
|
if (txtTM.Text == "")
|
{
|
MessageBox.Show("请录入主题");
|
}
|
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 frmGG2_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.isStrNull(txtZ.Text) == "")
|
{
|
MessageBox.Show("字没有填写!", "提示");
|
return false;
|
}
|
//
|
if (DBUtility.ClsPub.isStrNull(txtH.Text) == "")
|
{
|
MessageBox.Show("号没有填写!", "提示");
|
return false;
|
}
|
//
|
if (DBUtility.ClsPub.isStrNull(txtTM.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 TM = txtTM.Text.Replace("'", "‘");
|
string Desc = txtDesc.Text.Replace("'", "‘");
|
// SaveFile MainID 保存文件
|
oCn.RunProc("Insert into oa_gg2(id,operator,z,h"+
|
",description,opdate,tm,MainID,Emp"+
|
",h2,Maker,MakeDate) " +
|
" values (" +
|
MainID + ",'" + DBUtility.ClsPub.CurUserName + "','" + txtZ.Text + "','" + txtH.Text + "'" +
|
",'" + Desc + "',getdate(),'" + TM + "'," + MainID + ",'" + txtEmp.Text + "'" +
|
",'" + txth2.Text + "','" + DBUtility.ClsPub.CurUserName + "',getdate() )");
|
if (txtEmp.Text != "")
|
{
|
string[] s = txtEmp.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_gg2sub (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 cmdEmp_Click(object sender, EventArgs e)
|
{
|
DBUtility.Gy_UserSelect oUser = new DBUtility.Gy_UserSelect();
|
oUser.bSingle = false;
|
oUser.ShowDialog();
|
if (oUser.IsOk == 1)
|
{
|
txtEmp.Text = oUser.sReturn;
|
}
|
else
|
{
|
txtEmp.Text = "";
|
}
|
}
|
|
|
}
|
}
|