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 OA_EmpMinMessage : Form { public OA_EmpMinMessage() { InitializeComponent(); } //定义 public const Int16 HTagCol = 0; public const Int16 HSnoCol = 1; public const Int16 HSendStatusCol = 2; public const Int16 HSendManCol = 3; public const Int16 HDateCol = 4; public const Int16 HDescriptionCol = 5; //表1 // public const string ModName = "4528"; public const string ModCaption = "个人微讯"; public const string ModRightName = "OA_EmpMinMessage"; 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 Pub_Class.ClsPub.Enum_BillStatus BillStatus; public Int64 KeyID; public bool grdStatus; public DAL.ClsOA_EmpMinMessage BillNew = new DAL.ClsOA_EmpMinMessage(); public DAL.ClsOA_EmpMinMessage BillOld = new DAL.ClsOA_EmpMinMessage(); //------------------------------------------------------------------------- #region 固定代码 //清空界面 public void Sub_ClearBill() { //清空界面控件 for 控件 DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp); // //txtHMaker.Text = DBUtility.ClsPub.CurUserName; //txtHMakeDate.Text = ""; //txtHChecker.Text = ""; //txtHCheckDate.Text = ""; //txtHCloseMan.Text = ""; //txtHCloseDate.Text = ""; //txtHDeleteMan.Text = ""; //txtHDeleteDate.Text = ""; //txtHUpDater.Text = ""; //txtHUpDateDate.Text = ""; initGrid(); } //编辑单据 private void Sub_EditBill() { string s = ""; if (BillOld.ShowBill(BillOld.omodel.HInterID, ref s) == false) { MessageBox.Show("此单据有错误!", "提示"); return; } //判断是否可编辑 if (BillOld.omodel.HChecker != "") { MessageBox.Show("此单据已经被审核,不允许修改", "提示"); return; } if (BillOld.omodel.HBillStatus > 1) { MessageBox.Show("此单据处于不可编辑状态,不允许修改", "提示"); return; } if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld, ref s)) { MessageBox.Show(s + ",不允许修改", "提示"); return; } // this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify; this.Sub_OperStatus();//刷新TOOLBAR // //txtHUpDater.Text = DBUtility.ClsPub.CurUserName; //txtHBillNo.Enabled = false; //单据号不允许修改 } //删除单据 private void Sub_DeleteBill() { //判断权限 //if (!ClsPub.Security_Log(ModRightNameEdit, 1, true,DBUtility.ClsPub.CurUserName)) //{ // return; //} string s = ""; if (BillOld.ShowBill(BillOld.omodel.HInterID, ref s) == false) { MessageBox.Show("此单据有错误!", "提示"); return; } if (BillOld.omodel.HChecker != "") { MessageBox.Show("此单据已经被审核,不允许删除", "提示"); return; } if (BillOld.omodel.HBillStatus > 1) { MessageBox.Show("此单据处于不可删除状态,不允许删除", "提示"); return; } if (!DBUtility.Xt_BaseBillFun.Fun_AllowDeleteBill(BillOld, ref s)) { MessageBox.Show(s + ",不允许删除", "提示"); return; } // if (MessageBox.Show("确定要删除当前单据?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { if (BillOld.DeleteBill(BillOld.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo) != true) { BillChange = true; MessageBox.Show("删除失败,原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); return; } MessageBox.Show("删除成功", "提示"); //BillOld = new DAL.ClsOA_EmpMinMessage(); //this.Sub_Next(); //显示下一张单据 //if (BillOld.omodel.HInterID == 0)//若找不到下一张,则显示上一张 //{ // this.Sub_Prev(); //} //if (BillOld.omodel.HInterID == 0)//若找不到上一张,清空 //{ this.Sub_ClearBill(); //} BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; this.Sub_OperStatus(); } } private void bclk_Click(object sender, EventArgs e) { //保存列宽 //DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); } private void mrlk_Click(object sender, EventArgs e) { //DBUtility.ClsPub.DefaultGridView(grdMain); //参数解释 开始列 ,结束列,是否以最大列宽为准,最小列宽 //DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); } //放弃 编辑 private void Sub_AbandonBill() { if (BillStatus == Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew || BillStatus == Pub_Class.ClsPub.Enum_BillStatus.BillStatus_Modify) { if (MessageBox.Show("单据尚未保存,是否放弃?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { //显示第一张单据 this.Sub_First(); } } } private void OA_EmpMinMessage_Paint(object sender, PaintEventArgs e)//画线 { } //控件位置 private void Sub_ControlLocation() { // } //窗体加载 private void OA_EmpMinMessage_Load(object sender, EventArgs e) { //打印初始化 dtpHDate.Value = DateTime.Today; this.Text = ModCaption; //命名窗体标题 this.lblCaption.Text = ModCaption;//命名单据标题 } //首张 private void Sub_First() { // } //上张 private void Sub_Prev() { // } //下张 private void Sub_Next() { // } //末张 private void Sub_Last() { // } //审核单据 private void Sub_CheckBill() { //判断权限 //if (!ClsPub.Security_Log(ModRightNameCheck, 1, true, DBUtility.ClsPub.CurUserName)) //{ // return; //} string s = ""; if (!DBUtility.Xt_BaseBillFun.Fun_AllowCheckBill(BillOld, ref s)) { MessageBox.Show(s + ",不允许审核", "提示"); return; } if (BillOld.CheckBill(BillOld.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo) == true) { BillChange = true; this.Sub_ShowBill(); } else { MessageBox.Show("审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); } } //反审单据 private void Sub_AbandonCheck() { //判断权限 //if (!ClsPub.Security_Log(ModRightNameCheck, 1, true, DBUtility.ClsPub.CurUserName)) //{ // return; //} // string s = ""; if (!DBUtility.Xt_BaseBillFun.Fun_AllowAbandonCheckBill(BillOld, ref s)) { MessageBox.Show(s + ",不允许反审核", "提示"); return; } if (BillOld.AbandonCheck(BillOld.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo) == true) { BillChange = true; this.Sub_ShowBill(); } else { MessageBox.Show("反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); } } //关闭单据 private void Sub_CloseBill() { ////关闭权限 //if (!ClsPub.Security_Log(ModRightNameClose, 1, true)) //{ // return; //} //// //if (BillOld.CloseBill(BillOld.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // txtHCloseMan.Text = ClsPub.CurUserName; // txtHCloseDate.Text = BillOld.HCloseDate; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("关闭失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //反关闭单据 private void Sub_Cancel() { ////关闭权限 //if (!ClsPub.Security_Log(ModRightNameClose, 1, true)) //{ // return; //} //// //if (BillOld.CancelClose(BillOld.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // txtHCloseMan.Text = ""; // txtHCloseDate.Text = ""; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("恢复失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //作废单据 private void Sub_Cancelltion() { ////作废权限 //if (!ClsPub.Security_Log(ModRightNameDelete, 1, true)) //{ // return; //} //// //if (BillOld.Cancelltion(BillOld.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // this.txtHDeleteMan.Text = ClsPub.CurUserName; // this.txtHDeleteDate.Text = BillOld.HDeleteDate; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("作废失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //反作废 private void Sub_AbandonCancelltion() { ////作废权限 //if (!ClsPub.Security_Log(ModRightNameDelete, 1, true)) //{ // return; //} //// //if (BillOld.AbandonCancelltion(BillOld.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // this.txtHDeleteMan.Text = ""; // this.txtHDeleteDate.Text = ""; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("作废失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //新增按纽 private void xz_Click(object sender, EventArgs e) { this.Sub_AddBill(); } //修改按纽 private void xg_Click(object sender, EventArgs e) { this.Sub_EditBill(); } //删除按钮 private void sc_Click(object sender, EventArgs e) { this.Sub_DeleteBill(); } //保存按钮 private void bc_Click(object sender, EventArgs e) { this.Sub_SaveBill(); } //放弃按钮 private void fq_Click(object sender, EventArgs e) { this.Sub_AbandonBill(); } //审核按钮 private void sh_Click(object sender, EventArgs e) { this.Sub_CheckBill(); } //放弃审核按钮 private void qsh_Click(object sender, EventArgs e) { this.Sub_AbandonCheck(); } //关闭按钮 private void gb_Click(object sender, EventArgs e) { this.Sub_CloseBill(); } //恢复按钮 private void hf_Click(object sender, EventArgs e) { this.Sub_Cancel(); } //作废按钮 private void zf_Click(object sender, EventArgs e) { this.Sub_Cancelltion(); } //反作废按钮 private void zc_Click(object sender, EventArgs e) { this.Sub_AbandonCancelltion(); } //首张单据按钮 private void sz_Click(object sender, EventArgs e) { this.Sub_First(); } //上一张按钮 private void syz_Click(object sender, EventArgs e) { this.Sub_Prev(); } //下一张按钮 private void xyz_Click(object sender, EventArgs e) { this.Sub_Next(); } //末张按钮 private void mz_Click(object sender, EventArgs e) { this.Sub_Last(); } //退出按钮 private void tc_Click(object sender, EventArgs e) { this.Close(); } //窗体尺寸变化时 private void OA_EmpMinMessage_Resize(object sender, EventArgs e) { Sub_ControlLocation(); } //根据编辑状态 设置 控件是否允许录入 private void Sub_LrtextStatus(bool TextEnabled) { if (TextEnabled == true) { //控件全部有效 gbUp.Enabled = true; //grdMain.BackColor = DBUtility.ClsPub.EditColor; } else { //控件全部无效 gbUp.Enabled = false; //grdMain.BackColor = DBUtility.ClsPub.ViewColor; } } //复制单据 private void Sub_CopyBill() { this.BillStatus = Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew; this.Sub_OperStatus();//设置TOOLBAR //this.txtHBillNo.Text = DBUtility.ClsPub.CreateBillCode(BillNew.BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//得到新单号 //this.txtHBillNo.Enabled = true; //this.txtHBillNo.Focus(); //this.txtHMaker.Text = DBUtility.ClsPub.CurUserName; //this.txtHMakeDate.Text = DBUtility.ClsPub.GetServerDate(-1); //this.txtHChecker.Text = ""; //this.txtHCloseDate.Text = ""; //this.txtHCloseMan.Text = ""; //this.txtHCloseDate.Text = ""; //this.txtHDeleteMan.Text = ""; //this.txtHDeleteDate.Text = ""; //this.txtHUpDater.Text = ""; //this.txtHUpDateDate.Text = ""; } //复制按钮 private void fz_Click(object sender, EventArgs e) { Sub_CopyBill(); } //timer private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; Sub_ControlLocation(); if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_View) { this.Sub_ShowBill(); } else { this.Sub_AddBill(); } } //窗体卸载 private void OA_EmpMinMessage_FormClosing(object sender, FormClosingEventArgs e) { BillStatus = Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew; //DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); } //新增单据 private void Sub_AddBill() { this.BillNew = new DAL.ClsOA_EmpMinMessage(); this.BillOld = new DAL.ClsOA_EmpMinMessage(); this.BillStatus = Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew; this.Sub_OperStatus();//设置TOOLBAR this.Sub_ClearBill();//清空界面 //this.txtHBillNo.Text = DBUtility.ClsPub.CreateBillCode(BillNew.BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//得到新单号 //this.txtHBillNo.Enabled = true; //this.txtHBillNo.Focus(); } //TOOLBAR状态 按钮是否灰度 public void Sub_OperStatus() { switch (BillStatus) { case DBUtility.ClsPub.Enum_BillStatus.BillStatus_View: //浏览状态 yl.Enabled = true; xz.Enabled = true; //xg.Enabled = true; sc.Enabled = true; bc.Enabled = false; fq.Enabled = false; sz.Enabled = true; syz.Enabled = true; xyz.Enabled = true; mz.Enabled = true; tc.Enabled = true; fz.Enabled = true; //未审核 //if (txtHChecker.Text.Trim() == "") //{ // sh.Enabled = true; // qsh.Enabled = false; // gb.Enabled = false; // hf.Enabled = false; // xg.Enabled = true; // sc.Enabled = true; // //未审核 // pic1.Visible = false; // pic1.Image = null; // // //} //else if (txtHCloseMan.Text.Trim() == "" && txtHChecker.Text.Trim() != "")//审核未关闭 //{ // sh.Enabled = false; // qsh.Enabled = true; // gb.Enabled = true; // hf.Enabled = false; // xg.Enabled = false; // sc.Enabled = false; // // // pic1.Visible = true; // pic1.Image = System.Drawing.Image.FromFile(DBUtility.ClsPub.AppPath + @"/Pic/Checked.jpg"); // // //} //else//已关闭 //{ // sh.Enabled = false; // qsh.Enabled = false; // gb.Enabled = false; // hf.Enabled = true; // xg.Enabled = false; // sc.Enabled = false; // // // pic1.Visible = true; // pic1.Image = System.Drawing.Image.FromFile(DBUtility.ClsPub.AppPath + @"/Pic/Closed.jpg"); // // //} //if (txtHDeleteMan.Text.Trim() == "") //{ // zf.Enabled = true; // zc.Enabled = false; //} //else //已作废 //{ // zf.Enabled = false; // zc.Enabled = true; // xg.Enabled = false; // sc.Enabled = false; // bc.Enabled = false; // fq.Enabled = false; // sh.Enabled = false; // qsh.Enabled = false; // gb.Enabled = false; // hf.Enabled = false; // // // pic1.Visible = true; // pic1.Image = System.Drawing.Image.FromFile(DBUtility.ClsPub.AppPath + @"/Pic/Deleted.jpg"); // // //} Sub_LrtextStatus(false); grdStatus = false; break; case DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew: //新增状态 yl.Enabled = false; xz.Enabled = false; xg.Enabled = false; sc.Enabled = false; bc.Enabled = true; fq.Enabled = true; sh.Enabled = false; qsh.Enabled = false; gb.Enabled = false; hf.Enabled = false; zf.Enabled = false; zc.Enabled = false; sz.Enabled = false; syz.Enabled = false; xyz.Enabled = false; mz.Enabled = false; tc.Enabled = true; Sub_LrtextStatus(true); grdStatus = true; fz.Enabled = false; //未审核 pic1.Visible = false; pic1.Image = null; // break; case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify: //修改状态 yl.Enabled = false; xz.Enabled = false; xg.Enabled = false; sc.Enabled = false; bc.Enabled = true; fq.Enabled = true; sh.Enabled = false; qsh.Enabled = false; gb.Enabled = false; hf.Enabled = false; zf.Enabled = false; zc.Enabled = false; sz.Enabled = false; syz.Enabled = false; xyz.Enabled = false; mz.Enabled = false; tc.Enabled = true; Sub_LrtextStatus(true); grdStatus = true; fz.Enabled = false; //未审核 pic1.Visible = false; pic1.Image = null; // break; } } #endregion #region 读写类 //显示单据 public void Sub_ShowBill() { //判断是否存在单据 if (BillOld.ShowBill(BillOld.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo) == false) { MessageBox.Show(DBUtility.ClsPub.sExeReturnInfo, "提示"); return; } //清空 Sub_ClearBill(); //grid禁止刷新 //grdMain.Redraw = VSFlex7.RedrawSettings.flexRDNone; //加载表头 //HEvaluateStatusID // this.dtpHDate.Value = BillOld.omodel.HDate; //this.txtHBillNo.Text = BillOld.omodel.HBillNo; this.txtHDescription.Text = BillOld.omodel.HDescription; this.txtHSendMan.Text = BillOld.omodel.HSendMan; this.txtHReceiveMan.Text = BillOld.omodel.HReceiveMan; this.chkHSystemFlag.Checked = BillOld.omodel.HSystemFlag; this.chkHReadFlag.Checked = BillOld.omodel.HReadFlag; //GRID允许刷新 // Sub_OperStatus(); } //单据完整性判断 未完成 private bool Sub_AllowSave() { //必输项目是否为空 //if (txtHDeptID.Tag.ToString().Trim() == "0") //{ // MessageBox.Show("部门没有选择!", "提示"); // return false; //} //单据号是否重复 //if (BillNew.IsExistBillNo(ref DBUtility.ClsPub.sExeReturnInfo, txtHBillNo.Text.Trim(), BillStatus, BillOld.omodel.HInterID)) //{ // MessageBox.Show("单据号重复!不允许保存!", "提示"); // return false; //} //明细表是否为零行 return true; } //保存单据 private bool Sub_SaveBill() { //编辑权限 //if (!ClsPub.Security_Log(ModRightNameEdit, 1, true)) //{ // return false; //} Int32 i; bool bResult; //网格失去焦点 this.lblCaption.Focus(); // BillNew = new DAL.ClsOA_EmpMinMessage(); if (!Sub_AllowSave())//单据完整性判断 return false; ////是否是合理的会计期间 int sYear = 0; int sPeriod = 0; //主类赋值 BillNew.omodel.HYear = sYear; BillNew.omodel.HPeriod = sPeriod; BillNew.omodel.HDate = this.dtpHDate.Value; BillNew.omodel.HDescription = ClsPub.isStrNull(this.txtHDescription.Text); BillNew.omodel.HSendMan = this.txtHSendMan.Text.Trim().Replace("'", "''"); BillNew.omodel.HReceiveMan = this.txtHReceiveMan.Text.Trim().Replace("'", "''"); BillNew.omodel.HReadFlag = this.chkHReadFlag.Checked; BillNew.omodel.HSystemFlag = this.chkHSystemFlag.Checked; // //保存完毕后处理 if (BillStatus == Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew) { bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { //bResult = BillNew.ModifyBill(BillNew.HInterID, ref ClsPub.sExeReturnInfo); bResult = false; } //提示 if (bResult == true) { BillChange = true; MessageBox.Show("单据存盘完毕!", "提示"); //if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew) //{ // BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; // BillOld.omodel.HInterID = BillNew.omodel.HInterID; // this.Sub_ShowBill(); //} //else if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify) //{ // BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; //} this.Sub_OperStatus(); return true; } else { MessageBox.Show("保存失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); return false; } } #endregion #region 窗体处理方法 //初始化GRID private void initGrid() { //表1 //grdMain.ColumnCount = 6; //总列数 //DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name); //grdMain.RowCount = 1; //设置 标题 //grdMain.Columns[HTagCol].HeaderText = ""; //grdMain.Columns[HSnoCol].HeaderText = "序号"; //grdMain.Columns[HSendManCol].HeaderText = "回复人"; //grdMain.Columns[HSendStatusCol].HeaderText = "类型"; //grdMain.Columns[HDateCol].HeaderText = "回复日期"; //grdMain.Columns[HDescriptionCol].HeaderText = "回复内容"; //格式化 //隐藏列 //grdMain.Columns[HTagCol].Visible = false; // //DBUtility.ClsPub.GetGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath);//设置列宽 //设置可编辑列和合计列 } private void cmdHSendMan_Click(object sender, EventArgs e) { DBUtility.Gy_UserSelect oUser = new DBUtility.Gy_UserSelect(); oUser.bSingle = true; oUser.ShowDialog(); if (oUser.IsOk == 1) { txtHSendMan.Text = oUser.sReturn; } else { txtHSendMan.Text = ""; } } private void cmdHReceiveMan_Click(object sender, EventArgs e) { DBUtility.Gy_UserSelect oUser = new DBUtility.Gy_UserSelect(); oUser.bSingle = true; oUser.ShowDialog(); if (oUser.IsOk == 1) { txtHReceiveMan.Text = oUser.sReturn; } else { txtHReceiveMan.Text = ""; } } //回复按钮 private void msg_Click(object sender, EventArgs e) { BackMessage(); } public void BackMessage() { return; } #endregion } }