首页 > 其他分享 >SM3200btnGBSCDDMX

SM3200btnGBSCDDMX

时间:2025-01-05 17:13:10浏览次数:1  
标签:string SCDDZT SCDDMXIDList sql XS SM3200btnGBSCDDMX page

using Salien.Utility;
using Salien.Utility.SUWF;
using System;
using System.Collections.Generic;
using System.Data;

namespace SM3200btnGBSCDDMX
{
    class SM3200btnGBSCDDMX : ISuwfBus /*关闭订单*/
    {
        private SlnSuwfPage _page;
        #region initial
        void ISuwfBus.Initial(SlnSuwfPage page)
        {
            _page = page;
            ClsPub.PUB.BindButtonEvent(_page, "btnGBSCDDMX", BtnGBSCDDMX_Click);
        }
        #endregion

        #region 关闭
        private void BtnGBSCDDMX_Click(object sender, EventArgs e)
        {
            try
            {
                string strPK = _page.GetRowDataPrimaryKeys();
                if (strPK.Length == 0)
                {
                    _page.ClientScript.RegisterClientScriptBlock(base.GetType(), "Alert", "<script>alert('请选择网格数据');</script>");
                    return;
                }
                string SL = "";
                string RKSL = "";

                string SCDDMXIDList = string.Empty;
                for (int i = 0; i < _page.GridData.Rows.Count; i++)
                {
                    if (_page.GridRowIsSelected(i))
                    {
                        SL = _page.GetRowDataByKey(i, "SL");
                        RKSL = _page.GetRowDataByKey(i, "RKSL");
                        if (ConvertFunction.ObjToDouble(RKSL) < ConvertFunction.ObjToDouble(SL)){
                            continue;
                        }
                        else { 
                        SCDDMXIDList = SCDDMXIDList + "," + _page.GetRowDataByKey(i, "ID");
                    }
                    }
                } /*end of for*/

                if (SlnString.IsNull(SCDDMXIDList) == true)
                {
                    _page.ClientScript.RegisterClientScriptBlock(base.GetType(), "Alert", "<script>alert('没有符合关闭条件的生产订单');</script>");
                    return;
                }
                SCDDMXIDList = SCDDMXIDList.TrimStart(',');
                string strMsg = SlnDataAccess.ExecuteSQL(TJSCDDGBMXJL(SCDDMXIDList));

                if (SlnString.IsNull(strMsg))
                {
                    strMsg += "添加关闭生产订单明细成功";
                    SlnDataAccess.ExecuteSQL($"update SM_XS_SCDDMX_TB set jhztbh=2,SCDDZT=70 where id in ({SCDDMXIDList})");
                }
                else
                {
                    strMsg += "添加关闭生产订单明细失败";
                }
                /*
                if (SlnString.IsNull(SlnDataAccess.ExecuteSQL($"update SM_XS_SCDDMX_TB t set t.jhztbh=2,t.SCDDZT=70 where t.id in ({SCDDMXIDList})")))
                {
                    strMsg += "->更新生产订单和执行单状态成功";
                }
                else
                {
                    strMsg += "->更新生产订单和执行单失败";
                }*/

                _page.ShowMessage(strMsg);
                _page.btnQuery_Click(null, null);
            }
            catch (Exception ex)
            {
                _page.ShowMessage(ex.Message);
            }
        }
        #endregion

        #region TJSCDDGBMXJL
        private List<string> TJSCDDGBMXJL(string SCDDMXIDList)
        {
            /*以前的都是设置为无效*/
         //   SlnDataAccess.ExecuteSQL($"delete from SM_XS_SCDDGBMX_TB where czlx in (2,4) and  SCDDMXID in ({SCDDMXIDList})");
          //  StringBuilder sb = new StringBuilder();
        //    sb.Append("insert into SM_XS_SCDDGBMX_TB(ID,SCDDMXID,YJHZTBH,YCJZTBH,YSCDDZT,CZLX,GBRID,GBRQ,SFYX,pu_bm,colname)");
            DataTable dt = SlnDataAccess.GetDataTable($"Select ID,JHZTBH,CJZTBH,SCDDZT From SM_XS_SCDDMX_TB  Where ID in ({SCDDMXIDList}) order by ID");
            List<string> lstSql = new List<string>();

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    string sql = @"INSERT INTO SM_XS_SCDDGBMX_TB(ID,SCDDMXID,YJHZTBH,YCJZTBH,YSCDDZT
                                   ,CZLX,GBRQ,GBRID,SFYX,pu_bm,colname)";
                    sql = sql + "VALUES(SEQSM_XS_SCDDGBMX.NEXTVAL";
                    sql = sql + $",'{row["ID"]}','{row["JHZTBH"]}','{row["CJZTBH"]}','{row["SCDDZT"]}'";
                    sql = sql + $",'2',sysdate,'{_page.GetValueByName("sys_userid")}',1,3200,'SCDDZT')";
                    lstSql.Add(sql);

                }
            }
            return lstSql;
/*
                var listQuery = dt.AsEnumerable().Select(m => new
                {
                    SCDDMXID = m.Field<decimal?>("ID"),
                    JHZTBH = m.Field<decimal?>("JHZTBH"),
                    CJZTBH = m.Field<decimal?>("CJZTBH"),
                    SCDDZT = m.Field<decimal?>("SCDDZT")
                }).ToList();

                foreach (var key in listQuery)
                {
                    if (key.Equals(listQuery.First()) == false) { sb.Append(" union all "); }
                    sb.Append(AddSCDDGBMXInfo(key.SCDDMXID, key.JHZTBH, key.CJZTBH, key.SCDDZT));
                }*/
          

            //return sb.ToString();
        }
        #endregion
       /* #region  AddSCDDGBMXInfo
        private string AddSCDDGBMXInfo(object SCDDMXID
                           , object JHZTBH
                           , object CJZTBH
                           , object SCDDZT)
        {
            List<string> aList = new List<string>();
            aList.Add(ConvertFunction.ObjToStr(SCDDMXID));
            aList.Add(ConvertFunction.ObjToStr(JHZTBH));
            aList.Add(ConvertFunction.ObjToStr(CJZTBH));
            aList.Add(ConvertFunction.ObjToStr(SCDDZT));
            aList.Add(ConvertFunction.ObjToStr("2"));
            return "select get_seq('seqSM_XS_SCDDGBMX')," + BusinessLogic.ObjectsToList(aList.ToArray())
               + "," + _page.GetValueByName("sys_userid") + ",sysdate,1,3200,'SCDDZT' from dual";
        }
        #endregion*/
    }
}

 

标签:string,SCDDZT,SCDDMXIDList,sql,XS,SM3200btnGBSCDDMX,page
From: https://www.cnblogs.com/nuaaydh/p/18653496

相关文章