Пример #1
0
        private string GetColKeyTypeFoKey(string bill, string colkey)
        {
            string  sql = @"/*dialect*/ select F_PAEZ_COLTYPE from PAEZ_t_BillLogColSetup where F_PAEZ_BILL='{0}' and F_PAEZ_COLUMNKEY='{1}'";
            DataSet tab = DBServiceHelper.ExecuteDataSet(Context, string.Format(sql, bill, colkey));

            return(tab.Tables[0].Rows[0][0].ToString());
        }
Пример #2
0
        /// <summary>
        /// 获取日志记录设置表表体字段(默认有单据编号字段)
        /// </summary>
        /// <param name="billkey">表标识</param>
        /// <param name="colarr">表体字段数组</param>
        /// <returns>表体字段列值</returns>
        private List <string[]> GetColKeyToArray(string billkey, params string[] colarr)
        {
            string          sql    = @"/*dialect*/ select {0}  bs.F_PAEZ_BILLNOCOL
from PAEZ_t_BillLogColSetup bs
left join PAEZ_BillLogColSetupEntry bse on bse.FID=bs.FID
WHERE BS.F_PAEZ_BILLKEY='{1}'
  AND BS.FDOCUMENTSTATUS='C'";
            string          sqlcol = "";
            DataSet         tab;
            List <string[]> datacol = new List <string[]>();

            if (colarr.Length > 0)
            {
                for (int i = 0; i < colarr.Length; i++)
                {
                    sqlcol += "bse." + colarr[i] + ",";
                    //if (i != colarr.Length - 1)
                    //    sqlcol += ",";
                }
            }
            tab = DBServiceHelper.ExecuteDataSet(Context, string.Format(sql, sqlcol, billkey));
            if (colarr.Length > 0)
            {
                for (int i = 0; i < colarr.Length; i++)
                {
                    datacol.Add(tab.Tables[0].AsEnumerable().Select(d => d.Field <string>(colarr[i])).ToArray());
                }
            }

            datacol.Add(tab.Tables[0].AsEnumerable().Select(d => d.Field <string>("F_PAEZ_BILLNOCOL")).ToArray());
            return(datacol);
        }
Пример #3
0
        public override void EntityRowDoubleClick(EntityRowClickEventArgs e)
        {
            base.EntityRowDoubleClick(e);
            if (!e.Key.Equals(HeadEntityKey, StringComparison.CurrentCultureIgnoreCase))
            {
                return;
            }

            //通过row获取主键

            var headEntry = this.View.GetControl <EntryGrid>(HeadEntityKey);

            var headEntity = this.View.BusinessInfo.GetEntity(HeadEntityKey);
            var selectObj  = this.Model.GetEntityDataObject(headEntity, e.Row);

            if (selectObj == null || !selectObj.DynamicObjectType.Properties.Contains(HeadFidKey))
            {
                return;
            }

            this.Model.DeleteEntryData(DetailEntityKey);
            var headId = selectObj[HeadFidKey].ToString();
            //使用DataTable获取单据体信息
            string strSql    = string.Format(@"
                        SELECT 
                         T2.FNAME AS MATERIAL_NAME,
                         T3.FAMOUNT,
                         T0.FQTY
                         FROM  T_PUR_POORDERENTRY T0
                         INNER JOIN T_BD_MATERIAL T1 ON T0.FMATERIALID = T1.FMATERIALID
                         INNER JOIN T_BD_MATERIAL_L T2 ON T1.FMATERIALID = T2.FMATERIALID AND T2.FLOCALEID=2052
                         INNER JOIN T_PUR_POORDERENTRY_F T3 ON T0.FENTRYID = T3.FENTRYID
                         WHERE T0.FID ={0}", headId);
            var    entryData = DBServiceHelper.ExecuteDataSet(this.View.Context, strSql);

            if (entryData == null || entryData.Tables[0].Rows.Count == 0)
            {
                return;
            }

            for (int i = 0; i < entryData.Tables[0].Rows.Count; i++)
            {
                this.Model.CreateNewEntryRow(DetailEntityKey);
                var dr = entryData.Tables[0].Rows[i];

                var materialName = dr["MATERIAL_NAME"] ?? string.Empty;
                this.Model.SetValue(MaterialKey, materialName, i);

                var amount = dr["FAMOUNT"] ?? 0;
                this.Model.SetValue(AmountKey, amount, i);

                var qty = dr["FQTY"] ?? 0;
                this.Model.SetValue(QtyKey, qty, i);
            }

            this.View.UpdateView(DetailEntityKey);
        }
Пример #4
0
        /// <summary>
        /// 实现IScheduleService的函数,实例化
        /// </summary>
        /// <param name = "ctx" ></ param >
        /// < param name="schedule"></param>
        public void Run(Context ctx, Schedule schedule)
        {
            string  orgSQL = "/*dialect*/SELECT FORGID FROM T_ORG_Organizations";
            DataSet orgds  = DBServiceHelper.ExecuteDataSet(ctx, orgSQL);

            if (orgds != null && orgds.Tables.Count > 0 && orgds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in orgds.Tables[0].Rows)
                {
                    string Id = Convert.ToString(row[0]);
                    for (int i = 1; i < 51; i++)
                    {
                        //流延
                        //string zttemTableName = "Z_SZXY_BGJ_XYLYList" + Id + i.ToString();
                        string ttemTableName = "Z_SZXY_BGJ_XYLYList" + Id + i.ToString();
                        updateSQL(ctx, ttemTableName);
                        //fuhe
                        //zttemTableName = "Z_SZXY_BGJ_XYFHList" + Id + i.ToString();
                        ttemTableName = "Z_SZXY_BGJ_XYFHList" + Id + i.ToString();
                        updateSQL(ctx, ttemTableName);
                        //lashen
                        //zttemTableName = "Z_SZXY_BGJ_XYLSList" + Id + i.ToString();
                        ttemTableName = "Z_SZXY_BGJ_XYLSList" + Id + i.ToString();
                        updateSQL(ctx, ttemTableName);
                        //fenceng
                        //zttemTableName = "Z_SZXY_BGJ_XYFCList" + Id + i.ToString();
                        ttemTableName = "Z_SZXY_BGJ_XYFCList" + Id + i.ToString();
                        updateSQL(ctx, ttemTableName);
                        // fenceng
                        //zttemTableName = "Z_SZXY_BGJ_XYFQList" + Id + i.ToString();
                        ttemTableName = "Z_SZXY_BGJ_XYFQList" + Id + i.ToString();
                        updateSQL(ctx, ttemTableName);
                        // SHIFA
                        //zttemTableName = "Z_SZXY_BGJ_XYSFList" + Id + i.ToString();
                        ttemTableName = "Z_SZXY_BGJ_XYSFList" + Id + i.ToString();
                        updateSQL(ctx, ttemTableName);
                        // JIANGLIAO
                        //zttemTableName = "Z_SZXY_BGJ_XYSFList" + Id + i.ToString();
                        ttemTableName = "Z_SZXY_BGJ_XYJLList" + Id + i.ToString();
                        updateSQL(ctx, ttemTableName);
                        // TUFU
                        //zttemTableName = "Z_SZXY_BGJ_XYTFList" + Id + i.ToString();
                        ttemTableName = "Z_SZXY_BGJ_XYTFList" + Id + i.ToString();
                        updateSQL(ctx, ttemTableName);
                        // BAOZHUANG
                        //zttemTableName = "Z_SZXY_BGJ_XYTFList" + Id + i.ToString();
                        ttemTableName = "Z_SZXY_BGJ_XYBZList" + Id + i.ToString();
                        updateSQL(ctx, ttemTableName);
                    }
                }
            }
        }
Пример #5
0
        /// <summary>
        /// 获取字段名
        /// </summary>
        /// <param name="billName"></param>
        /// <param name="billKey"></param>
        /// <param name="colKey">字段标识</param>
        /// <returns></returns>
        private string GetColumnName(string billName, string billKey, string colKey)
        {
            string  sql = @"/*dialect*/   select BSE.F_PAEZ_COLUMN
  from PAEZ_t_BillLogColSetup bs
  left join PAEZ_BillLogColSetupEntry bse on bse.FID=bs.FID
  WHERE BS.F_PAEZ_BILLNAME='{0}' 
  AND BS.F_PAEZ_BILLKEY='{1}'
  AND BSE.F_PAEZ_COLUMNKEY='{2}'
  AND BS.FDOCUMENTSTATUS='C'";
            DataSet tab = DBServiceHelper.ExecuteDataSet(Context, string.Format(sql, billName, billKey, colKey));

            return(tab.Tables[0].Rows[0][0].ToString());
        }
Пример #6
0
        /// <summary>
        /// 判断是否是记录字段,并返回字段类型
        /// </summary>
        /// <param name="colName">字段名</param>
        /// <param name="billNAme">表单名</param>
        /// <param name="colType">字段类型</param>
        /// <param name="tabName">表名</param>
        /// <returns></returns>
        private bool IsKeyColumn(string colName, string billNAme, out string colType, out string tabName)
        {
            string  sql = @"/*dialect*/ select F_PAEZ_COLTYPE,F_PAEZ_TABLENAME from PAEZ_t_BillLogColSetup where F_PAEZ_BILL='{0}' and F_PAEZ_COLUMN='{1}'";
            DataSet tab = DBServiceHelper.ExecuteDataSet(this.Context, string.Format(sql, billNAme, colName));

            colType = tab.Tables[0].Rows.Count == 0 ? "" : tab.Tables[0].Rows[0][0] + "";
            tabName = tab.Tables[0].Rows.Count == 0 ? "" : tab.Tables[0].Rows[0][1] + "";
            if (colType != "" && tabName != "")
            {
                return(true);
            }
            return(false);
        }
        public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
        {
            base.AfterExecuteOperationTransaction(e);
            var sql = "SELECT EntryID,MaterialID,MateriNumber,MaterialName,SupplierID,SupplierName,Price,Bitmap FROM dbo.SY_V_PRICELIST";

            using (DataSet ds = DBServiceHelper.ExecuteDataSet(Context, sql))
            {
                var table = ds.Tables[0];
                table.TableName = "JPTPrice";
                TableSender sender = new TableSender(table);
                sender.TransportData();
            }
        }
 public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
 {
     base.AfterExecuteOperationTransaction(e);
     foreach (var dataEntity in e.DataEntitys)
     {
         var a   = Convert.ToString(dataEntity["ID"]);
         var sql = $"SELECT F_SY_PLEntryID AS EntryID,F_SY_MATERIAL AS CloudMatID,sup.FNAME AS [CloudSupplierName],de.F_SY_RAmount AS [Price] ,F_SY_SUPPLIER as SupplierID FROM SY_T_KeyRFQDetail de LEFT JOIN dbo.T_BD_SUPPLIER_L sup ON de.F_SY_SUPPLIER=sup.FSUPPLIERID WHERE FID ={a}";
         using (DataSet ds = DBServiceHelper.ExecuteDataSet(Context, sql))
         {
             var table = ds.Tables[0];
             table.TableName = "JPTPlan";
             TableSender sender = new TableSender(table);
             sender.TransportData();
         }
     }
 }
Пример #9
0
        /// <summary>
        /// 根据表单、字段名返回字段类型
        /// </summary>
        /// <param name="billname">表单名</param>
        /// <param name="billkey">表单标识</param>
        /// <param name="colkey">字段标识</param>
        /// <param name="colname">字段名</param>
        /// <returns></returns>
        private string GetColKeyTypeFoCol(string billname, string billkey, string colkey, string colname = "")
        {
            string sql = @"/*dialect*/ select F_PAEZ_COLTYPEITEM from PAEZ_t_BillLogColSetup BS
left join PAEZ_BillLogColSetupEntry BSE on bse.FID=bs.FID
WHERE BS.F_PAEZ_BILLNAME='{0}' 
AND BS.F_PAEZ_BILLKEY='{1}'
/*AND BSE.BSE.F_PAEZ_COLUMN=''*/
AND BSE.F_PAEZ_COLUMNKEY='{2}'
AND BS.FDOCUMENTSTATUS='C'";

            string  sql2 = @"/*dialect*/ select F_PAEZ_COLTYPEITEM from PAEZ_t_BillLogColSetup BS
left join PAEZ_BillLogColSetupEntry BSE on bse.FID=bs.FID
WHERE BS.F_PAEZ_BILLNAME='{0}' 
AND BS.F_PAEZ_BILLKEY='{1}'
/*AND BSE.BSE.F_PAEZ_COLUMN=''*/
AND BSE.F_PAEZ_ENTITYPROPERTIES='{2}'
AND BS.FDOCUMENTSTATUS='C'";
            DataSet tab  = DBServiceHelper.ExecuteDataSet(Context, string.Format(sql2, billname, billkey, colkey));

            return(tab.Tables[0].Rows[0][0].ToString());
        }
Пример #10
0
        private void updateSQL(Context ctx, string ttemTableName)
        {
            DataSet ds  = null;
            string  SQL = "";

            SQL = "/*dialect*/SELECT 1 FROM SYSOBJECTS WHERE NAME ='" + ttemTableName + "'";
            ds  = DBServiceHelper.ExecuteDataSet(ctx, SQL);
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                SQL = "/*dialect*/DROP TABLE  " + ttemTableName + "";
                DBServiceHelper.Execute(ctx, SQL);
                SQL = "/*dialect*/CREATE TABLE " + ttemTableName + "(Id BIGINT IDENTITY(1,1) NOT NULL, Column1 INT NOT NULL)";
                DBServiceHelper.Execute(ctx, SQL);
            }
            else
            {
                SQL = "/*dialect*/CREATE TABLE " + ttemTableName + "(Id BIGINT IDENTITY(1,1) NOT NULL, Column1 INT NOT NULL)";
                DBServiceHelper.Execute(ctx, SQL);
            }
            //DoSQL(ztemTableName, zttemTableName, temTableName, ttemTableName);
        }
 public override void EndOperationTransaction(EndOperationTransactionArgs e)
 {
     try
     {
         string sql = string.Empty;
         if (e.DataEntitys != null && e.DataEntitys.Count <DynamicObject>() > 0)
         {
             foreach (DynamicObject item in e.DataEntitys)
             {
                 //收款单id
                 string Fid = item["Id"].ToString();
                 sql = string.Format(@"select FORDERBILLNO,FORDERENTRYID,b.FREALRECAMOUNT from T_AR_RECEIVEBILL a 
                                       inner join T_AR_RECEIVEBILLSRCENTRY b  on a.FID=b.fid 
                                       where a.FID='{0}'", Fid);
                 DataSet   ds = DBServiceHelper.ExecuteDataSet(this.Context, sql);
                 DataTable dt = ds.Tables[0];
                 if (dt.Rows.Count > 0)
                 {
                     string upsql = "";
                     for (int i = 0; i < dt.Rows.Count; i++)
                     {
                         //订单明细内码
                         string FORDERENTRYID = dt.Rows[i]["FORDERENTRYID"].ToString();
                         //本次收款金额
                         decimal FREALRECAMOUNT = Convert.ToDecimal(dt.Rows[i]["FREALRECAMOUNT"].ToString());
                         upsql += string.Format(@"/*dialect*/ update T_SAL_ORDERENTRY set FREALRECAMOUNT=FREALRECAMOUNT-{0} where FENTRYID={1}", FREALRECAMOUNT, FORDERENTRYID);
                     }
                     //更新销售订单
                     DBServiceHelper.Execute(Context, upsql);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw new KDException("", "反审核失败:" + ex.ToString());
     }
 }
Пример #12
0
        /// <summary>
        /// 返回记录字段标识数组集合
        /// </summary>
        /// <param name="billname">表单名</param>
        /// <param name="billkey">表单标识</param>
        /// <returns></returns>
        private string[] GetColKey(string billname, string billkey)
        {
            string  sql  = @"/*dialect*/ select BSE.F_PAEZ_COLUMNKEY 
from PAEZ_t_BillLogColSetup bs
left join PAEZ_BillLogColSetupEntry bse on bse.FID=bs.FID
WHERE BS.F_PAEZ_BILLNAME='{0}' 
AND BS.F_PAEZ_BILLKEY='{1}'
AND BS.FDOCUMENTSTATUS='C' ";
            string  sql2 = @"/*dialect*/ select BSE.F_PAEZ_ENTITYPROPERTIES 
from PAEZ_t_BillLogColSetup bs
left join PAEZ_BillLogColSetupEntry bse on bse.FID=bs.FID
WHERE BS.F_PAEZ_BILLNAME='{0}' 
AND BS.F_PAEZ_BILLKEY='{1}'
AND BS.FDOCUMENTSTATUS='C' ";
            DataSet tab  = DBServiceHelper.ExecuteDataSet(Context, string.Format(sql2, billname, billkey));

            //tab.Tables
            string[] colist = new string[tab.Tables[0].Rows.Count];
            for (int i = 0; i < colist.Length; i++)
            {
                colist[i] = tab.Tables[0].Rows[i][0] + "";
            }
            return(colist);
        }
        public override void AfterBarItemClick(AfterBarItemClickEventArgs e)
        {
            base.AfterBarItemClick(e);

            //客户回签签单打印  传Fid ,不需要自动打印,加一个按钮打印
            //补打标签

            if (e.BarItemKey.EqualsIgnoreCase("SZXY_tbGridPrintNoBD"))
            {
                this.Model.DataObject["FFormId"] = this.View.BusinessInfo.GetForm().Id;
                Utils.Save(View, new DynamicObject[] { this.Model.DataObject }, Kingdee.BOS.Orm.OperateOption.Create(), Context);

                string F_SZXY_ForLabel = Convert.ToString(this.Model.GetValue("F_SZXY_ForLabel"));//输入的补打标签

                DynamicObject OrgObj = this.Model.GetValue("F_SZXY_OrgId") as DynamicObject;

                if (OrgObj != null && !F_SZXY_ForLabel.IsNullOrEmptyOrWhiteSpace())
                {
                    long orgid = Convert.ToInt64(OrgObj["Id"]);

                    //如果输入的是分切条码号
                    string SelSql = $" /*dialect*/select T1.F_SZXY_CBNO1,T1.F_SZXY_CUST,T4.FNAME   " +
                                    $" from  SZXY_t_KHHQDEntry T1  " +
                                    $"left join SZXY_t_KHHQD T2  on t1.fid=T2.fid   " +
                                    $"left join T_BD_MATERIAL T3   on T3.FMATERIALID = T1.F_SZXY_MATERIAL  " +
                                    $"left join T_BD_MATERIAL_L T4 on t3.FMATERIALID = T4.FMATERIALID " +
                                    $"where  T1.F_SZXY_CBNO1='{F_SZXY_ForLabel}' ";
                    DataSet SelSqlds = DBServiceHelper.ExecuteDataSet(this.Context, SelSql);


                    //如果输入的是生产订单号加行号
                    string SelSql1 = $"/*dialect*/select " +
                                     $"T1.F_SZXY_CBNO1 ,T1.F_SZXY_CUST,T4.FNAME    " +
                                     $" from  SZXY_t_KHHQDEntry T1 " +
                                     $"left join SZXY_t_KHHQD T2  on t1.fid=T2.fid " +
                                     $"left join T_BD_MATERIAL T3   on T3.FMATERIALID = T1.F_SZXY_MATERIAL  " +
                                     $"left join T_BD_MATERIAL_L T4 on t3.FMATERIALID = T4.FMATERIALID  " +
                                     $" where  T1.F_SZXY_MONOE+CAST(T1.F_SZXY_MOLINENOE as varchar(50))='{F_SZXY_ForLabel}' " +

                                     $" group by T1.F_SZXY_CBNO1 ,F_SZXY_CUST,T4.FNAME ";

                    DataSet SelSqlds1 = DBServiceHelper.ExecuteDataSet(this.Context, SelSql1);


                    string InType = "";

                    if (SelSqlds.Tables[0].Rows.Count > 0)
                    {
                        InType = "BarNo";
                        Logger.Debug("输入的是条码号", SelSql);
                    }
                    if (SelSqlds1.Tables[0].Rows.Count > 0)
                    {
                        InType = "BillNo";
                        Logger.Debug("输入的是生产订单号", SelSql1);
                    }
                    if (InType == "")
                    {
                        this.View.ShowWarnningMessage("没有匹配到信息,请输入条码号或者生产订单号+行号!"); return;
                    }

                    //是否指定标签模板
                    string PJSQL = " ";

                    //DynamicObject PrintTemp = this.Model.GetValue("F_SZXY_LabelPrint") as DynamicObject;

                    //if (PrintTemp != null)
                    //{
                    //    string PId = Convert.ToString(PrintTemp["Id"]);

                    //    if (!PId.IsNullOrEmptyOrWhiteSpace())
                    //    {
                    //        PJSQL = $" and T1.Fid={PId} ";
                    //    }
                    //}
                    string MacInfo = Utils.GetMacAddress();
                    Logger.Debug("当前MAC地址", MacInfo);

                    #region

                    //条码号
                    orgid = Convert.ToInt64(OrgObj["Id"]);

                    StringBuilder STR          = new StringBuilder();
                    DataSet       PrintModelDS = null;
                    int           ckb          = 0;
                    if (InType == "BarNo" && SelSqlds.Tables[0].Rows.Count > 0 && !F_SZXY_ForLabel.IsNullOrEmptyOrWhiteSpace() && orgid != 0)
                    {
                        for (int i = 0; i < SelSqlds.Tables[0].Rows.Count; i++)
                        {
                            string F_SZXY_CUSTID = Convert.ToString(SelSqlds.Tables[0].Rows[i]["F_SZXY_CUST"]);
                            string FNAME         = Convert.ToString(SelSqlds.Tables[0].Rows[i]["FNAME"]);

                            if (!MacInfo.IsNullOrEmptyOrWhiteSpace())
                            {
                                if (i == 0)
                                {
                                    PrintModelDS = XYStraddleCut.getPrintModel(this.View, Context, PJSQL, orgid.ToString(), MacInfo, F_SZXY_CUSTID, FNAME, F_SZXY_ForLabel, "BarNo", ref ckb);
                                }
                                STR.Append($"'{F_SZXY_ForLabel}',");
                            }
                        }

                        if (STR.ToString() != "" && !STR.ToString().IsNullOrEmptyOrWhiteSpace())
                        {
                            string BarNoStr = STR.ToString();
                            BarNoStr = BarNoStr.Substring(0, BarNoStr.Length - 1);
                            if (PrintModelDS != null)
                            {
                                XYStraddleCut.Print(PrintModelDS, ckb, Context, this.View, BarNoStr, "BarNo");
                            }
                        }
                    }

                    //生产订单号+行号
                    if (InType == "BillNo" && SelSqlds1.Tables[0].Rows.Count > 0 && !F_SZXY_ForLabel.IsNullOrEmptyOrWhiteSpace() && orgid > 0)
                    {
                        if (SelSqlds1 != null && SelSqlds1.Tables.Count > 0 && SelSqlds1.Tables[0].Rows.Count > 0)
                        {
                            int j = 0;
                            for (int i = 0; i < SelSqlds1.Tables[0].Rows.Count; i++)
                            {
                                string F_SZXY_CUSTID   = Convert.ToString(SelSqlds1.Tables[0].Rows[i]["F_SZXY_CUST"]);
                                string FNAME           = Convert.ToString(SelSqlds1.Tables[0].Rows[i]["FNAME"]);
                                string F_SZXY_BARCODEE = Convert.ToString(SelSqlds1.Tables[0].Rows[i]["F_SZXY_CBNO1"]);

                                if (!MacInfo.IsNullOrEmptyOrWhiteSpace() && !F_SZXY_BARCODEE.IsNullOrEmptyOrWhiteSpace() && F_SZXY_BARCODEE != "")
                                {
                                    if (j == 0)
                                    {
                                        j++;
                                        PrintModelDS = XYStraddleCut.getPrintModel(this.View, Context, PJSQL, orgid.ToString(), MacInfo, F_SZXY_CUSTID, FNAME, F_SZXY_BARCODEE, "BillNo", ref ckb);
                                    }
                                    STR.Append($"'{F_SZXY_BARCODEE}',");
                                }
                            }

                            if (STR.ToString() != "")
                            {
                                string BarNoStr = STR.ToString();
                                BarNoStr = BarNoStr.Substring(0, BarNoStr.Length - 1);

                                if (PrintModelDS != null)
                                {
                                    XYStraddleCut.Print(PrintModelDS, ckb, Context, this.View, $"'{F_SZXY_ForLabel}'", "BillNo");
                                }
                            }
                        }
                        Logger.Debug($"箱号匹配到:{SelSqlds.Tables[0].Rows.Count}条数据", $" 生产订单号+行号匹配到:{SelSqlds1.Tables[0].Rows.Count}条数据");

                        #endregion
                    }
                }
            }
        }
Пример #14
0
        private void SetValue(DataSet LsDSA, string LsNo)
        {
            string F_SZXY_SeqH = Convert.ToString(this.Model.GetValue("F_SZXY_SeqH"));//层序
            string cx1         = "";
            string cx2         = "";

            if (this.Model.GetValue("F_SZXY_OrgId") is DynamicObject orgobj)
            {
                cx1 = $"1-{F_SZXY_SeqH}";
                cx2 = $"{Convert.ToInt32(F_SZXY_SeqH) + 1}-{  Convert.ToString(LsDSA.Tables[0].Rows[0]["层数"])}";

                bool IsRenZ = false;
                int  RZQTY  = 0;
                if (LsDSA != null && LsDSA.Tables.Count > 0 && LsDSA.Tables[0].Rows.Count > 0)
                {
                    int m = this.Model.GetEntryRowCount("F_SZXY_DFDEntity");
                    for (int i = 0; i < LsDSA.Tables[0].Rows.Count; i++)
                    {
                        int index = m + i;
                        if (i == 0)
                        {
                            //给单据头赋值
                            if (!Convert.ToString(LsDSA.Tables[0].Rows[i]["生产订单内码"]).IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_MOID", Convert.ToInt64(LsDSA.Tables[0].Rows[i]["生产订单内码"]));
                            }
                            this.Model.SetValue("F_SZXY_PTNoH", LsDSA.Tables[0].Rows[i]["生产任务单号"].ToString());
                            this.Model.SetValue("F_SZXY_POLineNum", LsDSA.Tables[0].Rows[i]["生产订单行号"].ToString());
                            if (!Convert.ToString(LsDSA.Tables[0].Rows[i]["特殊标志"]).IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_SpecialMarkH", Convert.ToString(LsDSA.Tables[0].Rows[i]["特殊标志"]));
                            }
                            if (!Convert.ToString(LsDSA.Tables[0].Rows[i]["班组"]).IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_TeamGroup", Convert.ToInt64(LsDSA.Tables[0].Rows[i]["班组"]));
                            }
                            if (!Convert.ToString(LsDSA.Tables[0].Rows[i]["班次"]).IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_Classes", Convert.ToInt64(LsDSA.Tables[0].Rows[i]["班次"]));
                            }
                            if (!Convert.ToString(LsDSA.Tables[0].Rows[i]["配方"]).IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_FormulaH", Convert.ToString(LsDSA.Tables[0].Rows[i]["配方"]));
                            }
                            if (!Convert.ToString(LsDSA.Tables[0].Rows[i]["产品型号"]).IsNullOrEmptyOrWhiteSpace())
                            {
                                string RMat = Utils.GetRootMatId(Convert.ToString(LsDSA.Tables[0].Rows[i]["产品型号"]), orgobj["Id"].ToString(), Context);
                                this.Model.SetValue("F_SZXY_MaterialID1", RMat);
                                if (this.Model.GetValue("F_SZXY_MaterialID1") is DynamicObject MatDo)
                                {
                                    if (!Convert.ToString(MatDo["F_SZXY_renzenQTY"]).IsNullOrEmptyOrWhiteSpace())
                                    {
                                        IsRenZ = true;
                                        RZQTY  = Convert.ToInt32(MatDo["F_SZXY_renzenQTY"]);
                                    }
                                }
                            }
                            if (!Convert.ToString(LsDSA.Tables[0].Rows[i]["流延机"]).IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_plasticMac", Convert.ToString(LsDSA.Tables[0].Rows[i]["流延机"]));
                            }
                            this.Model.SetValue("F_SZXY_AreaH", Convert.ToDecimal(LsDSA.Tables[0].Rows[i]["面积"]));
                            if (!Convert.ToString(LsDSA.Tables[0].Rows[i]["车间"]).IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_CJ", Convert.ToInt64(LsDSA.Tables[0].Rows[i]["车间"]));
                            }

                            DynamicObject FCreatorIdobj = this.Model.GetValue("FCreatorId") as DynamicObject;
                            if (!Convert.ToString(FCreatorIdobj["Id"]).IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_Recorder_Id", Convert.ToString(FCreatorIdobj["Id"]));
                            }
                            if (!Convert.ToString(LsDSA.Tables[0].Rows[i]["层数"]).IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_Layer", Convert.ToString(LsDSA.Tables[0].Rows[i]["层数"]));
                            }
                            DynamicObject billobj = this.Model.DataObject;
                        }
                        //单据体赋值
                        this.Model.CreateNewEntryRow("F_SZXY_DFDEntity");
                        this.Model.SetValue("F_SZXY_StretchNO", LsNo, index);
                        this.Model.SetValue("F_SZXY_bipartitionWidth", Convert.ToDecimal(LsDSA.Tables[0].Rows[i]["宽度"]), index);
                        this.Model.SetValue("F_SZXY_bipartitionLen", Convert.ToDecimal(LsDSA.Tables[0].Rows[i]["长度"]), index);
                        this.Model.SetValue("F_SZXY_bipartitionArea", Convert.ToDecimal(LsDSA.Tables[0].Rows[i]["汇总面积"]), index);
                        this.Model.SetValue("F_SZXY_bipartition", Convert.ToString(LsDSA.Tables[0].Rows[i]["对分层数"]), index);
                        this.Model.SetValue("F_SZXY_StretchC", cx1, index);
                        string DFNo = "";//拉伸编号+拉伸层次
                        if (cx1 != "" && i == 0)
                        {
                            this.Model.SetValue("F_SZXY_StretchC", cx1, index);
                            //this.Model.SetValue("F_SZXY_bipartition", Convert.ToInt32(this.Model.GetValue("F_SZXY_SeqH")));
                            DFNo = $"{LsNo}{cx1}";

                            this.Model.SetValue("F_SZXY_bipartitionNO", DFNo, index);
                        }
                        if (cx2 != "" && i == 1)
                        {
                            this.Model.SetValue("F_SZXY_StretchC", cx2, index);
                            //this.Model.SetValue("F_SZXY_bipartition", Convert.ToInt32(this.Model.GetValue("F_SZXY_SeqH")));
                            DFNo = $"{LsNo}{cx2}";
                            this.Model.SetValue("F_SZXY_bipartitionNO", DFNo, index);

                            if (RZQTY > 0 && IsRenZ && BFTYPE.EqualsIgnoreCase("单层"))
                            {
                                string b1 = "";
                                string b2 = "";
                                //string LsNo = Convert.ToString(billobj["F_SZXY_ProductNo"]);
                                string  Before = Convert.ToString(Convert.ToInt32(ASEQ.ToString()) + 1);
                                string  selsql = $"select F_SZXY_RollNo from SZXY_t_XYLSEntry where F_SZXY_STRETCHNO='{LsNo}' and FSeq={Before} ";
                                DataSet Ds1    = DBServiceHelper.ExecuteDataSet(Context, selsql);
                                if (Ds1 != null && Ds1.Tables.Count > 0 && Ds1.Tables[0].Rows.Count > 0)
                                {
                                    b1 = Convert.ToString(Ds1.Tables[0].Rows[0]["F_SZXY_RollNo"]);
                                }
                                string  selsql1 = $"select top 1 F_SZXY_RollNo from SZXY_t_XYLSEntry where F_SZXY_STRETCHNO='{LsNo}' order by FSeq Desc";
                                DataSet Ds11    = DBServiceHelper.ExecuteDataSet(Context, selsql1);
                                if (Ds11 != null && Ds11.Tables.Count > 0 && Ds11.Tables[0].Rows.Count > 0)
                                {
                                    b2 = Convert.ToString(Ds11.Tables[0].Rows[0]["F_SZXY_RollNo"]);
                                    // b2 = String.Format("{0:D2}", Convert.ToInt32( b2));
                                }
                                cx2  = $"{b1}-{b2}";
                                DFNo = $"{LsNo}{cx2}";
                                this.Model.SetValue("F_SZXY_StretchC", cx2, index);
                            }
                            this.Model.SetValue("F_SZXY_bipartitionNO", DFNo, index);
                        }
                    }
                    //调用保存
                    //
                    string UpdateStateSql = string.Format("/*dialect*/update SZXY_t_XYLS set  F_SZXY_CirculationState1={0}   where F_SZXY_RecNo='{1}' ", 1, LsNo);
                    int    res            = DBServiceHelper.Execute(Context, UpdateStateSql);


                    View.Model.DataObject["FFormId"] = this.View.BusinessInfo.GetForm().Id;
                    Utils.Save(View, new DynamicObject[] { View.Model.DataObject }, Kingdee.BOS.Orm.OperateOption.Create(), Context);
                    this.View.UpdateView();
                }
                else
                {
                    this.View.ShowMessage("此编号没有匹配到数据!");
                }
                //if (LsDSB != null && LsDSB.Tables.Count > 0 && LsDSB.Tables[0].Rows.Count > 0)
                //{
                //    int m = this.Model.GetEntryRowCount("F_SZXY_DFDEntity");
                //    for (int i = 0; i < LsDSB.Tables[0].Rows.Count; i++)
                //    {
                //        int index = m + i;
                //        if (i == 0)
                //        //单据体赋值
                //        this.Model.CreateNewEntryRow("F_SZXY_DFDEntity");
                //        this.Model.SetValue("F_SZXY_StretchNO", LsNo, index);
                //        this.Model.SetValue("F_SZXY_bipartitionWidth", Convert.ToDecimal(LsDSB.Tables[0].Rows[i]["宽度"]), index);
                //        this.Model.SetValue("F_SZXY_bipartitionLen", Convert.ToDecimal(LsDSB.Tables[0].Rows[i]["长度"]), index);
                //        this.Model.SetValue("F_SZXY_bipartitionArea", Convert.ToDecimal(LsDSB.Tables[0].Rows[i]["汇总面积"]), index);
                //       // this.Model.SetValue("F_SZXY_bipartition", Convert.ToString(LsDSB.Tables[0].Rows[i]["对分层数"]), index);
                //        this.Model.SetValue("F_SZXY_StretchC", cx2, index);
                //        string DFNo = "";//拉伸编号+拉伸层次
                //        if (cx2!= "")
                //        {
                //            string[] strArr = cx2.Split('-');
                //            int A = Convert.ToInt32(strArr[0]);
                //            int B = Convert.ToInt32(strArr[1]);
                //            this.Model.SetValue("F_SZXY_bipartition", Convert.ToInt32(this.Model.GetValue("F_SZXY_SeqH")) - B);
                //            DFNo = $"{LsNo}{cx2}";
                //        }

                //        this.Model.SetValue("F_SZXY_bipartitionNO", DFNo, index);

                //    }

                //}
            }
        }
        public override void DataChanged(DataChangedEventArgs e)
        {
            base.DataChanged(e);
            int           m = e.Row; string SelSQL = "";
            DynamicObject billobj = this.Model.DataObject;
            string        InNO    = Convert.ToString(this.Model.GetValue("F_SZXY_HCNO")); //获取输入的重检箱号

            string FQNo = Convert.ToString(this.Model.GetValue("F_SZXY_BarCode", m));     //获取输入分切编号


            if (e.Field.Key.EqualsIgnoreCase("F_SZXY_HCNO"))
            {
                if (InNO.IsNullOrEmptyOrWhiteSpace())
                {
                    return;
                }

                if (!InNO.IsNullOrEmptyOrWhiteSpace() && billobj["F_SZXY_OrgId"] is DynamicObject orgobj)
                {
                    string orgid = Convert.ToString(orgobj["Id"]);
                    if (InNO.Length <= 2)
                    {
                        this.View.ShowWarnningMessage("请检查输入的编号是否有误!"); return;
                    }

                    SelSQL = "/*dialect*/" +
                             "select T1.F_SZXY_NO '分切编号'," +
                             "T1.F_SZXY_Team '班组'," +
                             "T1.F_SZXY_Class '班次'," +
                             "T1.F_SZXY_station '工位'," +
                             "T1.F_SZXY_SpecialMark '特殊标志'," +
                             "T1.F_SZXY_XNDJ '性能等级'," +
                             "T1.F_SZXY_Material '产品型号'," +
                             "T1.F_SZXY_PLy '厚度'," +
                             "T1.F_SZXY_Width '宽度'," +
                             "T1.F_SZXY_Len '长度'," +
                             "T1.F_SZXY_Area '面积'," +
                             "T2.F_SZXY_Machine '分切机'," +
                             "T2.F_SZXY_CASTMAC '流延机'," +
                             "T2.F_SZXY_LayerNo '产品编号' " +
                             "from SZXY_t_XYDCJXXBEntry T1 " +
                             "left join SZXY_t_XYDCJXXB T3 on T1.fid=T3.FID " +
                             "left join SZXY_t_XYFQEntry T2 on T1.F_SZXY_NO=T2.F_SZXY_BARCODEE  " +
                             "left join SZXY_t_XYFQ T4 on T2.fid=T4.FID " +
                             $"where T1.F_SZXY_BOXNOE='{InNO}' " +
                             $"and T3.F_SZXY_ORGID= {orgid}";

                    DataSet fillData = DBServiceHelper.ExecuteDataSet(this.Context, SelSQL);
                    SetBillValue(Context, fillData, this.View, e.Row, orgobj, "XH");
                }
            }

            // 外观检验存在修改等级时,通过新单据体扫码分切编号,输入新等级,点击【确认修改等级】,系统实现自动刷新XY成品重检单上等级字段
            if (e.Field.Key.EqualsIgnoreCase("F_SZXY_BarCode"))
            {
                if (FQNo.IsNullOrEmptyOrWhiteSpace())
                {
                    return;
                }

                if (!FQNo.IsNullOrEmptyOrWhiteSpace() && billobj["F_SZXY_OrgId"] is DynamicObject orgobj)
                {
                    // 检查是否存在此条码
                    string NoKey    = "F_SZXY_BarCode";
                    string Entry    = "SZXY_XYCPJYEntry";
                    string entrykey = "F_SZXY_XYCPJYEntity";
                    XYComposite.CheckNoIsCur(this.View, this.Model.DataObject, FQNo, Entry, NoKey, e.Row, entrykey, "RCK", Context);
                    string orgid = Convert.ToString(orgobj["Id"]);
                    if (FQNo.Length <= 2)
                    {
                        this.View.ShowWarnningMessage("请检查输入的编号是否有误!"); return;
                    }

                    SelSQL = "/*dialect*/" +
                             "select T1.F_SZXY_BARCODEE '分切编号', " +
                             "T1.F_SZXY_TEAMGROUP1 '班组'," +
                             "T1.F_SZXY_CLASSES1 '班次'," +
                             "T1.F_SZXY_STATION '工位'," +
                             "T1.F_SZXY_SPECIALMARK '特殊标志'," +
                             "T1.F_SZXY_BLEVEL '性能等级'," +
                             "T1.F_SZXY_MATERIAL '产品型号'," +
                             "T1.F_SZXY_PLy '厚度'," +
                             "T1.F_SZXY_Width '宽度'," +
                             "T1.F_SZXY_Len '长度'," +
                             "T1.F_SZXY_Area '面积'," +
                             "T1.F_SZXY_Machine '分切机'," +
                             "T1.F_SZXY_CASTMAC '流延机'," +
                             "T1.F_SZXY_LayerNo '产品编号' " +
                                                             //"from SZXY_t_XYDCJXXBEntry T1 " +
                                                             //"left join SZXY_t_XYDCJXXB T3 on T1.fid=T3.FID " +
                             " from SZXY_t_XYFQEntry T1  " + //on T1.F_SZXY_NO=T2.F_SZXY_BARCODEE  " +
                             "left join SZXY_t_XYFQ T4 on T1.fid=T4.FID " +
                             $"where T1.F_SZXY_BARCODEE='{FQNo}' " +
                             $"and T4.F_SZXY_OrgId1= {orgid}";

                    DataSet fillData = DBServiceHelper.ExecuteDataSet(this.Context, SelSQL);
                    SetBillValue(Context, fillData, this.View, e.Row, orgobj, "XH");
                }
            }
        }
        public static void Print(DataSet ds, int v, Context Context, IBillView View, string XH)
        {
            #region
            if (v == 0)
            {
                List <dynamic> listData = new List <dynamic>();
                listData.Clear();
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string FListSQL = Convert.ToString(ds.Tables[0].Rows[0]["F_SZXY_ListSQL"]);
                    foreach (DataRow Row in ds.Tables[0].Rows)
                    {
                        // Kingdee.BOS.Log.Logger.Debug("QuerySQL", $"/*Dialect*/{Convert.ToString(Row[6])} {View.Model.GetPKValue()}");
                        if (Convert.ToString(Row[1]).IsNullOrEmptyOrWhiteSpace())
                        {
                            View.ShowMessage("当前用户没有设置grf打印模板,请检查!");
                        }
                        if (Convert.ToString(Row[2]).IsNullOrEmptyOrWhiteSpace())
                        {
                            View.ShowMessage("当前用户没有设置grf打印地址,请检查!");
                        }
                        var ReportModel = new
                        {
                            FID          = Convert.ToString(Row[0]),
                            report       = Convert.ToString(Row[1]),
                            PrintAddress = Convert.ToString(Row[2]),
                            PrintQty     = Convert.ToString(Row[3]),
                            //Label = Convert.ToString(Row[4]),
                            ConnString = Convert.ToString(Row[5]),
                            QuerySQL   = $"{Convert.ToString(Row[6])}F_SZXY_CBNO1='{XH}' {FListSQL}"
                        };
                        listData.Add(ReportModel);
                    }
                }
                string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(listData);
                //调用打印
                string  SQL = "/*dialect*/select F_SZXY_EXTERNALCONADS from SZXY_t_ClientExtern ";
                DataSet ids = DBServiceHelper.ExecuteDataSet(Context, SQL);
                if (ids != null && ids.Tables.Count > 0 && ids.Tables[0].Rows.Count > 0)
                {
                    string linkUrl = Convert.ToString(ids.Tables[0].Rows[0][0]).Replace("\\", "\\\\");// @"C:\Users\Administrator\Desktop\Grid++Report 6old\Grid++Report 6\Samples\CSharp\8.PrintInForm\bin\Debug\PrintReport.exe";

                    if (!strJson.IsNullOrEmptyOrWhiteSpace())
                    {
                        View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Print " + strJson);
                    }

                    else
                    {
                        View.ShowMessage("当前用户没有设置Grid++Report打印外接程序地址,请检查!");
                    }
                }
                View.SendDynamicFormAction(View);
            }
            else
            {
                List <dynamic> listData = new List <dynamic>();
                listData.Clear();
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string FListSQL = Convert.ToString(ds.Tables[0].Rows[0]["F_SZXY_ListSQL"]);
                    foreach (DataRow Row in ds.Tables[0].Rows)
                    {
                        //Kingdee.BOS.Log.Logger.Debug("QuerySQL", $"/*Dialect*/{Convert.ToString(Row[6])} {View.Model.GetPKValue()}");
                        if (Convert.ToString(Row[1]).IsNullOrEmptyOrWhiteSpace())
                        {
                            View.ShowMessage("当前用户没有设置grf打印模板,请检查!");
                        }
                        if (Convert.ToString(Row[2]).IsNullOrEmptyOrWhiteSpace())
                        {
                            View.ShowMessage("当前用户没有设置grf打印地址,请检查!");
                        }
                        var ReportModel = new
                        {
                            FID          = Convert.ToString(Row[0]),
                            report       = Convert.ToString(Row[1]),
                            PrintAddress = Convert.ToString(Row[2]),
                            PrintQty     = Convert.ToString(Row[3]),
                            //Label = Convert.ToString(Row[4]),
                            ConnString = Convert.ToString(Row[5]),
                            QuerySQL   = $"{Convert.ToString(Row[6])}F_SZXY_CTNNO='{XH}' {FListSQL}"
                        };
                        listData.Add(ReportModel);
                    }
                }
                string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(listData);
                //调用打印
                string  SQL = "/*dialect*/select F_SZXY_EXTERNALCONADS from SZXY_t_ClientExtern ";
                DataSet ids = DBServiceHelper.ExecuteDataSet(Context, SQL);
                if (ids != null && ids.Tables.Count > 0 && ids.Tables[0].Rows.Count > 0)
                {
                    string linkUrl = Convert.ToString(ids.Tables[0].Rows[0][0]).Replace("\\", "\\\\");// @"C:\Users\Administrator\Desktop\Grid++Report 6old\Grid++Report 6\Samples\CSharp\8.PrintInForm\bin\Debug\PrintReport.exe";
                    if (!linkUrl.IsNullOrEmptyOrWhiteSpace())
                    {
                        View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Preview " + strJson);
                    }
                    if (!strJson.IsNullOrEmptyOrWhiteSpace())
                    {
                        View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Print " + strJson);
                    }

                    else
                    {
                        View.ShowMessage("当前用户没有设置Grid++Report打印外接程序地址,请检查!");
                    }
                }
                View.SendDynamicFormAction(View);
            }
            #endregion
        }
        public override void ButtonClick(ButtonClickEventArgs e)
        {
            if (e.Key.EqualsIgnoreCase("F_JD_BTNOK"))
            {
                this.View.GetControl("F_JD_BTNOK").Enabled = false;

                if (FileNameList.Count < 1)
                {
                    this.View.ShowMessage("未检测到需要引入的txt文件!", MessageBoxType.Error);
                }
                else
                {
                    string result = "";
                    for (int f = 0; f < FileNameList.Count; f++)
                    {
                        result += "\r\n《" + _FileList[f] + "》结果:";
                        try
                        {
                            string        CustomKey = this.View.OpenParameter.GetCustomParameter("CustomKey").ToString();//获取父级页面传参的参数
                            List <object> analysis  = new List <object> {
                            };
                            if (CustomKey == "2001")
                            {
                                analysis = GetAnalysisTxt(FileNameList[f]);
                            }
                            else
                            {
                                analysis = GetAnalysisTxt2(FileNameList[f]);
                            }

                            string sql_3 = @"select tt.FID,t1.FENTRYID,t2.FMATERIALID,t2.FNUMBER from t_STK_InStock tt
                            left outer join T_STK_INSTOCKENTRY t1 on tt.FID=t1.FID
                            left outer join T_BD_MATERIAL t2 on t1.FMATERIALID=t2.FMATERIALID
                            where tt.FCancelStatus='A' and tt.FDocumentStatus in('A','B') and tt.F_PAEZ_Text='" + analysis[0].ToString() + "'";


                            DataSet   ds_3    = DBServiceHelper.ExecuteDataSet(this.Context, sql_3);
                            DataTable dt_head = ds_3.Tables[0]; dt_head.PrimaryKey = new DataColumn[] { dt_head.Columns["FENTRYID"] };
                            if (dt_head.Rows.Count < 1)
                            {
                                result += "\r\n 不存在Invoice No:“" + analysis[0].ToString() + "”的单据或已提交或已审核,无法更新单价。\r\n________________________________________________________________________\r\n";
                                continue;
                            }
                            long      BillID   = Convert.ToInt64(dt_head.Rows[0]["FID"]);
                            DataTable dt_entry = (DataTable)analysis[1];

                            #region 修改单据数据

                            FormMetadata  meta        = MetaDataServiceHelper.Load(this.Context, "STK_InStock") as FormMetadata;
                            BusinessInfo  info        = meta.BusinessInfo;
                            DynamicObject toModifyObj = Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.LoadSingle(this.Context, BillID, info.GetDynamicObjectType());

                            if (toModifyObj != null)
                            {
                                decimal FEXCHANGERATE = 1;
                                DynamicObjectCollection InStockFin = toModifyObj["InStockFin"] as DynamicObjectCollection;
                                foreach (DynamicObject StockFin in InStockFin)
                                {
                                    FEXCHANGERATE = Convert.ToDecimal(info.GetField("FEXCHANGERATE").DynamicProperty.GetValue(StockFin));//汇率
                                }

                                DynamicObjectCollection entryObjs = toModifyObj["InStockEntry"] as DynamicObjectCollection;
                                string  FNUMBER = string.Empty;
                                decimal FTaxPrice = 0; decimal FTAXRATE = 0; decimal FPRICEUNITQTY = 0;
                                string  err_row = "";
                                foreach (DynamicObject entryObj in entryObjs)
                                {
                                    int FENTRYID = Convert.ToInt32(entryObj["Id"]);
                                    FTAXRATE      = Convert.ToDecimal(info.GetField("FTAXRATE").DynamicProperty.GetValue(entryObj)) / 100;
                                    FPRICEUNITQTY = Convert.ToDecimal(info.GetField("FPRICEUNITQTY").DynamicProperty.GetValue(entryObj));
                                    DataRow dr = dt_head.Rows.Find(FENTRYID);
                                    if (dr != null)
                                    {
                                        FNUMBER = dr["FNUMBER"].ToString();
                                        DataRow[] dr_r = dt_entry.Select("FPartID='" + FNUMBER + "'");
                                        if (dr_r.Length > 0)
                                        {
                                            FTaxPrice = Convert.ToDecimal(dr_r[0]["FUnitPrice"]);
                                            decimal FPRICE     = Math.Round((FTaxPrice / (1 + FTAXRATE)), 6, MidpointRounding.AwayFromZero);
                                            decimal FALLAMOUNT = Math.Round((FTaxPrice * FPRICEUNITQTY), 2, MidpointRounding.AwayFromZero);
                                            decimal FAMOUNT    = Math.Round((FTaxPrice / (1 + FTAXRATE) * FPRICEUNITQTY), 2, MidpointRounding.AwayFromZero);

                                            info.GetField("FPRICE").DynamicProperty.SetValue(entryObj, FPRICE);
                                            info.GetField("FTaxPrice").DynamicProperty.SetValue(entryObj, FTaxPrice);
                                            info.GetField("FALLAMOUNT").DynamicProperty.SetValue(entryObj, FALLAMOUNT);
                                            info.GetField("FAMOUNT").DynamicProperty.SetValue(entryObj, FAMOUNT);
                                            info.GetField("FTAXAMOUNT").DynamicProperty.SetValue(entryObj, FALLAMOUNT - FAMOUNT);
                                            info.GetField("FTAXNETPRICE").DynamicProperty.SetValue(entryObj, FTaxPrice);

                                            info.GetField("FTAXAMOUNT_LC").DynamicProperty.SetValue(entryObj, Math.Round((FALLAMOUNT - FAMOUNT) * FEXCHANGERATE, 2, MidpointRounding.AwayFromZero)); //税额(本位币)
                                            info.GetField("FAMOUNT_LC").DynamicProperty.SetValue(entryObj, Math.Round((FAMOUNT * FEXCHANGERATE), 2, MidpointRounding.AwayFromZero));                 //金额(本位币)FAMOUNT_LC
                                            info.GetField("FALLAMOUNT_LC").DynamicProperty.SetValue(entryObj, Math.Round((FALLAMOUNT * FEXCHANGERATE), 2, MidpointRounding.AwayFromZero));           //含税金额(本位币)FAMOUNT_LC
                                        }
                                        else
                                        {
                                            err_row += "物料【" + FNUMBER + "】未检测到导入的数据。\r\n";
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        err_row += "分录【" + FENTRYID + "】未检测对应物料数据,请检查。\r\n";
                                        continue;
                                    }
                                }
                                if (err_row == "")
                                {
                                    IOperationResult save_result = Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.Save(this.Context, info, new DynamicObject[] { toModifyObj }, null, "Save");
                                    if (save_result.IsSuccess)
                                    {
                                        Import  = true;
                                        result += "\r\n引入成功!\r\n________________________________________________________________________\r\n";
                                        continue;
                                    }
                                    else
                                    {
                                        for (int mf = 0; mf < save_result.ValidationErrors.Count; mf++)
                                        {
                                            result += "\r\n" + save_result.ValidationErrors[mf].Message;
                                        }
                                        result += "\r\n________________________________________________________________________\r\n";
                                        continue;
                                    }
                                }
                                else
                                {
                                    result += "\r\n" + err_row;
                                    result += "\r\n________________________________________________________________________\r\n";
                                    continue;
                                }
                            }
                            #endregion
                        }
                        catch (Exception ex)
                        {
                            result += "\r\n" + ex.Message.ToString() + "\r\n________________________________________________________________________\r\n";
                            continue;
                        }
                    }

                    this._FileList.Clear();
                    this.FileNameList.Clear();
                    this.View.GetControl("F_JD_FileUpdate").SetValue(DBNull.Value);
                    this.View.Refresh();
                    this.View.ShowMessage("导入完成,以下为具体的引入情况:" + result, MessageBoxType.Advise);
                }
            }
            else if (e.Key.EqualsIgnoreCase("F_JD_BTNCancel"))
            {
                this.View.ReturnToParentWindow(new FormResult(Import));
                this.View.Close();
            }
        }
Пример #18
0
        private DataSet getPrintModel(IBillView view, Context context, string pJSQL, string orgid, string macInfo, string f_SZXY_ForLabel, ref int V)
        {
            DataSet RESDS = null;
            string  SQL12 = "/*dialect*/select T1.FID,T1.F_SZXY_REPORT,T1.F_SZXY_PRINTMAC,T1.F_SZXY_PRINTQTY,T1.F_SZXY_LPRINT,T1.F_SZXY_CONNSTRING,T1.F_SZXY_QUERYSQL," +
                            "T1.F_SZXY_ListSQL,T1.F_SZXY_CustID ,T1.F_SZXY_Model '产品型号', T3.FNAME, T1.F_SZXY_CHECKBOX 'CKB',T1.F_SZXY_Remark,T1.FNUMBER '标签' from SZXY_t_BillTemplatePrint T1" +
                            " left join   T_BD_MATERIAL T2  on T2.FMATERIALID=T1.F_SZXY_Model " +
                            " left join   T_BD_MATERIAL_L T3 on t2.FMATERIALID=T3.FMATERIALID   where" +
                            "  T1.F_SZXY_BILLIDENTIFI='" + View.BusinessInfo.GetForm().Id + "' and T1.FUSEORGID='" + orgid + "'" +
                            " and T1.F_SZXY_TYPESELECT='1'   and T1.FDOCUMENTSTATUS='C'  " + pJSQL + " ";
            DataSet DS = null;

            if (!macInfo.IsNullOrEmptyOrWhiteSpace())
            {
                DS = DBServiceHelper.ExecuteDataSet(Context, SQL12);
                if (DS != null && DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow DR in DS.Tables[0].Rows)
                    {
                        V = 0;
                        if (!Convert.ToString(DR["CKB"]).IsNullOrEmptyOrWhiteSpace())
                        {
                            V = Convert.ToInt32(DR["CKB"]);
                        }

                        RESDS = DS;
                    }
                }
                else
                {
                    string WhereSql = $"{SQL12} and F_SZXY_Remark='{macInfo}' ";
                    DS = DBServiceHelper.ExecuteDataSet(Context, WhereSql);
                    if (DS != null && DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow DR in DS.Tables[0].Rows)
                        {
                            V = 0;
                            if (!Convert.ToString(DR["CKB"]).IsNullOrEmptyOrWhiteSpace())
                            {
                                V = Convert.ToInt32(DR["CKB"]);
                            }

                            RESDS = DS;
                        }
                    }
                    else
                    {
                        WhereSql = $"{SQL12} and F_SZXY_Remark='' ";
                        DS       = DBServiceHelper.ExecuteDataSet(Context, WhereSql);
                        if (DS != null && DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow DR in DS.Tables[0].Rows)
                            {
                                V = 0;
                                if (!Convert.ToString(DR["CKB"]).IsNullOrEmptyOrWhiteSpace())
                                {
                                    V = Convert.ToInt32(DR["CKB"]);
                                }

                                RESDS = DS;
                            }
                        }
                    }
                }
            }

            return(RESDS);
        }
        /// <summary>
        ///累加日计划面积
        /// </summary>
        /// <param name="e"></param>
        public override void EndOperationTransaction(EndOperationTransactionArgs e)
        {
            base.EndOperationTransaction(e);
            IViewService Services = ServiceHelper.GetService <IViewService>();

            if (selectedRows != null && selectedRows.Count() != 0)
            {
                IMetaDataService metadataService = Kingdee.BOS.App.ServiceHelper.GetService <IMetaDataService>();

                foreach (DynamicObject dy in selectedRows)
                {
                    string Id = Convert.ToString(dy["Id"]);
                    if (!Convert.ToString(dy["F_SZXY_Invalid"]).EqualsIgnoreCase("True"))
                    {
                        string  BZ        = "";
                        string  Orgid     = "";
                        string  Operator  = "";
                        decimal OrderQty  = 0;
                        string  Cust      = "";
                        string  CustBacth = "";
                        string  BC        = "";
                        if (dy["F_SZXY_TeamGroup"] is DynamicObject BZDO)
                        {
                            BZ = BZDO["Id"].ToString();
                        }


                        if (dy["F_SZXY_operator"] is DynamicObject OperatorDo)
                        {
                            Operator = OperatorDo["Id"].ToString();
                        }
                        if (dy["F_SZXY_CustCode"] is DynamicObject CustDo)
                        {
                            Cust = CustDo["Id"].ToString();
                        }
                        if (dy["F_SZXY_BC"] is DynamicObject BCDo)
                        {
                            BC = BCDo["Id"].ToString();
                        }
                        OrderQty  = Convert.ToDecimal(dy["F_SZXY_OrderQty"]);
                        CustBacth = dy["F_SZXY_CustBacth"].ToString();

                        if (dy["SZXY_BZKHXXDYBEntry"] is DynamicObjectCollection Entry && dy["F_SZXY_OrgId"] is DynamicObject OrgDo)
                        {
                            Orgid = OrgDo["Id"].ToString();
                            foreach (DynamicObject item in Entry)
                            {
                                string  F_SZXY_NO           = item["F_SZXY_NO"].ToString();
                                string  F_SZXY_NewDate      = item["F_SZXY_NewDate"].ToString();
                                string  F_SZXY_OriginalDate = item["F_SZXY_OriginalDate"].ToString();
                                string  F_SZXY_CustCartonNo = item["F_SZXY_CustCartonNo"].ToString();//新箱号
                                string  MoNo          = item["F_SZXY_ProductionTask1"].ToString();
                                string  MoLineNo      = item["F_SZXY_MoLineNo"].ToString();
                                string  Mat           = item["F_SZXY_Model_Id"].ToString();
                                decimal F_SZXY_PLy    = Convert.ToDecimal(item["F_SZXY_PLy"].ToString());
                                decimal F_SZXY_Width  = Convert.ToDecimal(item["F_SZXY_Width"].ToString());
                                decimal F_SZXY_Len    = Convert.ToDecimal(item["F_SZXY_Len"].ToString());
                                decimal F_SZXY_Area   = Convert.ToDecimal(item["F_SZXY_Area"].ToString());
                                decimal F_SZXY_volume = Convert.ToDecimal(item["F_SZXY_volume"].ToString());
                                string  SQLPJ         = "";
                                if (!F_SZXY_CustCartonNo.IsNullOrEmptyOrWhiteSpace())
                                {
                                    SQLPJ = $"  F_SZXY_CTNNO = '{F_SZXY_CustCartonNo}', ";
                                }

                                if (!F_SZXY_NO.IsNullOrEmptyOrWhiteSpace())
                                {
                                    long MoId     = 0;
                                    long FENTRYID = 0;
                                    if (!MoLineNo.IsNullOrEmptyOrWhiteSpace() && !MoNo.IsNullOrEmptyOrWhiteSpace())
                                    {
                                        string sql = $"/*dialect*/select T2.fid,T2.FENTRYID  from " +
                                                     $"T_PRD_MO T1 " +
                                                     $"inner join " +
                                                     $" T_PRD_MOENTRY T2 on T1.fid = T2.fid " +
                                                     $"where T1.FPRDORGID = '{Orgid}' and T1.FBILLNO='{MoNo}' and T2.FSEQ='{MoLineNo}'";

                                        DataSet Selds = DBServiceHelper.ExecuteDataSet(Context, sql);
                                        if (Selds != null && Selds.Tables.Count > 0 && Selds.Tables[0].Rows.Count > 0)
                                        {
                                            MoId     = Convert.ToInt64(Selds.Tables[0].Rows[0]["fid"].ToString());
                                            FENTRYID = Convert.ToInt64(Selds.Tables[0].Rows[0]["FENTRYID"].ToString());

                                            string updatesql1 = $"/*dialect*/update   SZXY_t_BZDHEntry " +
                                                                $"set " +
                                                                $"F_SZXY_DATE = '{F_SZXY_NewDate}', " +
                                                                $" F_SZXY_MATERIAL = '{Mat}', " +
                                                                $" F_SZXY_PLY = '{F_SZXY_PLy}', " +
                                                                $" F_SZXY_WIDTH = '{F_SZXY_Width}', " +
                                                                $" F_SZXY = '{F_SZXY_Len}', " +
                                                                $" F_SZXY_AREA1 = '{F_SZXY_Area}', " +
                                                                $" F_SZXY_TEAMGROUP1 = '{BZ}', " +
                                                                $" F_SZXY_CLASSES1 = '{BC}', " +
                                                                SQLPJ +
                                                                $" F_SZXY_OPERATOR = '{Operator}'," +
                                                                $" F_SZXY_CUSTBACTH = '{CustBacth}'," +
                                                                $" F_SZXY_BACTHQTY = '{OrderQty}'," +
                                                                $"  F_SZXY_PUDNO = '{MoNo}'," +
                                                                $"  F_SZXY_JQTY = '{F_SZXY_volume}'," +
                                                                $" F_SZXY_PUDLINENO = '{MoLineNo}' " +
                                                                $" where F_SZXY_CTNNO = '{F_SZXY_NO}'";
                                            DBServiceHelper.Execute(Context, updatesql1);

                                            //string updatesql2 = $"/*dialect*/update a   " +
                                            //     $"set a.F_SZXY_MOID={MoId} " +
                                            //     $" from  SZXY_t_BZD a,SZXY_t_BZDHEntry b  " +
                                            //     $" where a.Fid=B.Fid and  b.F_SZXY_CTNNO = '{F_SZXY_NO}'";
                                            //DBServiceHelper.Execute(Context, updatesql2);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #20
0
        /// <summary>
        /// 审核结束自动下推(应付单下推付款申请单)
        /// </summary>
        /// <param name="e"></param>
        public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
        {
            base.AfterExecuteOperationTransaction(e);
            try
            {
                string sql = string.Empty;
                if (e.DataEntitys != null && e.DataEntitys.Count <DynamicObject>() > 0)
                {
                    foreach (DynamicObject item in e.DataEntitys)
                    {
                        //收款单id
                        string Fid  = item["Id"].ToString();
                        string sql2 = "";
                        //收款单源单明细
                        DynamicObjectCollection RECEIVEBILLSRCENTRYList = item["RECEIVEBILLSRCENTRY"] as DynamicObjectCollection;
                        foreach (var entry in RECEIVEBILLSRCENTRYList)
                        {
                            //销售订单明细内码
                            string FORDERENTRYID = entry["FSRCORDERENTRYID"].ToString();
                            //本次收款金额
                            decimal FREALRECAMOUNT = Convert.ToDecimal(entry["REALRECAMOUNT"].ToString());
                            if (!string.IsNullOrEmpty(FORDERENTRYID))
                            {
                                //查询采购订单
                                sql = string.Format(@"select a.FBILLNO,b.FENTRYID as 采购订单明细内码 ,f.F_YBG_BUSINESSMODEL as 业务模式  from  t_PUR_POOrder a  
                                                       inner join   t_PUR_POOrderEntry b on a.fID=b.FID 
                                                       inner join T_PUR_POORDERENTRY_LK c on c.FENTRYID=b.FENTRYID 
                                                       left join T_SAL_ORDERENTRY d on d.FENTRYID=c.FSID
                                                       left  join T_SAL_ORDER f on f.FID=d.FID 
                                                       where  FSID='{0}'", FORDERENTRYID);
                                DataSet   ds = DBServiceHelper.ExecuteDataSet(this.Context, sql);
                                DataTable dt = ds.Tables[0];
                                if (dt.Rows.Count > 0)
                                {
                                    for (int i = 0; i < dt.Rows.Count; i++)
                                    {
                                        string F_YBG_BUSINESSMODEL = dt.Rows[i]["采购订单明细内码"].ToString();
                                        if (F_YBG_BUSINESSMODEL == "01" || F_YBG_BUSINESSMODEL == "04") //挂靠的采用自动生成付款申请单
                                        {
                                            string POFENTRYID = dt.Rows[i]["采购订单明细内码"].ToString();
                                            if (string.IsNullOrEmpty(sql2))
                                            {
                                                sql2 += "  FPAYABLEENTRYID='" + POFENTRYID + "' ";
                                            }
                                            else
                                            {
                                                sql2 += "  or  FPAYABLEENTRYID='" + POFENTRYID + "' ";
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(sql2))
                        {
                            #region  应付单下推付款申请单
                            string           srcFormId  = "AP_Payable";  //应付单
                            string           destFormId = "CN_PAYAPPLY"; //付款申请单
                            IMetaDataService mService   = Kingdee.BOS.App.ServiceHelper.GetService <IMetaDataService>();
                            IViewService     vService   = Kingdee.BOS.App.ServiceHelper.GetService <IViewService>();
                            FormMetadata     destmeta   = mService.Load(this.Context, destFormId) as FormMetadata;
                            //转换规则的唯一标识
                            string ruleKey = "AP_PayableToPayApply";
                            //var rules = ConvertServiceHelper.GetConvertRules(Context, srcFormId, destFormId);
                            //var rule = rules.FirstOrDefault(t => t.IsDefault);
                            ConvertRuleElement     rule    = GetDefaultConvertRule(Context, srcFormId, destFormId, ruleKey);
                            List <ListSelectedRow> lstRows = new List <ListSelectedRow>();
                            string  strsql = "select a.FID , a.FENTRYID  from T_AP_PAYABLEPLAN  a left join T_AP_PAYABLE b on a.FID=b.FID   where b.FDOCUMENTSTATUS='C' and  (" + sql2 + ") ";
                            DataSet ds2    = DBServiceHelper.ExecuteDataSet(Context, strsql);
                            if (ds2.Tables[0].Rows.Count > 0)
                            {
                                HashSet <string> hasset = new HashSet <string>();
                                for (int j = 0; j < ds2.Tables[0].Rows.Count; j++)
                                {
                                    hasset.Add(ds2.Tables[0].Rows[j]["FID"].ToString());
                                    long entryId = Convert.ToInt64(ds2.Tables[0].Rows[j]["FENTRYID"]);
                                    //源单单据标识
                                    ListSelectedRow row = new ListSelectedRow(ds2.Tables[0].Rows[j]["FID"].ToString(), entryId.ToString(), 0, "AP_Payable");
                                    //源单单据体标识
                                    row.EntryEntityKey = "FEntityPlan";
                                    lstRows.Add(row);
                                }

                                PushArgs        pargs      = new PushArgs(rule, lstRows.ToArray());
                                IConvertService cvtService = Kingdee.BOS.App.ServiceHelper.GetService <IConvertService>();
                                OperateOption   option     = OperateOption.Create();
                                option.SetIgnoreWarning(true);
                                option.SetVariableValue("ignoreTransaction", false);
                                option.SetIgnoreInteractionFlag(true);
                                #region 提交审核
                                //OperateOption option2 = OperateOption.Create();
                                //option2.SetIgnoreWarning(true);
                                //option2.SetVariableValue("ignoreTransaction", true);
                                //foreach (var hid in hasset)
                                //{
                                //    //如果应付单没有提交先提交审核
                                //    IMetaDataService BomService = Kingdee.BOS.App.ServiceHelper.GetService<IMetaDataService>();
                                //    //应付单元素包
                                //    FormMetadata APMeta = BomService.Load(Context, "AP_Payable") as FormMetadata;
                                //    IViewService APVService = Kingdee.BOS.App.ServiceHelper.GetService<IViewService>();
                                //    //应付单数据包
                                //    DynamicObject APmd = APVService.LoadSingle(Context, hid, APMeta.BusinessInfo.GetDynamicObjectType());

                                //    DynamicObject[] dy = new DynamicObject[] { APmd };

                                //    object[] items = dy.Select(p => p["Id"]).ToArray();

                                //    ISubmitService submitService = Kingdee.BOS.App.ServiceHelper.GetService<ISubmitService>();
                                //    IOperationResult submitresult = submitService.Submit(Context, APMeta.BusinessInfo, items, "Submit", option2);

                                //    IAuditService auditService = Kingdee.BOS.App.ServiceHelper.GetService<IAuditService>();
                                //    IOperationResult auditresult = auditService.Audit(Context, APMeta.BusinessInfo, items, option2);
                                //}
                                #endregion

                                ConvertOperationResult cvtResult = cvtService.Push(Context, pargs, option, false);
                                if (cvtResult.IsSuccess)
                                {
                                    DynamicObject[] dylist = (from p in cvtResult.TargetDataEntities select p.DataEntity).ToArray();
                                    //修改应收单里面数据
                                    for (int K = 0; K < dylist.Length; K++)
                                    {
                                        //付款原因
                                        dylist[K]["F_YBG_Remarks"] = "供应商付款";
                                        //明细信息
                                        DynamicObjectCollection RECEIVEBILLENTRYList = dylist[K]["FPAYAPPLYENTRY"] as DynamicObjectCollection;
                                        foreach (var Entry in RECEIVEBILLENTRYList)
                                        {
                                            //结算方式
                                            BaseDataField FSETTLETYPEID = destmeta.BusinessInfo.GetField("FSETTLETYPEID") as BaseDataField;
                                            Entry["FSETTLETYPEID_Id"] = 4;
                                            Entry["FSETTLETYPEID"]    = vService.LoadSingle(Context, 4, FSETTLETYPEID.RefFormDynamicObjectType);
                                        }
                                    }
                                    //保存
                                    ISaveService     saveService = Kingdee.BOS.App.ServiceHelper.GetService <ISaveService>();
                                    IOperationResult saveresult  = saveService.Save(Context, destmeta.BusinessInfo, dylist, option);
                                    bool             reult       = CheckResult(saveresult, out string mssg);
                                    if (!reult)
                                    {
                                        throw new Exception("收款款单审核成功,生成付款申请单失败:");
                                    }
                                    else
                                    {
                                        //纪录核销的纪录
                                        OperateResultCollection operateResults = saveresult.OperateResult;
                                        string fnmber = operateResults[0].Number;
                                        string fid    = operateResults[0].PKValue.ToString();
                                    }
                                }
                            }
                            else
                            {
                                throw new KDException("", "应付单不存在或者未审核,下推付款申请单失败");
                            }
                            #endregion
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new KDException("", "应付单下推付款申请单失败:" + ex.ToString());
            }
        }
 public void Run(Kingdee.BOS.Context ctx, Schedule schedule)
 {
     try
     {
         string sql = string.Empty;
         #region
         sql = string.Format(@"select  FID, F_YBG_WAREHOUSE ,F_YBG_SUPPLIER from  T_SAL_ORDER where FDOCUMENTSTATUS='C' or FDOCUMENTSTATUS='B' ");
         DataSet   ds = DBServiceHelper.ExecuteDataSet(ctx, sql);
         DataTable dt = ds.Tables[0];
         if (dt.Rows.Count > 0)
         {
             string upsql = "";
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 string FID = dt.Rows[i]["FID"].ToString();
                 //供应商
                 string F_YBG_Supplier = dt.Rows[i]["F_YBG_SUPPLIER"].ToString();
                 //仓库
                 string F_YBG_Warehouse     = dt.Rows[i]["F_YBG_WAREHOUSE"].ToString();
                 string F_YBG_BUSINESSMODEL = ""; //其他仓库默认01
                 //仓库编码
                 sql = string.Format(@"select  FNumber from t_BD_Stock where FSTOCKID='{0}'", F_YBG_Warehouse);
                 string CKFNumber = DBServiceHelper.ExecuteScalar <string>(ctx, sql, "0", null);
                 //供应商编码 ---自营VEN00057  VEN00099 VEN00256
                 sql = string.Format(@"select  FNumber from t_BD_Supplier where FSUPPLIERID='{0}'", F_YBG_Supplier);
                 string SPFNUMBER = DBServiceHelper.ExecuteScalar <string>(ctx, sql, "0", null);
                 if (CKFNumber == "0" || SPFNUMBER == "0")
                 {
                 }
                 else
                 {
                     //非嘉里开头的
                     if (CKFNumber.StartsWith("ZF")) //挂靠01
                     {
                         F_YBG_BUSINESSMODEL = "01";
                         upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                     }
                     //嘉里开头
                     else if (CKFNumber.StartsWith("JLZF")) //04 挂靠自发
                     {
                         F_YBG_BUSINESSMODEL = "04";
                         upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                     }
                     //嘉里物流主仓 嘉里苏宁移动仓
                     else if (CKFNumber.StartsWith("JL002") || CKFNumber.StartsWith("JLSN001"))
                     {
                         // 是壹办公供应商或者自营供应商
                         if (SPFNUMBER.Contains("VEN00057") || SPFNUMBER.Contains("VEN00099") || SPFNUMBER.Contains("P451")) //自营 05
                         {
                             F_YBG_BUSINESSMODEL = "05";
                             upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                         }
                         else //代采 06
                         {
                             F_YBG_BUSINESSMODEL = "06";
                             upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                         }
                     }
                     //珠海仓
                     else if (CKFNumber.StartsWith("YBG001") || CKFNumber.StartsWith("YBG015") || CKFNumber.StartsWith("YBG017"))
                     {
                         F_YBG_BUSINESSMODEL = "07"; //珠海自营 07
                         upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                     }
                     // 观澜仓 车公庙仓
                     else if (CKFNumber.StartsWith("YBG002") || CKFNumber.StartsWith("YBG003"))
                     {
                         //壹办公供应商或者自营供应商
                         if (SPFNUMBER.Contains("VEN00057") || SPFNUMBER.Contains("VEN00099") || SPFNUMBER.Contains("P451")) //自营直发 05
                         {
                             F_YBG_BUSINESSMODEL = "02";
                             upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                         }
                         else //代采直发 03
                         {
                             F_YBG_BUSINESSMODEL = "03";
                             upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                         }
                     }
                     else //其他仓库默认01
                     {
                         //壹办公供应商或者自营供应商
                         if (SPFNUMBER.Contains("VEN00057") || SPFNUMBER.Contains("VEN00099") || SPFNUMBER.Contains("P451"))  //自营 05
                         {
                             F_YBG_BUSINESSMODEL = "05";
                             upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                         }
                         else
                         {
                             F_YBG_BUSINESSMODEL = "01";
                             upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                         }
                     }
                 }
             }
             //更新业务模式
             DBServiceHelper.Execute(ctx, upsql);
         }
         #endregion
     }
     catch (Exception ex)
     {
         throw new Exception("更新报错:" + ex.ToString());
     }
 }
Пример #22
0
        public override void DataChanged(DataChangedEventArgs e)
        {
            base.DataChanged(e);
            string Flag = "";

            int           m = e.Row; string SelSQL = "";
            DynamicObject billobj  = this.Model.DataObject;
            string        InNO     = Convert.ToString(this.Model.GetValue("F_SZXY_NO", m));  //获取输入的编号
            DynamicObject BQTypeDO = this.Model.GetValue("F_SZXY_Tagtype") as DynamicObject; //获取输入 标签类型
            string        FQJYNO   = Convert.ToString(this.Model.GetValue("F_SZXY_FQJYNO")); //获取输入的编号
            string        XQty     = Convert.ToString(this.Model.GetValue("F_SZXY_volume")); //获取输入每箱装的卷卷数

            //选择标签类型 并输入卷数(每箱装的卷卷数),扫描分切编号,自动将分切编号相关信息携带到XY待重检信息表中,装满一箱时自动生成箱条码,并调用标签进行打印;
            if (e.Field.Key.EqualsIgnoreCase("F_SZXY_NO"))
            {
                Flag = "BarNo";
                if (InNO.IsNullOrEmptyOrWhiteSpace())
                {
                    return;
                }

                if (!XQty.IsNullOrEmptyOrWhiteSpace() && Convert.ToInt32(XQty) > 0 && !InNO.IsNullOrEmptyOrWhiteSpace() && billobj["F_SZXY_OrgId"] is DynamicObject orgobj)
                {
                    string orgid = Convert.ToString(orgobj["Id"]);
                    if (InNO.Length <= 2)
                    {
                        this.View.ShowWarnningMessage("请检查输入的编号是否有误!"); return;
                    }

                    //string no1 = InNO.Remove(1, 1);
                    //inNo = InNO;
                    //int Currindex = no1.IndexOf('C');
                    //if (Currindex == 0)


                    SelSQL = "/*dialect*/" +
                             "select " +
                             "T1.F_SZXY_TEAMGROUP1 '班组',T1.F_SZXY_CLASSES1 '班次'," +
                             "T1.F_SZXY_STATION '工位',T1.F_SZXY_CHECKOUT '检验标志'," +
                             "T1.F_SZXY_SpecialMark '特殊标志',T1.F_SZXY_BLEVEL '性能等级'," +
                             "T1.F_SZXY_MATERIAL '产品型号',T1.F_SZXY_AREA '面积'," +
                             "T1.F_SZXY_PLy '厚度',T1.F_SZXY_Width '宽度'," +
                             "T1.F_SZXY_Len '长度',T2.FDATE '生产日期' " +
                             "from SZXY_t_XYFQEntry T1  " +
                             "left join SZXY_t_XYFQ  T2 on T1.fid=T2.fid " +
                             $"where T1.F_SZXY_BARCODEE='{InNO}' " +
                             $"and T2.F_SZXY_ORGID1={orgid}";
                    DataSet fillData = DBServiceHelper.ExecuteDataSet(this.Context, SelSQL);
                    SetBillValue(Context, fillData, this.View, e.Row, Convert.ToInt32(XQty), orgobj, "FQ");
                    //this.View.UpdateView("F_SZXY_XYDCJXXBEntity");


                    //打印
                    //if (XHList.Count>0 && XHList!=null)
                    //{

                    //    string MacInfo = Utils.GetMacAddress();
                    //    Logger.Debug("当前MAC地址", MacInfo);


                    //    DataSet PrintModelDS = null;
                    //    int ckb = 0;


                    //    //是否指定标签模板
                    //    string PJSQL = " ";

                    //    DynamicObject PrintTemp = this.Model.GetValue("F_SZXY_Tagtype") as DynamicObject;

                    //    if (PrintTemp != null)
                    //    {
                    //        string PId = Convert.ToString(PrintTemp["Id"]);

                    //        if (!PId.IsNullOrEmptyOrWhiteSpace())
                    //        {
                    //            PJSQL = $" and T1.Fid={PId} ";
                    //        }
                    //    }
                    //    foreach (string F_SZXY_ForLabel in XHList)
                    //    {

                    //        if (!MacInfo.IsNullOrEmptyOrWhiteSpace())
                    //        {
                    //            PrintModelDS = getPrintModel(this.View, Context, PJSQL, orgid.ToString(), MacInfo, F_SZXY_ForLabel, ref ckb);

                    //            if (PrintModelDS != null)
                    //            {
                    //                XYStraddleCut.Print(PrintModelDS, ckb, Context, this.View, $"'{F_SZXY_ForLabel}'", "XH");
                    //            }
                    //            else
                    //            {
                    //                View.ShowWarnningMessage("没有匹配到模板!");
                    //                return;
                    //            }
                    //        }


                    //    }
                    //}
                }
                else
                {
                    this.View.ShowWarnningMessage("请检查输入的卷数!");
                    this.Model.SetValue("F_SZXY_NO", "", e.Row);
                    this.View.UpdateView("F_SZXY_NO");
                    return;
                }
            }

            if (e.Field.Key.EqualsIgnoreCase("F_SZXY_FQJYNO"))
            {
                Flag = "BillNo";
                if (!FQJYNO.IsNullOrEmptyOrWhiteSpace() && billobj["F_SZXY_OrgId"] is DynamicObject orgobj)
                {
                    string orgid = Convert.ToString(orgobj["Id"]);
                    if (FQJYNO.Length <= 2)
                    {
                        this.View.ShowWarnningMessage("请检查输入的编号是否有误!"); return;
                    }

                    //分切外观检验单
                    SelSQL = "/*dialect*/" +
                             "select  " +
                             "T2.F_SZXY_STATION '工位',T2.F_SZXY_Barcode '分切编号'," +
                             "T2.F_SZXY_XNDJ '性能等级',T3.F_SZXY_TEAMGROUP1 '班组',T3.F_SZXY_CLASSES1 '班次'," +
                             "T2.F_SZXY_MATERIAL '产品型号',T2.F_SZXY_Area1 '面积',T3.F_SZXY_SpecialMark '特殊标志'," +
                             "T2.F_SZXY_PLy '厚度',T2.F_SZXY_Width '宽度'," +
                             "T2.F_SZXY '长度',T1.FDATE '生产日期' " +
                             "from  SZXY_t_FQJYD T1   " +
                             "left join SZXY_t_FQJYDEntry  T2 on T1.fid=T2.fid " +
                             "left join SZXY_t_XYFQEntry T3 on T2.F_SZXY_BARCODE=T3.F_SZXY_BarCodeE " +

                             $"where T1.FBILLNO='{FQJYNO}' " +
                             $"and T1.F_SZXY_ORGID={orgid}";
                    DataSet fillData = DBServiceHelper.ExecuteDataSet(this.Context, SelSQL);
                    SetBillValue(Context, fillData, this.View, e.Row, Convert.ToInt32(XQty), orgobj, "FQJY");
                    this.View.UpdateView("F_SZXY_XYDCJXXBEntity");


                    ////打印
                    //if (XHList.Count > 0 && XHList != null)
                    //{

                    //    string MacInfo = Utils.GetMacAddress();
                    //    Logger.Debug("当前MAC地址", MacInfo);


                    //    DataSet PrintModelDS = null;
                    //    int ckb = 0;


                    //    //是否指定标签模板
                    //    string PJSQL = " ";

                    //    DynamicObject PrintTemp = this.Model.GetValue("F_SZXY_Tagtype") as DynamicObject;

                    //    if (PrintTemp != null)
                    //    {
                    //        string PId = Convert.ToString(PrintTemp["Id"]);

                    //        if (!PId.IsNullOrEmptyOrWhiteSpace())
                    //        {
                    //            PJSQL = $" and T1.Fid={PId} ";
                    //        }
                    //    }

                    //    StringBuilder STR = new StringBuilder();
                    //    int a = 0;
                    //    foreach (string F_SZXY_ForLabel in XHList)
                    //    {
                    //        if (a==0)
                    //        {
                    //            PrintModelDS = getPrintModel(this.View, Context, PJSQL, orgid.ToString(), MacInfo, F_SZXY_ForLabel, ref ckb);
                    //            a++;
                    //        }

                    //        STR.Append($"'{F_SZXY_ForLabel}',");

                    //    }

                    //    if (!MacInfo.IsNullOrEmptyOrWhiteSpace())
                    //    {

                    //        if (STR.ToString() != "" && !STR.ToString().IsNullOrEmptyOrWhiteSpace())
                    //        {
                    //            string BarNoStr = STR.ToString();
                    //            BarNoStr = BarNoStr.Substring(0, BarNoStr.Length - 1);
                    //            if (PrintModelDS != null)
                    //            {
                    //                XYStraddleCut.Print(PrintModelDS, ckb, Context, this.View, BarNoStr, "XH");
                    //            }
                    //            else
                    //            {
                    //                View.ShowWarnningMessage("没有匹配到模板!");
                    //                return;
                    //            }

                    //        }


                    //    }
                    //}
                }
            }


            //
            if (e.Field.Key.EqualsIgnoreCase("F_SZXY_BOXNO"))
            {
                this.Model.DataObject["FFormId"] = this.View.BusinessInfo.GetForm().Id;
                Utils.Save(View, new DynamicObject[] { this.Model.DataObject }, Kingdee.BOS.Orm.OperateOption.Create(), Context);

                if (e.NewValue.IsNullOrEmptyOrWhiteSpace())
                {
                    return;
                }
                else
                {
                }
                string NewXH           = Convert.ToString(this.Model.GetValue("F_SZXY_BOXNO"));//
                string F_SZXY_ForLabel = e.OldValue.ToString();
                //if (!NewXH.IsNullOrEmptyOrWhiteSpace())
                //{
                //    XHList.Add(NewXH);
                //}

                //打印

                string MacInfo = Utils.GetMacAddress();
                Logger.Debug("当前MAC地址", MacInfo);


                DataSet PrintModelDS = null;
                int     ckb          = 0;


                //是否指定标签模板
                string PJSQL = " ";

                DynamicObject PrintTemp = this.Model.GetValue("F_SZXY_Tagtype") as DynamicObject;

                if (PrintTemp != null)
                {
                    string PId = Convert.ToString(PrintTemp["Id"]);

                    if (!PId.IsNullOrEmptyOrWhiteSpace())
                    {
                        PJSQL = $" and T1.Fid={PId} ";
                    }
                }


                PrintModelDS = getPrintModel(this.View, Context, PJSQL, this.Model.DataObject["F_SZXY_OrgId_Id"].ToString(), MacInfo, F_SZXY_ForLabel, ref ckb);



                if (!MacInfo.IsNullOrEmptyOrWhiteSpace())
                {
                    if (PrintModelDS != null)
                    {
                        Print(PrintModelDS, ckb, Context, this.View, $"'{F_SZXY_ForLabel}'", "XH");
                    }
                    else
                    {
                        View.ShowWarnningMessage("没有匹配到模板!");
                        return;
                    }
                }
            }
        }
Пример #23
0
        /// <summary>
        ///点击确定按钮
        /// </summary>
        /// <param name="e"></param>
        public override void ButtonClick(ButtonClickEventArgs e)
        {
            if (e.Key.EqualsIgnoreCase("F_JD_BTNOK"))
            {
                try
                {
                    this.View.GetControl("F_JD_BTNOK").Enabled = false;
                    if (FileNameList.Count < 1)
                    {
                        this.View.ShowMessage("未检测到需要引入的excel文件!", MessageBoxType.Error);
                    }
                    else
                    {
                        ///读取excel到Dataset
                        DataSet dss_1;
                        string  sql       = string.Empty;
                        string  updatesql = string.Empty;
                        string  err_row   = "";
                        using (ExcelOperation helper = new ExcelOperation(this.View))
                        {
                            dss_1 = helper.ReadFromFile(FileNameList[0], 0, 0);
                        }
                        //获取当前所有物料
                        sql = "select FMASTERID, FNUMBER FROM T_BD_MATERIAL";
                        DataSet   ds      = DBServiceHelper.ExecuteDataSet(this.Context, sql);
                        DataTable dt_Item = ds.Tables[0];
                        dt_Item.PrimaryKey = new DataColumn[] { dt_Item.Columns["FNUMBER"] }; //设置主键
                        DataTable dt_ex = dss_1.Tables[0];
                        //读取excel
                        for (int i = 1; i < dt_ex.Rows.Count; i++)
                        {
                            //物料编码
                            string WlNumber = dt_ex.Rows[i][3].ToString();
                            //单位编码
                            string DWFnumber = dt_ex.Rows[i][5].ToString();
                            //pcs换算率
                            int Fdate = string.IsNullOrEmpty(dt_ex.Rows[i][7].ToString()) ? 0 : Convert.ToInt32(dt_ex.Rows[i][7].ToString());
                            //单箱数量
                            int Dxqty = string.IsNullOrEmpty(dt_ex.Rows[i][8].ToString()) ? 0 : Convert.ToInt32(dt_ex.Rows[i][8].ToString());

                            //判断是否存在改物料

                            DataRow dr_item = dt_Item.Rows.Find(dt_ex.Rows[i][3].ToString());

                            if (dr_item == null)
                            {
                                err_row += "第【" + i + "】行分录,物料代码【" + dt_ex.Rows[i][3].ToString() + "】不存在。\r\n";
                                continue;
                            }
                            else
                            {
                                if (DWFnumber == "PCS")
                                {
                                    Fdate = 1;
                                }
                                updatesql += "/*dialect*/  update T_BD_MATERIAL set FDXQTY=" + Dxqty + ",FPCSCONVERT=" + Fdate + " where FNUMBER='" + WlNumber + "';";
                            }
                        }
                        //更新
                        int reult = DBServiceHelper.Execute(this.Context, updatesql);
                        this.View.ShowMessage("更新成功 \r\n" + err_row.ToString(), MessageBoxType.AskOK);
                        this._FileList.Clear();
                        this.FileNameList.Clear();
                        this.View.GetControl("F_JD_FileUpdate").SetValue(DBNull.Value);
                        this.View.Refresh();
                        return;
                    }
                }
                catch (Exception ex)
                {
                    this.View.ShowMessage("更新换算率失败:" + ex.ToString(), MessageBoxType.Error);
                    this._FileList.Clear();
                    this.FileNameList.Clear();
                    this.View.GetControl("F_JD_FileUpdate").SetValue(DBNull.Value);
                    this.View.Refresh();
                    return;
                }
            }
        }
Пример #24
0
        public static void Print(DataSet DS, int v, Context Context, IBillView View, string XH, string INNOType = "")
        {
            string formid = View.BillBusinessInfo.GetForm().Id.ToString();

            Logger.Debug("打印---", "------------BEGIN------------------");

            Logger.Debug("---", $"------------打印条码或生产订单号为:{XH}------------------");
            List <dynamic> listData = new List <dynamic>();

            listData.Clear();

            if (DS != null && DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow Row in DS.Tables[0].Rows)
                {
                    string FListSQL = Convert.ToString(Row["F_SZXY_ListSQL"]);
                    if (Convert.ToString(Row[1]).IsNullOrEmptyOrWhiteSpace())
                    {
                        View.ShowMessage("当前用户没有设置grf打印模板,请检查!");
                    }
                    if (Convert.ToString(Row[2]).IsNullOrEmptyOrWhiteSpace())
                    {
                        View.ShowMessage("当前用户没有设置grf打印地址,请检查!");
                    }
                    string QSQL = "";
                    if (INNOType == "BillNo")
                    {
                        QSQL = $"{Convert.ToString(Row[6])} DYBQDD in ({XH}) {FListSQL}";

                        Logger.Debug("订单号拼接sql:", QSQL);
                    }
                    else
                    {
                        QSQL = $"{Convert.ToString(Row[6])} DYBQ in ({XH})  {FListSQL}";
                        Logger.Debug("条码号拼接sql:", QSQL);
                    }

                    var ReportModel = new
                    {
                        FID          = Convert.ToString(Row[0]),
                        report       = Convert.ToString(Row[1]),
                        PrintAddress = Convert.ToString(Row[2]),
                        PrintQty     = Convert.ToString(Row[3]),
                        ConnString   = Convert.ToString(Row[5]),
                        QuerySQL     = QSQL
                    };

                    if (QSQL != "")
                    {
                        DataSet SelNullDS = DBServiceHelper.ExecuteDataSet(Context, $"/*dialect*/{QSQL}");

                        if (SelNullDS != null && SelNullDS.Tables.Count > 0 && SelNullDS.Tables[0].Rows.Count > 0)
                        {
                            listData.Add(ReportModel);
                        }
                    }
                    Logger.Debug("最终打印查询SQL:", QSQL);
                }
            }
            string strJson = "";

            if (listData.Count > 0 && listData != null)
            {
                strJson = Newtonsoft.Json.JsonConvert.SerializeObject(listData);
            }

            if (strJson != "")
            {
                //调用打印
                string  SQL = "/*dialect*/select F_SZXY_EXTERNALCONADS from SZXY_t_ClientExtern ";
                DataSet ids = DBServiceHelper.ExecuteDataSet(Context, SQL);

                if (ids != null && ids.Tables.Count > 0 && ids.Tables[0].Rows.Count > 0)
                {
                    string linkUrl = Convert.ToString(ids.Tables[0].Rows[0][0]).Replace("\\", "\\\\");// @"C:\Users\Administrator\Desktop\Grid++Report 6old\Grid++Report 6\Samples\CSharp\8.PrintInForm\bin\Debug\PrintReport.exe";
                    if (v == 0)
                    {
                        if (!strJson.IsNullOrEmptyOrWhiteSpace())
                        {
                            View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Print " + strJson);

                            //打印记录表
                            // Utils.GenPrintReCord(View, Context, formid, XH);
                        }
                        else
                        {
                            View.ShowMessage("当前用户没有设置Grid++Report打印外接程序地址,请检查!");
                        }
                    }
                    else
                    {
                        if (!linkUrl.IsNullOrEmptyOrWhiteSpace())
                        {
                            View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Preview " + strJson);
                        }
                        // if (!linkUrl.IsNullOrEmptyOrWhiteSpace()) View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Print " + strJson);

                        else
                        {
                            View.ShowMessage("当前用户没有设置Grid++Report打印外接程序地址,请检查!");
                        }
                    }
                }
                else
                {
                    Logger.Debug("客户端外接配置查询返回为空", "不调打印");
                }
                View.SendDynamicFormAction(View);
            }

            Logger.Debug("打印---", "---------------END------------------");
        }
        private void SetBillValue(Context context, DynamicObject orgobj, string WhereSql, IBillView view, int erow)
        {
            string XQty = Convert.ToString(this.Model.GetValue("F_SZXY_BoxQty"));//获取输入的箱数

            if (!WhereSql.IsNullOrEmptyOrWhiteSpace())
            {
                long orgid = Convert.ToInt64(orgobj["Id"]);

                string SQL = "/*dialect*/select t1.F_SZXY_MATERIAL,t1.F_SZXY_PLY,t1.F_SZXY_WIDTH,t1.F_SZXY,t1.F_SZXY_MANDREL,T5.F_SZXY_Text '客户订单号', " +
                             "t1.F_SZXY_CUSTID,t1.F_SZXY_PUDNO,t1.F_SZXY_CUSTNO,t1.F_SZXY_CUSTBACTH,t1.F_SZXY_PUDLINENO,T1.F_SZXY_CTNNO,t3.F_SZXY_MOID, " +
                             "t1.F_SZXY_SOSEQ1,t1.F_SZXY_SOENTRYID1,sum(t1.F_SZXY_AREA1) Area , " +
                             "sum(t1.F_SZXY_JQTY)  BOXCount ,T5.F_SZXY_SALER '销售员',T1.F_SZXY_DATE '包装日期',T5.F_SZXY_XSCUST '客户' " +
                             "from SZXY_t_BZDHEntry t1 " +
                             "join SZXY_t_BZD t3 on t1.FID = t3.FID " +
                             "left join T_PRD_MO T4 on T4.FBILLNO = t1.F_SZXY_PUDNO " +
                             "left join T_PRD_MOENTRY T5 on t5.FSEQ = t1.F_SZXY_PUDLINENO " +
                             $" where {WhereSql} " +
                             " group by t1.F_SZXY_MATERIAL,t1.F_SZXY_PLY,t1.F_SZXY_WIDTH,F_SZXY_CTNNO,t1.F_SZXY, " +
                             " t1.F_SZXY_MANDREL,t1.F_SZXY_CUSTID,t1.F_SZXY_PUDNO,t1.F_SZXY_CUSTNO, " +
                             " t1.F_SZXY_CUSTBACTH,t1.F_SZXY_PUDLINENO,t3.F_SZXY_MOID,t1.F_SZXY_SOSEQ1,t1.F_SZXY_SOENTRYID1 " +
                             ",T5.F_SZXY_SALER  ,T5.F_SZXY_SALER ,T5.F_SZXY_TEXT,T1.F_SZXY_DATE,T5.F_SZXY_XSCUST";

                //客户订单号获取客户PO号、日期获取包装日期、业务员、客户
                Logger.Debug("客户回签单", SQL);
                DataSet  fillData = DBServiceHelper.ExecuteDataSet(this.Context, SQL);
                DateTime dt       = DateTime.Now;
                if (fillData != null && fillData.Tables.Count > 0 && fillData.Tables[0].Rows.Count > 0)
                {
                    string value = "";

                    int mm = 0;


                    for (int i = 0; i < fillData.Tables[0].Rows.Count; i++)
                    {
                        mm = erow + i;

                        this.Model.BatchCreateNewEntryRow("F_SZXY_KHHQDEntity", 1);

                        this.View.UpdateView("F_SZXY_KHHQDEntity");

                        this.View.GetControl <EntryGrid>("F_SZXY_KHHQDEntity").SetEnterMoveNextColumnCell(true);

                        this.Model.SetValue("F_SZXY_CBNO1", Convert.ToString(this.Model.GetValue("F_SZXY_CBNO")), mm);

                        this.Model.SetValue("F_SZXY_BoxNo", Convert.ToString(fillData.Tables[0].Rows[i]["F_SZXY_CTNNO"]), mm);



                        IViewService viewService = ServiceHelper.GetService <IViewService>();
                        //物料编码
                        value = Convert.ToString(fillData.Tables[0].Rows[i][0]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            string RMat = Utils.GetRootMatId(value, orgid.ToString(), Context);
                            DynamicObjectCollection entry1          = this.Model.DataObject["SZXY_KHHQDEntry"] as DynamicObjectCollection;
                            DynamicObject           F_SZXY_Material = this.Model.GetValue("F_SZXY_Material", mm) as DynamicObject;
                            Utils.SetBaseDataValue(viewService, entry1[mm], (BaseDataField)this.View.BusinessInfo.GetField("F_SZXY_MATERIAL"), Convert.ToInt64(RMat), ref F_SZXY_Material, Context);
                        }
                        this.View.UpdateView("F_SZXY_Material", mm);

                        //客户代码
                        value = Convert.ToString(fillData.Tables[0].Rows[i]["客户"]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            //this.Model.SetValue("F_SZXY_Cust", value, mm);

                            string CustId = Utils.GetRootCustId(value, orgid.ToString(), Context);
                            this.Model.SetValue("F_SZXY_Cust", CustId, mm);
                            this.View.UpdateView("F_SZXY_Cust", mm);
                        }

                        this.Model.SetValue("F_SZXY_Date", Convert.ToString(fillData.Tables[0].Rows[i]["包装日期"]), mm);

                        value = Convert.ToString(fillData.Tables[0].Rows[i]["销售员"]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            this.Model.SetValue("F_SZXY_salesman", value, mm);
                        }
                        this.View.UpdateView("F_SZXY_salesman", mm);

                        //客户订单号
                        value = Convert.ToString(fillData.Tables[0].Rows[i]["客户订单号"]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            this.Model.SetValue("F_SZXY_CustOrderNo1", value, mm);
                        }


                        //卷数
                        value = Convert.ToString(fillData.Tables[0].Rows[i]["BOXCount"]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            this.Model.SetValue("F_SZXY_volume", value, mm);
                        }


                        //客户批号
                        value = Convert.ToString(fillData.Tables[0].Rows[i]["F_SZXY_CUSTBACTH"]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            this.Model.SetValue("F_SZXY_CustBacthNo", value, mm);
                        }


                        //生产订单编号
                        value = Convert.ToString(fillData.Tables[0].Rows[i]["F_SZXY_PUDNO"]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            this.Model.SetValue("F_SZXY_MONOE", value, mm);
                        }

                        //生产订单行号
                        value = Convert.ToString(fillData.Tables[0].Rows[i]["F_SZXY_PUDLINENO"]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            this.Model.SetValue("F_SZXY_MOLineNOE", value, mm);
                        }


                        //厚度
                        value = Convert.ToString(fillData.Tables[0].Rows[i][1]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            this.Model.SetValue("F_SZXY_Ply", value, mm);
                        }

                        //宽度
                        value = Convert.ToString(fillData.Tables[0].Rows[i][2]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            this.Model.SetValue("F_SZXY_Width", value, mm);
                        }

                        //长度
                        value = Convert.ToString(fillData.Tables[0].Rows[i]["F_SZXY"]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            this.Model.SetValue("F_SZXY_Len", value, mm);
                        }

                        //面积
                        value = Convert.ToString(fillData.Tables[0].Rows[i]["Area"]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            this.Model.SetValue("F_SZXY_Area", value, mm);
                        }



                        if (mm > 0 && (mm % Convert.ToInt32(XQty)) == 0)
                        {
                            string KBNO = GenNo(Context, this.View.BusinessInfo.GetForm().Id, orgobj, Convert.ToDateTime(this.Model.GetValue("FDate")));
                            if (!KBNO.IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_CBNO", KBNO);
                                this.Model.SetValue("F_SZXY_CBNO1", KBNO, mm);    //单据体卡板号
                            }
                        }


                        if (erow == 0 && mm == 0)
                        {
                            string KBNO = GenNo(Context, this.View.BusinessInfo.GetForm().Id, orgobj, Convert.ToDateTime(this.Model.GetValue("FDate")));
                            if (!KBNO.IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_CBNO", KBNO);
                                this.Model.SetValue("F_SZXY_CBNO1", KBNO, erow);
                            }
                        }
                        this.View.SetEntityFocusRow("F_SZXY_KHHQDEntity", mm + 1);
                    }



                    OperateOption saveOption = OperateOption.Create();
                    view.Model.DataObject["FFormID"] = View.BillBusinessInfo.GetForm().Id;
                    var saveResult = BusinessDataServiceHelper.Save(this.View.Context, View.BusinessInfo, view.Model.DataObject, saveOption, "Save");
                    this.View.UpdateView("F_SZXY_KHHQDEntity");
                }
                else
                {
                    this.View.ShowWarnningMessage("没有匹配到数据!"); return;
                }
            }
        }
Пример #26
0
        /// <summary>
        /// 更新修改后的金额
        /// </summary>
        /// <param name="e"></param>
        public override void EndOperationTransaction(EndOperationTransactionArgs e)
        {
            try
            {
                string sql = string.Empty;
                if (e.DataEntitys != null && e.DataEntitys.Count <DynamicObject>() > 0)
                {
                    foreach (DynamicObject item in e.DataEntitys)
                    {
                        HashSet <string> hsset = new HashSet <string>();
                        //财务应收fid
                        string Fid = item["Id"].ToString();
                        //单据类型
                        string FBILLTYPEID = item["BillTypeID_Id"].ToString();
                        //只有财务应收的采用反写
                        #region
                        if (FBILLTYPEID == "5d18aa0e58407c")
                        {
                            string upsql = "";

                            string FSTABLENAME = "";
                            sql = string.Format(@"select ar.FMODIFYDATE as 修改时间,are.FENTRYID as AreFENTRYID,arel.FBASICUNITQTY, arf.FALLAMOUNT as 表头价税合计,arf.FNOTAXAMOUNT as 表头不含税金额 , are.FALLAMOUNTFOR as 表体价税合计,arE.FNOTAXAMOUNTFOR as 表体不含税金额 ,arE.FPRICEQTY as 计价数量 ,arel.FSTABLENAME,arel.FSID
                                                   from t_AR_receivable ar inner join t_AR_receivableEntry arE on ar.FID=arE.FID
                                                   inner join T_AR_RECEIVABLEENTRY_LK arel on arel.FENTRYID=are.FENTRYID
                                                   left join t_AR_receivableFIN  arf on arf.FID=ar.FID  where ar.FID='{0}'", Fid);
                            DataSet   ds = DBServiceHelper.ExecuteDataSet(this.Context, sql);
                            DataTable dt = ds.Tables[0];
                            if (dt.Rows.Count > 0)
                            {
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    string FSID = dt.Rows[i]["FSID"].ToString();
                                    //decimal FALLAMOUNT = Convert.ToDecimal(dt.Rows[i]["表头价税合计"].ToString());
                                    // decimal FNOTAXAMOUNT = Convert.ToDecimal(dt.Rows[i]["表头不含税金额"].ToString());
                                    decimal FALLAMOUNTFOR   = Math.Abs(Convert.ToDecimal(dt.Rows[i]["表体价税合计"].ToString()));
                                    decimal FNOTAXAMOUNTFOR = Math.Abs(Convert.ToDecimal(dt.Rows[i]["表体不含税金额"].ToString()));
                                    decimal FPRICEQTY       = Math.Abs(Convert.ToDecimal(dt.Rows[i]["计价数量"].ToString()));
                                    decimal FBASICUNITQTY   = Math.Abs(Convert.ToDecimal(dt.Rows[i]["FBASICUNITQTY"].ToString()));//暂估基本数量
                                    string  FMODIFYDATE     = dt.Rows[i]["修改时间"].ToString();
                                    if (FPRICEQTY != FBASICUNITQTY)
                                    {
                                        FALLAMOUNTFOR   = FALLAMOUNTFOR * (FBASICUNITQTY / FPRICEQTY);
                                        FNOTAXAMOUNTFOR = FNOTAXAMOUNTFOR * (FBASICUNITQTY / FPRICEQTY);
                                        FPRICEQTY       = FBASICUNITQTY;
                                    }
                                    sql = string.Format(@"select FSID as 销售出库单FENTRYID ,FSBILLID as 销售出库单id,FSTABLENAME 
                                                          from  T_AR_RECEIVABLEENTRY_LK where FENTRYID={0}", FSID);
                                    DataSet   ds2 = DBServiceHelper.ExecuteDataSet(this.Context, sql);
                                    DataTable dt2 = ds2.Tables[0];
                                    if (dt2.Rows.Count > 0)
                                    {
                                        for (int j = 0; j < dt2.Rows.Count; j++)
                                        {
                                            FSTABLENAME = dt2.Rows[j]["FSTABLENAME"].ToString();
                                            if (FSTABLENAME == "T_SAL_OUTSTOCKENTRY")
                                            {
                                                hsset.Add(dt2.Rows[j]["销售出库单id"].ToString());
                                                //销售出库单表体
                                                upsql += string.Format(@"/*dialect*/update T_SAL_OUTSTOCKENTRY set FTotalARFNOTAXAMOUNTFOR=(b.FSALUNITQTY-FARFQty)*b.FPRICE+FARFQty*a.FARFPRICE,
                                                                              FTotalARFALLAMOUNTFOR=(b.FSALUNITQTY-FARFQty)*b.FPRICE+FARFQty*a.FARFPRICE +((b.FSALUNITQTY-FARFQty)*b.FPRICE+FARFQty*a.FARFPRICE)*FTAXRATE/100
                                                                             from T_SAL_OUTSTOCKENTRY a inner join T_SAL_OUTSTOCKENTRY_F b on b.FENTRYID=a.FENTRYID
                                                                             where a.FENTRYID={0}", dt2.Rows[j]["销售出库单FENTRYID"].ToString());
                                            }
                                            else
                                            {
                                                hsset.Add(dt2.Rows[j]["销售出库单id"].ToString());
                                                //销售退货表体
                                                upsql += string.Format(@"/*dialect*/ update T_SAL_RETURNSTOCKENTRY 
                                                                           set FTotalARFNOTAXAMOUNTFOR=(a.FREALQTY-FARFQty)*b.FPRICE+FARFQty*a.FARFPRICE,
                                                                           FTotalARFALLAMOUNTFOR=(a.FREALQTY-FARFQty)*b.FPRICE+FARFQty*a.FARFPRICE +((a.FREALQTY-FARFQty)*b.FPRICE+FARFQty*a.FARFPRICE)*FTAXRATE/100
                                                                           from T_SAL_RETURNSTOCKENTRY a inner join T_SAL_RETURNSTOCKENTRY_F b on b.FENTRYID=a.FENTRYID 
                                                                           where a.FENTRYID={0}", dt2.Rows[j]["销售出库单FENTRYID"].ToString());
                                            }
                                        }
                                    }
                                }
                                //更新销售出库单表体
                                DBServiceHelper.Execute(Context, upsql);
                            }
                            string UpdatesqlH = "";
                            //更新表头
                            foreach (var hs in hsset)
                            {
                                if (FSTABLENAME == "T_SAL_OUTSTOCKENTRY")
                                {
                                    sql = string.Format(@"select sum(FTotalARFNOTAXAMOUNTFOR) as FTotalARFNOTAXAMOUNTFOR_H,
                                            sum(FTotalARFALLAMOUNTFOR) as FTotalARFALLAMOUNTFOR_H  from T_SAL_OUTSTOCKENTRY where FID={0}", hs);

                                    DataSet   ds2 = DBServiceHelper.ExecuteDataSet(this.Context, sql);
                                    DataTable dt2 = ds2.Tables[0];
                                    if (dt2.Rows.Count > 0)
                                    {
                                        for (int j = 0; j < dt2.Rows.Count; j++)
                                        {
                                            decimal FTotalARFNOTAXAMOUNTFOR_H = Convert.ToDecimal(dt2.Rows[j]["FTotalARFNOTAXAMOUNTFOR_H"].ToString());
                                            decimal FTotalARFALLAMOUNTFOR_H   = Convert.ToDecimal(dt2.Rows[j]["FTotalARFALLAMOUNTFOR_H"].ToString());
                                            UpdatesqlH += string.Format(@"/*dialect*/ update T_SAL_OUTSTOCK set FTotalARFNOTAXAMOUNTFOR_H={1},
                                                     FTotalARFALLAMOUNTFOR_H={2} where FID={0}", hs, FTotalARFNOTAXAMOUNTFOR_H, FTotalARFALLAMOUNTFOR_H);
                                        }
                                    }
                                }
                                else
                                {
                                    sql = string.Format(@"select sum(FTotalARFNOTAXAMOUNTFOR) as FTotalARFNOTAXAMOUNTFOR_H,
                                            sum(FTotalARFALLAMOUNTFOR) as FTotalARFALLAMOUNTFOR_H  from T_SAL_RETURNSTOCKENTRY where FID={0}", hs);
                                    DataSet   ds2 = DBServiceHelper.ExecuteDataSet(this.Context, sql);
                                    DataTable dt2 = ds2.Tables[0];
                                    if (dt2.Rows.Count > 0)
                                    {
                                        for (int j = 0; j < dt2.Rows.Count; j++)
                                        {
                                            decimal FTotalARFNOTAXAMOUNTFOR_H = Convert.ToDecimal(dt2.Rows[j]["FTotalARFNOTAXAMOUNTFOR_H"].ToString());
                                            decimal FTotalARFALLAMOUNTFOR_H   = Convert.ToDecimal(dt2.Rows[j]["FTotalARFALLAMOUNTFOR_H"].ToString());
                                            UpdatesqlH += string.Format(@"/*dialect*/ update T_SAL_RETURNSTOCK set FTotalARFNOTAXAMOUNTFOR_H={1},
                                                     FTotalARFALLAMOUNTFOR_H={2} where FID={0}", hs, FTotalARFNOTAXAMOUNTFOR_H, FTotalARFALLAMOUNTFOR_H);
                                        }
                                    }
                                }
                            }
                            //更新销售出库单表头/销售退货单
                            DBServiceHelper.Execute(Context, UpdatesqlH);
                        }
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                throw new KDException("", "审核失败:" + ex.ToString());
            }
        }
        public override void AfterBarItemClick(AfterBarItemClickEventArgs e)
        {
            base.AfterBarItemClick(e);


            //打印按钮事件
            if (e.BarItemKey.EqualsIgnoreCase("SZXY_tbGridPrintNo"))
            {
                this.Model.DataObject["FFormId"] = this.View.BusinessInfo.GetForm().Id;
                Utils.Save(View, new DynamicObject[] { this.Model.DataObject }, Kingdee.BOS.Orm.OperateOption.Create(), Context);

                if (this.Model.GetValue("F_SZXY_OrgId") is DynamicObject OrgObj)
                {
                    long orgid = Convert.ToInt64(OrgObj["Id"]);
                    Utils.TYPrint(this.View, Context, orgid, Convert.ToString(this.Model.DataObject[0]));

                    Logger.Debug("物流快递单打印完毕----------清除已勾选复选框-----:", $"---------");
                    DynamicObjectCollection entry2 = this.Model.DataObject["SZXY_XYWLKDDEntry"] as DynamicObjectCollection;


                    bool flag29 = entry2 != null;
                    if (flag29)
                    {
                        foreach (DynamicObject item in from ck in entry2
                                 where Convert.ToString(ck["F_SZXY_Print"]).EqualsIgnoreCase("true")
                                 select ck)
                        {
                            item["F_SZXY_Print"] = "false";
                        }
                    }
                    this.View.UpdateView();
                }
            }



            if (e.BarItemKey.EqualsIgnoreCase("SZXY_tbGetReBackInfo"))
            {
                DynamicObject BillDO = this.Model.DataObject;
                if (BillDO["F_SZXY_OrgId"] is DynamicObject OrdDO)
                {
                    string OrgId = OrdDO["ID"].ToString();

                    if (BillDO["SZXY_XYWLKDDEntry"] is DynamicObjectCollection entry)
                    {
                        foreach (DynamicObject Row in entry)
                        {
                            string MoNo     = Row["F_SZXY_PTNo"].ToString();
                            string MoLineNo = Row["F_SZXY_MOSEQ"].ToString();
                            if (!MoNo.IsNullOrEmptyOrWhiteSpace() && !MoLineNo.IsNullOrEmptyOrWhiteSpace())
                            {
                                string SelSql = "/*dialect*/select count(T1.F_SZXY_BoxNo), isnull(sum(T1.F_SZXY_volume),0) ,ISNULL( sum(T1.F_SZXY_Area),0) ,T2.FBILLNO " +
                                                "from SZXY_t_KHHQDEntry T1 " +
                                                "left  join SZXY_t_KHHQD T2 on T1.FID = T2.FID " +
                                                $"where T1.F_SZXY_MoNOE = '{MoNo}' and T1.F_SZXY_MOLINENOE = '{MoLineNo}' and T2.F_SZXY_ORGID = '{OrgId}'" +
                                                $" group by T2.FBILLNO ";

                                using (DataSet fillData = DBServiceHelper.ExecuteDataSet(this.Context, SelSql))
                                {
                                    if (fillData != null && fillData.Tables.Count > 0 && fillData.Tables[0].Rows.Count > 0)
                                    {
                                        Row["F_SZXY_XS"]          = fillData.Tables[0].Rows[0][0];
                                        Row["F_SZXY_JS"]          = fillData.Tables[0].Rows[0][1];
                                        Row["F_SZXY_MJ"]          = fillData.Tables[0].Rows[0][2];
                                        Row["F_SZXY_SIGNATURENO"] = fillData.Tables[0].Rows[0][3];
                                    }
                                };
                            }
                        }
                    }
                    this.View.UpdateView("F_SZXY_XYWLKDDEntity");
                }
            }
        }
Пример #28
0
        public override void BeginOperationTransaction(BeginOperationTransactionArgs e)
        {
            try
            {
                string sql = string.Empty;
                if (e.DataEntitys != null && e.DataEntitys.Count <DynamicObject>() > 0)
                {
                    foreach (DynamicObject item in e.DataEntitys)
                    {
                        //财务应收fid
                        string Fid = item["Id"].ToString();
                        //单据类型
                        string FBILLTYPEID = item["BillTypeID_Id"].ToString();
                        //只有财务应收的采用反写
                        #region
                        if (FBILLTYPEID == "5d18aa0e58407c")
                        {
                            string upsql      = "";
                            string UpdatesqlH = "";
                            sql = string.Format(@"select are.FORDERENTRYID as FORDERENTRYID,ar.FMODIFYDATE as 修改时间,ar.F_YBG_CheckBox,arE.FTAXPRICE as  含税单价,arE.FPRICE as 不含税单价,
                                                  are.FENTRYID as AreFENTRYID,arel.FBASICUNITQTY, arf.FALLAMOUNT as 表头价税合计,
                                                  arf.FNOTAXAMOUNT as 表头不含税金额 , are.FALLAMOUNTFOR as 表体价税合计,are.FIsModifyPrice,
                                                  arE.FNOTAXAMOUNTFOR as 表体不含税金额 ,arE.FPRICEQTY as 计价数量 ,arel.FSTABLENAME,arel.FSID
                                                   from t_AR_receivable ar inner join t_AR_receivableEntry arE on ar.FID=arE.FID
                                                   inner join T_AR_RECEIVABLEENTRY_LK arel on arel.FENTRYID=are.FENTRYID
                                                   left join t_AR_receivableFIN  arf on arf.FID=ar.FID  where ar.FID='{0}'", Fid);
                            DataSet   ds = DBServiceHelper.ExecuteDataSet(this.Context, sql);
                            DataTable dt = ds.Tables[0];
                            if (dt.Rows.Count > 0)
                            {
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    string FORDERENTRYID = dt.Rows[i]["FORDERENTRYID"].ToString();
                                    string FSID          = dt.Rows[i]["FSID"].ToString();
                                    //是否修改了单价
                                    string FIsModifyPrice = dt.Rows[i]["FIsModifyPrice"].ToString();
                                    //decimal FALLAMOUNT = Convert.ToDecimal(dt.Rows[i]["表头价税合计"].ToString());
                                    // decimal FNOTAXAMOUNT = Convert.ToDecimal(dt.Rows[i]["表头不含税金额"].ToString());
                                    decimal FALLAMOUNTFOR   = Math.Abs(Convert.ToDecimal(dt.Rows[i]["表体价税合计"].ToString()));
                                    decimal FNOTAXAMOUNTFOR = Math.Abs(Convert.ToDecimal(dt.Rows[i]["表体不含税金额"].ToString()));
                                    decimal FPRICEQTY       = Math.Abs(Convert.ToDecimal(dt.Rows[i]["计价数量"].ToString()));
                                    decimal FBASICUNITQTY   = Math.Abs(Convert.ToDecimal(dt.Rows[i]["FBASICUNITQTY"].ToString())); //暂估基本数量、
                                    decimal FTAXPRICE       = Math.Abs(Convert.ToDecimal(dt.Rows[i]["含税单价"].ToString()));          //含税单价
                                    decimal FPRICE          = Math.Abs(Convert.ToDecimal(dt.Rows[i]["不含税单价"].ToString()));         //不含税单价
                                    string  FMODIFYDATE     = dt.Rows[i]["修改时间"].ToString();
                                    //string F_YBG_CheckBox= dt.Rows[i]["F_YBG_CheckBox"].ToString();
                                    if (FPRICEQTY != FBASICUNITQTY)
                                    {
                                        FALLAMOUNTFOR   = FALLAMOUNTFOR * (FBASICUNITQTY / FPRICEQTY);
                                        FNOTAXAMOUNTFOR = FNOTAXAMOUNTFOR * (FBASICUNITQTY / FPRICEQTY);
                                        FPRICEQTY       = FBASICUNITQTY;
                                    }
                                    //更新暂估应收
                                    upsql += string.Format(@"/*dialect*/ update t_AR_receivableEntry set FIsLockPrice=1  where FENTRYID ='{0}'", FSID);

                                    string FSTABLENAME = "";
                                    sql = string.Format(@"select FSID as 销售出库单FENTRYID ,FSBILLID as 销售出库单id,FSTABLENAME 
                                                          from  T_AR_RECEIVABLEENTRY_LK where FENTRYID={0}", FSID);
                                    DataSet   ds2 = DBServiceHelper.ExecuteDataSet(this.Context, sql);
                                    DataTable dt2 = ds2.Tables[0];
                                    if (dt2.Rows.Count > 0)
                                    {
                                        for (int j = 0; j < dt2.Rows.Count; j++)
                                        {
                                            FSTABLENAME = dt2.Rows[j]["FSTABLENAME"].ToString();
                                            if (FSTABLENAME == "T_SAL_OUTSTOCKENTRY")
                                            {
                                                //销售出库单表头
                                                UpdatesqlH += string.Format(@"/*dialect*/ update T_SAL_OUTSTOCK set FARFNOTAXAMOUNTFOR_H=FARFNOTAXAMOUNTFOR_H+{1},FARFALLAMOUNTFOR_H=FARFALLAMOUNTFOR_H+{2},FARFMODIFYDATE='{3}'   
                                                                                   from  T_SAL_OUTSTOCK a inner join T_SAL_OUTSTOCKENTRY_R b on a.FID=b.FID where a.FID ='{0}' and FSOENTRYID='{4}'", dt2.Rows[j]["销售出库单id"].ToString(), FNOTAXAMOUNTFOR, FALLAMOUNTFOR, FMODIFYDATE, FORDERENTRYID);
                                                //销售出库单表体
                                                upsql += string.Format(@"/*dialect*/ update T_SAL_OUTSTOCKENTRY set FARFNOTAXAMOUNTFOR=FARFNOTAXAMOUNTFOR+{1},FARFALLAMOUNTFOR=FARFALLAMOUNTFOR+{2} ,FARFQty=FARFQty+{3},FARFTAXPRICE={4},FIsModifyPrice={5},FARFPRICE={6}  
                                                                             from  T_SAL_OUTSTOCKENTRY a inner join T_SAL_OUTSTOCKENTRY_R b on a.FID=b.FID where a.FENTRYID ='{0}'and FSOENTRYID='{7}'", dt2.Rows[j]["销售出库单FENTRYID"].ToString(), FNOTAXAMOUNTFOR, FALLAMOUNTFOR, FPRICEQTY, FTAXPRICE, FIsModifyPrice, FPRICE, FORDERENTRYID);
                                            }
                                            else
                                            {
                                                //销售退货单表头
                                                UpdatesqlH += string.Format(@"/*dialect*/ update T_SAL_RETURNSTOCK set FARFNOTAXAMOUNTFOR_H=FARFNOTAXAMOUNTFOR_H+{1},FARFALLAMOUNTFOR_H=FARFALLAMOUNTFOR_H+{2},FARFMODIFYDATE='{3}'     
                                                                           from  T_SAL_RETURNSTOCK a inner join T_SAL_RETURNSTOCKENTRY b on a.FID=b.FID  
                                                                          where a.FID ='{0}'and FSOENTRYID='{4}'", dt2.Rows[j]["销售出库单id"].ToString(), FNOTAXAMOUNTFOR, FALLAMOUNTFOR, FMODIFYDATE, FORDERENTRYID);
                                                //销售退货表体
                                                upsql += string.Format(@"/*dialect*/ update T_SAL_RETURNSTOCKENTRY set FARFNOTAXAMOUNTFOR=FARFNOTAXAMOUNTFOR+{1},FARFALLAMOUNTFOR=FARFALLAMOUNTFOR+{2} ,FARFQty=FARFQty+{3},FARFTAXPRICE={5},FIsModifyPrice={6},FARFPRICE={7}    
                                                                               where FENTRYID ='{0}'and FSOENTRYID='{4}'", dt2.Rows[j]["销售出库单FENTRYID"].ToString(), FNOTAXAMOUNTFOR, FALLAMOUNTFOR, FPRICEQTY, FORDERENTRYID, FTAXPRICE, FIsModifyPrice, FPRICE);
                                            }
                                        }
                                    }
                                }
                                //更新销售出库单表头
                                DBServiceHelper.Execute(Context, UpdatesqlH);
                                //更新销售出库单表体
                                DBServiceHelper.Execute(Context, upsql);
                            }
                        }
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                throw new KDException("", "审核失败:" + ex.ToString());
            }
        }
        public override void AfterConvert(AfterConvertEventArgs e)
        {
            base.AfterConvert(e);

            //获取整个下推的数据
            var dataObjs = e.Result.FindByEntityKey("FBillHead");

            if (dataObjs != null)
            {
                foreach (var extendedDataEntity in dataObjs)
                {
                    DynamicObjectCollection EntryCollect = null;

                    DynamicObject BillObject = extendedDataEntity.DataEntity;

                    //生产入库单明细
                    EntryCollect = extendedDataEntity.DataEntity["Entity"] as DynamicObjectCollection;

                    Entity entity2 = e.TargetBusinessInfo.GetEntity("FEntity_Link");

                    if (EntryCollect != null && EntryCollect.Count > 0)
                    {
                        foreach (DynamicObject row in EntryCollect)
                        {
                            string fmoent = "";
                            string sql    = "select FENTRYID   FROM T_PRD_MOENTRY  where FID= "
                                            + row["MoId"]
                                            + "and  FSEQ= "
                                            + row["MoEntrySeq"];                                  //sql拼接
                            DataSet sqltable = DBServiceHelper.ExecuteDataSet(this.Context, sql); //放入DataSet
                            if (sqltable != null && sqltable.Tables.Count > 0 && sqltable.Tables[0].Rows.Count > 0)
                            {
                                fmoent = sqltable.Tables[0].Rows[0][0].ToString();
                            }

                            //源单类型
                            row["SrcBillType"] = "PRD_MO";
                            //源单编号
                            row["SrcBillNo"] = row["MoBillNo"];
                            //源单内码
                            row["SrcInterId"] = row["MoId"];
                            //源单分录内码
                            row["SrcEntryId"] = fmoent;
                            //源单行号
                            row["SrcEntrySeq"] = row["MoEntrySeq"];

                            DynamicObjectCollection linkCollect = row["FEntity_Link"] as DynamicObjectCollection;

                            linkCollect[0]["RuleId"] = "PRD_MO2INSTOCK";//PRD_INSTOCK

                            linkCollect[0]["STableName"] = "T_PRD_MOENTRY";

                            linkCollect[0]["SBillId"] = row["MoId"];

                            //生产订单分录内码
                            linkCollect[0]["SId"] = fmoent;
                        }
                    }
                }
            }
        }
Пример #30
0
        public override void AfterBarItemClick(AfterBarItemClickEventArgs e)
        {
            base.AfterBarItemClick(e);

            if (e.BarItemKey.EqualsIgnoreCase("SZXY_tbGridPrintNo"))
            {
                this.Model.DataObject["FFormId"] = this.View.BusinessInfo.GetForm().Id;
                Utils.Save(View, new DynamicObject[] { this.Model.DataObject }, Kingdee.BOS.Orm.OperateOption.Create(), Context);


                string F_SZXY_ForLabel = Convert.ToString(this.Model.GetValue("F_SZXY_ForLabel"));//补打标签


                if (this.Model.GetValue("F_SZXY_OrgId") is DynamicObject OrgObj && !F_SZXY_ForLabel.IsNullOrEmptyOrWhiteSpace())
                {
                    long orgid = Convert.ToInt64(OrgObj["Id"]);

                    //如果输入的是箱号
                    string SelSql = $"/*dialect*/select  T1.F_SZXY_BOXNOE from SZXY_t_XYDCJXXBEntry T1 left join SZXY_t_XYDCJXXB  T2  on t1.fid=T2.fid " +

                                    $"where  T1.F_SZXY_BOXNOE='{F_SZXY_ForLabel}'" +
                                    $" group by  T1.F_SZXY_BOXNOE";

                    DataSet SelSqlds = DBServiceHelper.ExecuteDataSet(this.Context, SelSql);

                    if (SelSqlds.Tables[0].Rows.Count > 0 && SelSqlds != null && SelSqlds.Tables.Count > 0)
                    {
                    }
                    else
                    {
                        this.View.ShowWarnningMessage("没有找到此箱号的信息");
                        return;
                    }

                    string MacInfo = Utils.GetMacAddress();
                    Logger.Debug("当前MAC地址", MacInfo);


                    DataSet PrintModelDS = null;
                    int     ckb          = 0;
                    orgid = Convert.ToInt64(OrgObj["Id"]);


                    //是否指定标签模板
                    string PJSQL = " ";

                    DynamicObject PrintTemp = this.Model.GetValue("F_SZXY_Tagtype") as DynamicObject;

                    if (PrintTemp != null)
                    {
                        string PId = Convert.ToString(PrintTemp["Id"]);

                        if (!PId.IsNullOrEmptyOrWhiteSpace())
                        {
                            PJSQL = $" and T1.Fid={PId} ";
                        }
                    }


                    if (!MacInfo.IsNullOrEmptyOrWhiteSpace())
                    {
                        PrintModelDS = getPrintModel(this.View, Context, PJSQL, orgid.ToString(), MacInfo, F_SZXY_ForLabel, ref ckb);

                        if (PrintModelDS != null)
                        {
                            XYStraddleCut.Print(PrintModelDS, ckb, Context, this.View, $"'{F_SZXY_ForLabel}'", "XH");
                        }
                        else
                        {
                            View.ShowWarnningMessage("没有匹配到模板!");
                            return;
                        }

                        Logger.Debug($" 箱号匹配到:{SelSqlds.Tables[0].Rows.Count}条数据。", "");
                    }
                }
            }
        }