yangle
2022-10-29 16bb2f7b48cf2c3cfbb6a026c265d4e52d22eca4
BaseSet/¹«ÓÃ×ÊÁÏ/ÆäËû»ù´¡×ÊÁÏ/Gy_StdWorkTimesList.cs
@@ -7,7 +7,7 @@
using System.Text;
using System.Windows.Forms;
namespace BaseSet.公用资料.其他基础资料
namespace BaseSet
{
    public partial class Gy_StdWorkTimesList : Form
    {
@@ -118,40 +118,45 @@
        //删除项目
        public void Delete()
        {
            Int64 lngBillKey = 0;
            if (grdMain.SelectedRows.Count == 0)
            {
                MessageBox.Show("请至少选择一行!", "提示");
                return;
            }
            //删除权限
            if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
            {
                return;
            }
            //
            if (AllowRow())
            {
                if (MessageBox.Show("确定要删除当前项目?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    //得到HITEMID
                    long sItemID;
                    sItemID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[HItemIDCol].Value);
                    //判断存在性
                    if (oMatePrce.ShowBill(sItemID, ref DBUtility.ClsPub.sExeReturnInfo))
                    oCn.BeginTran();
                    for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
                    {
                        foreach (Model.ClsGy_StdWorkTimes_Model oSub in oMatePrce.DetailColl)
                        lngBillKey = DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("HItemID")].Value);
                        if (lngBillKey == 0)
                            return;
                        DAL.ClsGy_StdWorkTimes_Ctl oItem = new DAL.ClsGy_StdWorkTimes_Ctl();
                        //审核
                        //查看是否已审核,关闭,作废
                        DataSet DsSub = oCn.RunProcReturn("Select * from Gy_StdWorkTimes Where HitemID=" + lngBillKey.ToString(), "Gy_StdWorkTimes");
                        if (!string.IsNullOrEmpty(DsSub.Tables[0].Rows[0]["HChecker"].ToString()))
                        {
                            if (oSub.HChecker.Trim() != "")
                            {
                                MessageBox.Show("单据已审核!不能删除", "提示");
                                return;
                            }
                        }
                        if (oMatePrce.DeleteByID(sItemID))
                        {
                            MessageBox.Show("删除项目成功!", "提示");
                            Display();
                            oCn.RollBack();
                            MessageBox.Show("标准工时:"+ DsSub.Tables[0].Rows[0]["HStdWorkTimes"].ToString() + "的单据已审核,无法删除", "提示");
                            return;
                        }
                        else
                            MessageBox.Show("删除项目成功!", "提示");
                        {
                            oCn.RunProc(" delete Gy_StdWorkTimes where HItemID=" + lngBillKey.ToString());
                        }
                    }
                    oCn.Commit();
                    MessageBox.Show("删除成功,请刷新!", "提示");
                    return;
                }
            }
@@ -181,14 +186,7 @@
            if (oBillMain.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
            {
                oFrm = new Gy_StdWorkTimes();
                oFrm.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View;
                foreach (Model.ClsGy_StdWorkTimes_Model oSub in oBillMain.DetailColl)
                {
                    if (oSub.HChecker.Trim() != "")
                    {
                        oFrm.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View;
                    }
                }
                oBill.HItemID = lngBillKey;
                oFrm.BillOld = oBill;
                oFrm.BillNew = oBillMain;
@@ -265,9 +263,9 @@
                sr = CurNode.Text.Split(c);
                HParentID = sr[0].ToString();
            }
            //过滤条件
            if (frmCondition.SqlStr.Trim().Length == 0)
            if (frmCondition==null)
            {
                //过滤条件
                if (HParentID == "" || HParentID == "物料资料" || HParentID == "工序资料")
                {
                    sSql = "Select top 10000 * from " + ViewName + " order by  HItemID Desc";
@@ -276,7 +274,7 @@
                {
                    if (wl.Checked == false)
                    {
                        sSql = "Select top 10000 * from " + ViewName + " where å·¥åºä»£ç  like '%" + HParentID.ToString() + "%' order by HItemID Desc" ;
                        sSql = "Select top 10000 * from " + ViewName + " where å·¥åºä»£ç  like '%" + HParentID.ToString() + "%' order by HItemID Desc";
                    }
                    else
                    {
@@ -287,8 +285,9 @@
            }
            else
            {
                sSql = frmCondition.SqlStr + sWhere + " order by  HItemID Desc";
            }
                sSql = frmCondition.SqlStr + sWhere + " order by " + ModName;
            }
            //执行SQL
            DSet = SubCn.RunProcReturn(sSql, ViewName);
@@ -310,12 +309,12 @@
            oSumGrid.BuildTotalCols(sT);
            //  
            //冻结
            int FrCol = DBUtility.ClsPub.isInt(frmCondition.txtFrozenCol.Text);
            string s = frmCondition.cmbHComplete.Text;
            DBUtility.Xt_BaseBillFun.DisplayGrid(grdMain, this.Name, s, FrCol);
            //int FrCol = DBUtility.ClsPub.isInt(frmCondition.txtFrozenCol.Text);
            //string s = frmCondition.cmbHComplete.Text;
            //DBUtility.Xt_BaseBillFun.DisplayGrid(grdMain, this.Name, s, FrCol);
            //画线
            //
            Total();
            //Total();
        }
        //合计 new
@@ -395,27 +394,24 @@
                DAL.ClsGy_StdWorkTimes_Ctl oItem = new DAL.ClsGy_StdWorkTimes_Ctl();
                //审核
                //查看是否已审核,关闭,作废
                if (oItem.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
                DataSet DsSub = oCn.RunProcReturn("Select * from Gy_StdWorkTimes Where HitemID=" + lngBillKey.ToString(), "Gy_StdWorkTimes");
                if (!string.IsNullOrEmpty(DsSub.Tables[0].Rows[0]["HChecker"].ToString()))
                {
                    MessageBox.Show("单据已审核,无需审核", "提示");
                    return;
                }
                else
                {
                    MessageBox.Show("项目不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
                    return;
                }
                //审核
                if (oItem.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                {
                    MessageBox.Show("审核成功!第"+i.ToString()+"行", "提示");
                }
                else
                {
                    MessageBox.Show("审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
                    return;
                    //审核
                    if (oItem.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) != true)
                    {
                        MessageBox.Show("审核失败!", "提示");
                        return;
                    }
                }
            }
            MessageBox.Show("审核成功,请刷新!", "提示");
            MessageBox.Show("审核成功!", "提示");
            Display();
            return;
        }
        //反审核
@@ -435,34 +431,103 @@
                DAL.ClsGy_StdWorkTimes_Ctl oItem = new DAL.ClsGy_StdWorkTimes_Ctl();
                //审核
                //查看是否已审核,关闭,作废
                if (oItem.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
                DataSet DsSub = oCn.RunProcReturn("Select * from Gy_StdWorkTimes Where HitemID=" + lngBillKey.ToString(), "Gy_StdWorkTimes");
                if (string.IsNullOrEmpty(DsSub.Tables[0].Rows[0]["HChecker"].ToString()))
                {
                    MessageBox.Show("单据未审核,无需反审核", "提示");
                    return;
                }
                else
                {
                    MessageBox.Show("项目不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
                    return;
                }
                //审核
                if (oItem.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                {
                    MessageBox.Show("审核成功!第"+i.ToString()+"行", "提示");
                }
                else
                {
                    MessageBox.Show("审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
                    return;
                    //审核
                    if (oItem.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) != true)
                    {
                        MessageBox.Show("反审核失败!", "提示");
                        return;
                    }
                }
            }
            MessageBox.Show("审核成功,请刷新!", "提示");
            MessageBox.Show("反审核成功!", "提示");
            Display();
            return;
        }
        //考贝
        private void yl_Click(object sender, EventArgs e)
        {
            DBUtility.Gy_BaseFun.DataToExcel(this.Text, grdMain);
        }
        private void jy_Click(object sender, EventArgs e)
        {
            Int64 lngBillKey = 0;
            if (grdMain.SelectedRows.Count == 0)
            {
                MessageBox.Show("请至少选择一行!", "提示");
                return;
            }
            for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
            {
                lngBillKey = DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("HItemID")].Value);
                if (lngBillKey == 0)
                    return;
                DAL.ClsGy_StdWorkTimes_Ctl oItem = new DAL.ClsGy_StdWorkTimes_Ctl();
                //审核
                //查看是否已审核,关闭,作废
                DataSet DsSub = oCn.RunProcReturn("Select * from Gy_StdWorkTimes Where HitemID=" + lngBillKey.ToString(), "Gy_StdWorkTimes");
                if (DsSub.Tables[0].Rows[0]["HStopflag"].ToString() == "1")
                {
                    MessageBox.Show("单据已禁用,无需禁用" , "提示");
                    return;
                }
                else
                {
                    oCn.RunProc(" Update Gy_StdWorkTimes set HStopflag=1 Where HItemID=" + lngBillKey.ToString());
                }
            }
            MessageBox.Show("禁用成功!", "提示");
            Display();
            return;
        }
        private void fjy_Click(object sender, EventArgs e)
        {
            Int64 lngBillKey = 0;
            if (grdMain.SelectedRows.Count == 0)
            {
                MessageBox.Show("请至少选择一行!", "提示");
                return;
            }
            for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
            {
                lngBillKey = DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("HItemID")].Value);
                if (lngBillKey == 0)
                    return;
                DAL.ClsGy_StdWorkTimes_Ctl oItem = new DAL.ClsGy_StdWorkTimes_Ctl();
                //审核
                //查看是否已审核,关闭,作废
                DataSet DsSub = oCn.RunProcReturn("Select * from Gy_StdWorkTimes Where HitemID=" + lngBillKey.ToString(), "Gy_StdWorkTimes");
                if (DsSub.Tables[0].Rows[0]["HStopflag"].ToString() == "0")
                {
                    MessageBox.Show("单据暂未禁用,无需反禁用", "提示");
                    return;
                }
                else
                {
                    oCn.RunProc(" Update Gy_StdWorkTimes set HStopflag=0 Where HItemID=" + lngBillKey.ToString());
                }
            }
            MessageBox.Show("反禁用成功!", "提示");
            Display();
            return;
        }
        //导出
        private void dc_Click(object sender, EventArgs e)
        {
            DBUtility.Gy_BaseFun.DataToExcel(this.Text, grdMain);
        }
    }
}