jinghz@oceic.com
2023-08-24 c5cfa2df88c6d2e5b31e87e1d5a8fe49d585f0bb
BaseSet/¹«ÓÃ×ÊÁÏ/ÆäËû»ù´¡×ÊÁÏ/Gy_StdWorkTimes.cs
@@ -8,7 +8,7 @@
using System.Text;
using System.Windows.Forms;
namespace BaseSet.公用资料.其他基础资料
namespace BaseSet
{
    public partial class Gy_StdWorkTimes : Form
    {
@@ -32,6 +32,8 @@
        public const Int16 HLowerlimit = 11;
        public const Int16 HUSEORGID = 12;
        public const Int16 HRemarkCol = 13;
        public const Int16 HStdPiece = 14;
        public const Int16 HStdPric = 15;
        public bool BillChange;   //
        public DBUtility.ClsPub.Enum_OKTag OkTag;
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
@@ -242,29 +244,44 @@
        {
            try
            {
                if (int.Parse(txtHStdWorkTimes.Text)<=0)
                if (Convert.ToDecimal(txtHStdWorkTimes.Text.ToString())<=0)
                {
                    MessageBox.Show("标准工时必须大于0", "提示");
                    return;
                }
                if (int.Parse(txtHUpperlimit.Text) <= 0)
                if (Convert.ToDecimal(txtHUpperlimit.Text) <= 0)
                {
                    MessageBox.Show("上限比例必须大于0", "提示");
                    return;
                }
                if (int.Parse(txtHLowerlimit.Text) <= 0)
                if (Convert.ToDecimal(txtHLowerlimit.Text) <= 0)
                {
                    MessageBox.Show("下线比例必须大于0", "提示");
                    return;
                }
                oCn.BeginTran();
                if (Convert.ToDecimal(txtHStdPiece.Text) <= 0)
                {
                    MessageBox.Show("标准计件必须大于0", "提示");
                    return;
                }
                if (Convert.ToDecimal(txtHStdPric.Text) <= 0)
                {
                    MessageBox.Show("标准计价必须大于0", "提示");
                    return;
                }
                string sql = string.Format(@"Update Gy_StdWorkTimes set" +
                            " HMaterID=" + textBox1.Text +
                            ",HProcID=" + textBox2.Text +
                            ",HStdWorkTimes=" + txtHStdWorkTimes.Text +
                            ",HUpperlimit=" + txtHUpperlimit.Text +
                            ",HLowerlimit=" + txtHLowerlimit.Text +
                            ",HStdPiece=" + txtHStdPiece.Text +
                            ",HStdPric=" + txtHStdPric.Text +
                            ",HMaker='" + DBUtility.ClsPub.CurUserName + "'" +
                            ",HMakeDate='" + DateTime.Now + "'" +
                            ",HUSEORGID=" + DBUtility.ClsPub.HOrgID +
                             " where HItemID=" + BillOld.HItemID);
                oCn.BeginTran();
                oCn.RunProc(sql);
                oCn.Commit();
                MessageBox.Show("修改成功,请退出并刷新", "提示");
@@ -334,7 +351,7 @@
        {
            timer1.Enabled = false;
            Sub_ControlLocation();
            if (BillOld.HItemID.ToString()!=null)//|| BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Viewonly
            if (BillOld.HItemID.ToString()!=null&& BillOld.HItemID.ToString() !="0")//|| BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Viewonly
            {
                this.Sub_ShowBill();
            }
@@ -365,37 +382,27 @@
        {
            switch (BillStatus)
            {
                case DBUtility.ClsPub.Enum_BillStatus.BillStatus_View:
                    //case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Viewonly:
                    //浏览状态
                    yl.Enabled = true;
                    xz.Enabled = true;
                case 0:
                    xg.Enabled = true;
                    sc.Enabled = true;
                    AddRow.Enabled = false;
                    DelRow.Enabled = false;
                    bc.Enabled = false;
                    tc.Enabled = true;
                    //未审核
                    if (txtHChecker.Text.Trim() == "")
                    {
                        xg.Enabled = true;
                        sc.Enabled = true;
                    }
                    else
                    {
                        xg.Enabled = false;
                        sc.Enabled = false;
                    }
                    Sub_LrtextStatus(true);
                    grdStatus = true;
                    break;
                case DBUtility.ClsPub.Enum_BillStatus.BillStatus_View:
                    xg.Enabled = true;
                    AddRow.Enabled = false;
                    DelRow.Enabled = false;
                    bc.Enabled = false;
                    tc.Enabled = true;
                    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;
                    AddRow.Enabled = true;
                    DelRow.Enabled = true;
                    bc.Enabled = true;
@@ -405,10 +412,7 @@
                    break;
                case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify:
                    //修改状态
                    yl.Enabled = false;
                    xz.Enabled = false;
                    xg.Enabled = false;
                    sc.Enabled = false;
                    AddRow.Enabled = true;
                    DelRow.Enabled = true;
                    bc.Enabled = true;
@@ -416,6 +420,7 @@
                    Sub_LrtextStatus(true);
                    grdStatus = true;
                    break;
            }
        }
@@ -445,48 +450,10 @@
            this.txtHStdWorkTimes.Text = dr["标准工时"].ToString();
            this.txtHUpperlimit.Text = dr["上线比例"].ToString();
            this.txtHLowerlimit.Text = dr["下线比例"].ToString();
            this.txtHStdPiece.Text = dr["标准计件"].ToString();
            this.txtHStdPric.Text = dr["标准计价"].ToString();
            //加载表体
            //initGrid();
            //int i = 0;
            //foreach (Model.ClsGy_StdWorkTimes_Model oSub in BillNew.DetailColl)
            //{
            //    //
            //    if (i >= grdMain1.RowCount - 1)
            //        grdMain1.Rows.Add();
            //    grdMain1.Rows[i].Cells[HTagCol].Value = "*";
            //    grdMain1.Rows[i].Cells[HMaterIDCol].Value = oSub.HMaterID.ToString();
            //    if (oMater.GetInfoByID(oSub.HMaterID))
            //    {
            //        grdMain1.Rows[i].Cells[HMaterNumberCol].Value = oMater.omodel.HNumber;
            //        grdMain1.Rows[i].Cells[HMaterNameCol].Value = oMater.omodel.HName;
            //        grdMain1.Rows[i].Cells[HMaterModelCol].Value = oMater.omodel.HModel;
            //    }
            //    else
            //    {
            //        grdMain1.Rows[i].Cells[HMaterNumberCol].Value = "";
            //        grdMain1.Rows[i].Cells[HMaterNameCol].Value = "";
            //        grdMain1.Rows[i].Cells[HMaterModelCol].Value = "";
            //    }
            //    grdMain1.Rows[i].Cells[HProcIDCol].Value = oSub.HProcID.ToString();
            //    if (oProc.GetInfoByID(oSub.HProcID))
            //    {
            //        grdMain1.Rows[i].Cells[HProcNumberCol].Value = oProc.omodel.HNumber;
            //        grdMain1.Rows[i].Cells[HProcNameCol].Value = oProc.omodel.HName;
            //    }
            //    else
            //    {
            //        grdMain1.Rows[i].Cells[HProcNumberCol].Value = "";
            //        grdMain1.Rows[i].Cells[HProcNameCol].Value = "";
            //    }
            //    grdMain1.Rows[i].Cells[HStdWorkTimes].Value = oSub.HStdWorkTimes.ToString();
            //    grdMain1.Rows[i].Cells[HUpperlimit].Value = oSub.HUpperlimit.ToString();
            //    grdMain1.Rows[i].Cells[HLowerlimit].Value = oSub.HLowerlimit.ToString();
            //    grdMain1.Rows[i].Cells[HUSEORGID].Value = oSub.HUSEORGID.ToString();
            //    grdMain1.Rows[i].Cells[HRemarkCol].Value = oSub.HRemark;
            //    i = i + 1;
            //}
            //GRID允许刷新
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            //合计
@@ -499,16 +466,6 @@
        //单据完整性判断          æœªå®Œæˆ
        private bool Sub_AllowSave()
        {
            //必输项目是否为空
            //ClsK3_DepartmentHlp oDept = new ClsK3_DepartmentHlp();
            //if(!oDept.GetInfoByID(ClsPub.isLong(txtHDeptID.Tag)))
            //{
            //    MessageBox.Show("部门不存在!");
            //    return false;
            //}
            //明细表是否为零行
            if (!IsNullRow(0))
            {
                MessageBox.Show("表体明细行不存在!请录入!", "提示");
@@ -516,8 +473,18 @@
            }
            else
            {
                return true;
            }
        }
        //是否是空行
        private bool IsNullRow(int Row)
        {
            if (ClsPub.isInt(grdMain1.Rows[Row].Cells[HMaterIDCol].Value) == 0&& ClsPub.isInt(grdMain1.Rows[Row].Cells[HProcIDCol].Value) == 0&& ClsPub.isDoule( grdMain1.Rows[Row].Cells[HStdWorkTimes].Value )== 0&& ClsPub.isDoule(grdMain1.Rows[Row].Cells[HUpperlimit].Value) == 0&& ClsPub.isDoule(grdMain1.Rows[Row].Cells[HLowerlimit].Value) == 0&& ClsPub.isStrNull(grdMain1.Rows[Row].Cells[HRemarkCol].Value) == ""&& ClsPub.isDoule(grdMain1.Rows[Row].Cells[HStdPiece].Value) == 0&& ClsPub.isDoule(grdMain1.Rows[Row].Cells[HStdPiece].Value) == 0)
            {
                return true;
            }
            return false;
        }
        //保存单据
        private bool Sub_SaveBill()
@@ -526,11 +493,7 @@
            Int32 i;
            bool bResult;
            BillNew = new DAL.ClsGy_StdWorkTimes_Ctl();
            //编辑权限
            //if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
            //{
            //    return false;
            //}
            //失去焦点
            lblCaption.Focus();
            //
@@ -542,9 +505,13 @@
            BillNew.DetailColl = new List<Model.ClsGy_StdWorkTimes_Model>();
            for (i = 0; i <= grdMain1.RowCount - 1; i++)
            {
                if (DBUtility.ClsPub.isLong(grdMain1.Rows[i].Cells[HMaterIDCol].Value) != 0 && DBUtility.ClsPub.isLong(grdMain1.Rows[i].Cells[HProcIDCol].Value) != 0)
                if (IsNullRow(i))
                {
                    if (DBUtility.ClsPub.isLong(grdMain1.Rows[i].Cells[HStdWorkTimes].Value)>0&& DBUtility.ClsPub.isLong(grdMain1.Rows[i].Cells[HUpperlimit].Value) > 0&& DBUtility.ClsPub.isLong(grdMain1.Rows[i].Cells[HLowerlimit].Value) > 0)
                    break;
                }
                if (DBUtility.ClsPub.isStrNull(grdMain1.Rows[i].Cells[HMaterIDCol].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain1.Rows[i].Cells[HProcIDCol].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain1.Rows[i].Cells[HStdWorkTimes].Value) != "")
                {
                    if (DBUtility.ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdWorkTimes].Value) > 0 && DBUtility.ClsPub.isDoule(grdMain1.Rows[i].Cells[HUpperlimit].Value) > 0 && DBUtility.ClsPub.isDoule(grdMain1.Rows[i].Cells[HLowerlimit].Value) > 0 && DBUtility.ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdPiece].Value) > 0 && DBUtility.ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdPric].Value) > 0)
                    {
                        Model.ClsGy_StdWorkTimes_Model oSub = new Model.ClsGy_StdWorkTimes_Model();
                        oSub.HMaterID = ClsPub.isLong(grdMain1.Rows[i].Cells[HMaterIDCol].Value);
@@ -552,6 +519,8 @@
                        oSub.HStdWorkTimes = ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdWorkTimes].Value);
                        oSub.HUpperlimit = ClsPub.isDoule(grdMain1.Rows[i].Cells[HUpperlimit].Value);
                        oSub.HLowerlimit = ClsPub.isDoule(grdMain1.Rows[i].Cells[HLowerlimit].Value);
                        oSub.HStdPiece = ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdPiece].Value);
                        oSub.HStdPric = ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdPric].Value);
                        oSub.HUSEORGID = ClsPub.HOrgID;
                        oSub.HStopflag = false;
                        oSub.HMaker = ClsPub.CurUserName;
@@ -561,9 +530,14 @@
                    }
                    else
                    {
                        MessageBox.Show("第" + (i+1) + "行,标准工时,上限比例和下限比例都应大于0", "提示");
                        MessageBox.Show("第" + (i + 1) + "行,标准工时,上限比例,下限比例,标准计件和标准计价都应大于0", "提示");
                        return false;
                    }
                }
                else
                {
                    MessageBox.Show("第" + (i + 1) + "行,物料、工序和标准工时不能为空", "提示");
                    return false;
                }
            }
            //保存完毕后处理
@@ -632,6 +606,9 @@
            grdMain1.Columns[HStdWorkTimes].HeaderText = "标准工时";
            grdMain1.Columns[HUpperlimit].HeaderText = "上限比例";
            grdMain1.Columns[HLowerlimit].HeaderText = "下限比例";
            grdMain1.Columns[HStdPiece].HeaderText = "标准计件";
            grdMain1.Columns[HStdPric].HeaderText = "标准计价";
            grdMain1.Columns[HUSEORGID].HeaderText = "组织ID";
            grdMain1.Columns[HRemarkCol].HeaderText = "备注";
            //
@@ -646,6 +623,8 @@
                            "," + HStdWorkTimes.ToString() +
                            "," + HUpperlimit.ToString() +
                            "," + HLowerlimit.ToString() +
                            "," + HStdPiece.ToString() +
                            "," + HStdPric.ToString() +
                            "," + HRemarkCol.ToString();
            //合计列
            string sTotalCol = "";
@@ -710,15 +689,6 @@
            //  
            oSumGrid.EditStatus = false;
            return true;
        }
        //是否是空行
        private bool IsNullRow(int Row)
        {
            if (ClsPub.isInt(grdMain1.Rows[Row].Cells[HMaterIDCol].Value) == 0)
            {
                return true;
            }
            return false;
        }
        //'判断网格行的录入是否正确
        private bool CheckGridRow(int Row)