/// <summary>
        /// 读取第三方物料信息,存入K/3 Cloud物料
        /// </summary>
        private void ImportMaterial()
        {
            // 构建一个IBillView实例,通过此实例,可以方便的填写物料各属性
            IBillView billView = this.CreateMaterialView();

            // 新建一个空白物料
            // billView.CreateNewModelData();
            ((IBillViewService)billView).LoadData();


            // 触发插件的OnLoad事件:
            // 组织控制基类插件,在OnLoad事件中,对主业务组织改变是否提示选项进行初始化。
            // 如果不触发OnLoad事件,会导致主业务组织赋值不成功
            DynamicFormViewPlugInProxy eventProxy = billView.GetService <DynamicFormViewPlugInProxy>();

            eventProxy.FireOnLoad();


            // 记载指定的单据进行修改
            // this.ModifyBill(billView, "100001"); // 本代码演示新建物料,把调用修改的代码,注释掉

            // 填写物料各属性
            this.FillMaterialPropertys(billView);
            // 保存物料
            OperateOption saveOption = OperateOption.Create();

            this.SaveMaterial(billView, saveOption);
        }
        private void SaveCheckBill(IBillView billView, OperateOption saveOption)
        {
            // 设置FormId
            Form form = billView.BillBusinessInfo.GetForm();

            if (form.FormIdDynamicProperty != null)
            {
                form.FormIdDynamicProperty.SetValue(billView.Model.DataObject, form.Id);
            }

            // 调用保存操作
            IOperationResult saveResult = BusinessDataServiceHelper.Save(this.Context, billView.BillBusinessInfo, billView.Model.DataObject, saveOption, "Save");

            if (saveResult.IsSuccess)
            {
                object[] primaryKeys = saveResult.SuccessDataEnity.Select(u => u.GetPrimaryKeyValue()).ToArray();

                // 提交
                OperateOption    submitOption = OperateOption.Create();
                IOperationResult submitResult = BusinessDataServiceHelper.Submit(this.Context, billView.BillBusinessInfo, primaryKeys, "Submit", submitOption);
                if (submitResult.IsSuccess)
                {
                    // 审核
                    OperateOption    auditOption = OperateOption.Create();
                    IOperationResult auditResult = BusinessDataServiceHelper.Audit(this.Context, billView.BillBusinessInfo, primaryKeys, auditOption);
                }
            }
        }
Esempio n. 3
0
        public static IBillView AddNew(this IBillView billView)
        {
            billView.OpenParameter.Status  = OperationStatus.ADDNEW;
            billView.OpenParameter.PkValue = null;

            //新建一个空白数据
            billView.CreateNewModelData();
            ((IBillViewService)billView).LoadData();

            // 触发插件的OnLoad事件:
            // 组织控制基类插件,在OnLoad事件中,对主业务组织改变是否提示选项进行初始化。
            // 如果不触发OnLoad事件,会导致主业务组织赋值不成功
            DynamicFormViewPlugInProxy eventProxy = billView.GetService <DynamicFormViewPlugInProxy>();

            eventProxy.FireOnLoad();

            //设置FormId
            Form form = billView.BillBusinessInfo.GetForm();

            if (form.FormIdDynamicProperty != null)
            {
                form.FormIdDynamicProperty.SetValue(billView.Model.DataObject, form.Id);
            }//end if

            return(billView);
        }
Esempio n. 4
0
        private void FillBillPropertys(IBillView billView, String orderBillNo, long materialId, String unit, double rate)
        {
            IDynamicFormViewService dynamicFormView = billView as IDynamicFormViewService;

            // 物料编码
            dynamicFormView.SetItemValueByID("FMaterialNumber", materialId, 0);
            // 销售订单号
            dynamicFormView.UpdateValue("FOrderNo", 0, orderBillNo);
            // 目标计量单位
            StringBuilder tmpSQL3 = new StringBuilder();

            if (unit.Equals("平方米"))
            {
                tmpSQL3.AppendFormat(@"/*dialect*/ SELECT TOP 1 FUNITID FROM T_BD_UNIT_L WHERE FNAME = '平方米' AND FUNITID = 108176 ");
            }
            if (unit.Equals("张"))
            {
                tmpSQL3.AppendFormat(@"/*dialect*/ SELECT TOP 1 FUNITID FROM T_BD_UNIT_L WHERE FNAME = '张' ");
            }
            if (unit.Equals("个"))
            {
                tmpSQL3.AppendFormat(@"/*dialect*/ SELECT TOP 1 FUNITID FROM T_BD_UNIT_L WHERE FNAME = '个' ");
            }
            DynamicObjectCollection col3 = DBUtils.ExecuteDynamicObject(this.Context, tmpSQL3.ToString());

            if (col3 != null && col3.Count > 0)
            {
                dynamicFormView.SetItemValueByID("FUnitID", Convert.ToInt64(col3[0]["FUNITID"]), 0);
            }

            // 目标单位数量
            dynamicFormView.UpdateValue("FQty", 0, rate);
        }
 /// <summary>
 /// 加载指定的单据进行修改
 /// </summary>
 /// <param name="billView"></param>
 /// <param name="pkValue"></param>
 private void ModifyBill(IBillView billView, string pkValue)
 {
     billView.OpenParameter.Status            = OperationStatus.EDIT;
     billView.OpenParameter.CreateFrom        = CreateFrom.Default;
     billView.OpenParameter.PkValue           = pkValue;
     billView.OpenParameter.DefaultBillTypeId = string.Empty;
     ((IDynamicFormViewService)billView).LoadData();
 }
Esempio n. 6
0
 private void FillFormPropertys(IBillView billView)
 {
     billView.Model.SetValue("FBillNo", DateTime.Now.ToString("yyyyMMddHHmmssss"), 0);
     billView.Model.SetValue("F_PAE_Text", "普通", 0);
     billView.Model.SetItemValueByNumber("F_PAE_Base1", "PRE001", 0);
     billView.Model.SetItemValueByNumber("F_PAE_Base", "CH4441", 0);
     billView.Model.SetValue("F_PAE_Text1", "普通", 0);
 }
Esempio n. 7
0
        //数据同步
        public void dataSync(DynamicObject obj)
        {
            IBillView billView = this.CreateBillView(this.Context);

            ((IBillViewService)billView).LoadData();
            DynamicFormViewPlugInProxy eventProxy = billView.GetService <DynamicFormViewPlugInProxy>();

            eventProxy.FireOnLoad();
            this.FillBillPropertys(this.Context, billView, obj);
            IOperationResult saveResult = null;

            object[]         primaryKeys = null;
            IOperationResult auditResult = null;

            if (this.FormOperation.Operation.Equals("Save"))//保存
            {
                if (isExsit(Convert.ToInt64(obj["Id"])))
                {
                    updateAssistData(Convert.ToInt64(obj["Id"]), Convert.ToString(obj["Number"]), Convert.ToString(obj["Name"]));  //存在则修改
                }
                else  //不存则新增
                      // 调用保存操作
                {
                    OperateOption saveOption = OperateOption.Create();
                    // 调用保存操作
                    saveResult = BusinessDataServiceHelper.Save(this.Context, billView.BillBusinessInfo, billView.Model.DataObject, saveOption, "Save");
                }
            }
            else if (this.FormOperation.Operation.Equals("Submit"))//提交
            {
                updateAssistDataStatus(Convert.ToInt64(obj["Id"]), "B");
            }
            else if (this.FormOperation.Operation.Equals("Audit"))//审核
            {
                updateAssistDataStatus(Convert.ToInt64(obj["Id"]), "C");
            }
            else if (this.FormOperation.Operation.Equals("UnAudit"))          //反审核
            {
                if (getExsitOldData(Convert.ToString(obj["Number"])) != null) //判断辅助资料表是否有对应的老数据
                {
                    DynamicObject oo = getExsitOldData(Convert.ToString(obj["Number"]));
                    updateAssistDataOld(Convert.ToString(oo["fentryid"]), Convert.ToString(obj["Number"]));//如果存在则把外键编码字段关联上
                }
                updateAssistDataStatus(Convert.ToInt64(obj["Id"]), "D");
            }
            else if (this.FormOperation.Operation.Equals("Forbid"))//禁用
            {
                updateAssistForbidStatus(Convert.ToInt64(obj["Id"]), "B");
            }
            else if (this.FormOperation.Operation.Equals("Enable"))//反禁用
            {
                updateAssistForbidStatus(Convert.ToInt64(obj["Id"]), "A");
            }
            else if (this.FormOperation.Operation.Equals("Delete"))//删除
            {
                deleteData(Convert.ToInt64(obj["Id"]));
            }
        }
Esempio n. 8
0
        public BillController(IBillRepository repository, IBillView view)
        {
            this.repository = repository;
            this.view       = view;

            view.BillSave += delegate(object sender, BillEventArgs e) {
                Add(e.Bill);
            };
        }
Esempio n. 9
0
        private void FillBillPropertys(Kingdee.BOS.Context ctx, IBillView billView, DynamicObject obj)
        {
            IDynamicFormViewService dynamicFormView = billView as IDynamicFormViewService;

            dynamicFormView.UpdateValue("FId", 0, dataType);
            dynamicFormView.UpdateValue("F_PAEZ_Number", 0, Convert.ToString(obj["Id"]));//用于关联辅助资料表记录
            dynamicFormView.UpdateValue("FNumber", 0, Convert.ToString(obj["Number"]));
            dynamicFormView.UpdateValue("FDataValue", 0, Convert.ToString(obj["Name"]));
        }
Esempio n. 10
0
        public static IBillView Edit(this IBillView billView, DynamicObject dataObject)
        {
            billView.OpenParameter.Status  = OperationStatus.EDIT;
            billView.OpenParameter.PkValue = dataObject.PkId <string>();

            billView.Model.DataChanged = false;
            billView.Model.DataObject  = dataObject;

            return(billView);
        }
Esempio n. 11
0
        public static IBillView AddNew(this IBillView billView, DynamicObject dataObject)
        {
            billView.OpenParameter.Status  = OperationStatus.ADDNEW;
            billView.OpenParameter.PkValue = null;

            billView.Model.DataChanged = false;
            billView.Model.DataObject  = dataObject;

            return(billView);
        }
Esempio n. 12
0
        private void SaveBillInfo()
        {
            IBillView billView = this.CreateBillView();

            ((IBillViewService)billView).LoadData();
            this.FillFormPropertys(billView);
            OperateOption saveOption = OperateOption.Create();

            this.SaveFormData(billView, saveOption);
        }
Esempio n. 13
0
        public DynamicObject installCostRequestPackage(Context ctx, string FormID, Action <IDynamicFormViewService> fillBillPropertys, string BillTypeId = "")
        {
            //IMetaDataService metaService = ServiceHelper.GetService<IMetaDataService>();//元数据服务
            //FormMetadata Meta = metaService.Load(ctx, FormID) as FormMetadata;//获取元数据
            FormMetadata            Meta = MetaDataServiceHelper.Load(ctx, FormID) as FormMetadata;//获取元数据
            Form                    form = Meta.BusinessInfo.GetForm();
            IDynamicFormViewService dynamicFormViewService = (IDynamicFormViewService)Activator.CreateInstance(Type.GetType("Kingdee.BOS.Web.Import.ImportBillView,Kingdee.BOS.Web"));
            // 创建视图加载参数对象,指定各种参数,如FormId, 视图(LayoutId)等
            BillOpenParameter openParam = new BillOpenParameter(form.Id, Meta.GetLayoutInfo().Id);

            openParam.Context      = ctx;
            openParam.ServiceName  = form.FormServiceName;
            openParam.PageId       = Guid.NewGuid().ToString();
            openParam.FormMetaData = Meta;
            openParam.Status       = OperationStatus.ADDNEW;
            openParam.CreateFrom   = CreateFrom.Default;
            // 单据类型
            openParam.DefaultBillTypeId = BillTypeId;
            openParam.SetCustomParameter("ShowConfirmDialogWhenChangeOrg", false);
            // 插件
            List <AbstractDynamicFormPlugIn> plugs = form.CreateFormPlugIns();

            openParam.SetCustomParameter(FormConst.PlugIns, plugs);
            PreOpenFormEventArgs args = new PreOpenFormEventArgs(ctx, openParam);

            foreach (var plug in plugs)
            {
                plug.PreOpenForm(args);
            }
            // 动态领域模型服务提供类,通过此类,构建MVC实例
            IResourceServiceProvider provider = form.GetFormServiceProvider(false);

            dynamicFormViewService.Initialize(openParam, provider);
            IBillView billView = dynamicFormViewService as IBillView;

            ((IBillViewService)billView).LoadData();

            // 触发插件的OnLoad事件:
            // 组织控制基类插件,在OnLoad事件中,对主业务组织改变是否提示选项进行初始化。
            // 如果不触发OnLoad事件,会导致主业务组织赋值不成功
            DynamicFormViewPlugInProxy eventProxy = billView.GetService <DynamicFormViewPlugInProxy>();

            eventProxy.FireOnLoad();
            if (fillBillPropertys != null)
            {
                fillBillPropertys(dynamicFormViewService);
            }
            // 设置FormId
            form = billView.BillBusinessInfo.GetForm();
            if (form.FormIdDynamicProperty != null)
            {
                form.FormIdDynamicProperty.SetValue(billView.Model.DataObject, form.Id);
            }
            return(billView.Model.DataObject);
        }
        // 物料动态换算新增单据
        private void createNewConvertBill(String lotNo, long materialId, String unit, double rate)
        {
            IBillView billView = this.CreateBillView();

            ((IBillViewService)billView).LoadData();
            DynamicFormViewPlugInProxy eventProxy = billView.GetService <DynamicFormViewPlugInProxy>();

            eventProxy.FireOnLoad();
            this.FillBillPropertys(billView, lotNo, materialId, unit, rate);
            OperateOption saveOption = OperateOption.Create();

            this.SaveCheckBill(billView, saveOption);
        }
        /// <summary>
        /// 保存物料,并显示保存结果
        /// </summary>
        /// <param name="billView"></param>
        /// <returns></returns>
        private void SaveMaterial(IBillView billView, OperateOption saveOption)
        {
            // 设置FormId
            Form form = billView.BillBusinessInfo.GetForm();

            if (form.FormIdDynamicProperty != null)
            {
                form.FormIdDynamicProperty.SetValue(billView.Model.DataObject, form.Id);
            }

            // 调用保存操作
            IOperationResult saveResult = BusinessDataServiceHelper.Save(
                this.Context,
                billView.BillBusinessInfo,
                billView.Model.DataObject,
                saveOption,
                "Save");

            // 显示处理结果
            if (saveResult == null)
            {
                this.View.ShowErrMessage("未知原因导致保存物料失败!");
                return;
            }
            else if (saveResult.IsSuccess == true)
            {// 保存成功,直接显示
                this.View.ShowOperateResult(saveResult.OperateResult);
                return;
            }
            else if (saveResult.InteractionContext != null &&
                     saveResult.InteractionContext.Option.GetInteractionFlag().Count > 0)
            {// 保存失败,需要用户确认问题
                InteractionUtil.DoInteraction(this.View, saveResult, saveOption,
                                              new Action <FormResult, IInteractionResult, OperateOption>((
                                                                                                             formResult, opResult, option) =>
                {
                    // 用户确认完毕,重新调用保存处理
                    this.SaveMaterial(billView, option);
                }));
            }
            // 保存失败,显示错误信息
            if (saveResult.IsShowMessage)
            {
                saveResult.MergeValidateErrors();
                this.View.ShowOperateResult(saveResult.OperateResult);
                return;
            }
        }
Esempio n. 16
0
        public static IBillView Edit(this IBillView billView, object id)
        {
            billView.OpenParameter.Status  = OperationStatus.EDIT;
            billView.OpenParameter.PkValue = id;
            ((IDynamicFormViewService)billView).LoadData();

            //设置FormId
            Form form = billView.BillBusinessInfo.GetForm();

            if (form.FormIdDynamicProperty != null)
            {
                form.FormIdDynamicProperty.SetValue(billView.Model.DataObject, form.Id);
            }//end if

            return(billView);
        }
Esempio n. 17
0
        /// <summary>
        /// 调用打印
        /// </summary>
        /// <param name="套打模板dataset"></param>
        /// <param name="0 OR 1 0代表打印,1代表预览打印"></param>
        /// <param name="Context"></param>
        /// <param name="View"></param>
        /// <param name="Mac地址"></param>
        /// <param name="Fid"></param>
        public static void Print(DataSet ds, int v, Context Context, IBillView View, string MacInfo = "", string Fid = "")
        {
            Logger.Debug("打印---", "------------BEGIN------------------");
            string PKFid = "";

            if (!Convert.ToString(View.Model.GetPKValue()).IsNullOrEmptyOrWhiteSpace())
            {
                PKFid = Convert.ToString(View.Model.GetPKValue());
            }
            else
            {
                PKFid = Fid;
            }
            Logger.Debug("打印Fid---", $"-------{PKFid}-----");
            #region
            if (PKFid != "")
            {
                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)
                    {
                        string QSQL = Convert.ToString(Row[6]);
                        //System.Text.RegularExpressions.Regex.Replace(Convert.ToString(Row[6]), @"[^0-9]+", "");
                        if (View.BusinessInfo.GetForm().Id == "SAL_OUTSTOCK")
                        {
                            QSQL = Convert.ToString(Row[6]).Replace("@Fid@", $" XYFID={PKFid} {FListSQL} ");
                        }
                        else
                        {
                            QSQL = $"{Convert.ToString(Row[6])}{PKFid} {FListSQL}";
                        }

                        // 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]),

                            ConnString = Convert.ToString(Row[5]),
                            // QuerySQL = $"/*dialect*/{Convert.ToString(Row[6])}{PKFid} {FListSQL}"
                            QuerySQL = QSQL
                        };
                        //string SelIsNull = $"/*dialect*/{Convert.ToString(Row[6])}{PKFid} {FListSQL}";
                        Logger.Debug("查询是否存在数据SQL:", QSQL);
                        DataSet SelNullDS = DBServiceHelper.ExecuteDataSet(Context, $"/*dialect*/{Convert.ToString(Row[6])}{PKFid} {FListSQL}");

                        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);
                            }
                            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);
                }



                //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])}{PKFid} {FListSQL}"
                //                //QuerySQL = $"{Convert.ToString(Row[6])}{View.Model.GetPKValue()} {FListSQL}"

                //            };
                //            string SelIsNull = $"{Convert.ToString(Row[6])}{PKFid} {FListSQL}";
                //            Logger.Debug("查询是否存在数据SQL:", $"{Convert.ToString(Row[6])} {PKFid} {FListSQL}");
                //            DataSet SelNullDS = DBServiceHelper.ExecuteDataSet(Context, SelIsNull);

                //            if (SelNullDS != null && SelNullDS.Tables.Count > 0 && SelNullDS.Tables[0].Rows.Count > 0)
                //            {
                //                listData.Add(ReportModel);
                //            }
                //            Logger.Debug("最终预览打印查询SQL:", $"{Convert.ToString(Row[6])} {PKFid} {FListSQL}");
                //        }
                //    }
                //    string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(listData);

                //    Logger.Debug("配置JSON", strJson);
                //    if (!strJson.IsNullOrEmptyOrWhiteSpace())
                //    {
                //        //调用打印
                //        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 (!linkUrl.IsNullOrEmptyOrWhiteSpace()) View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Print " + strJson);

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

                //}
            }

            #endregion
            Logger.Debug("打印---", "---------------END------------------");
        }
Esempio n. 18
0
 /// <summary>
 /// 转为动态表单服务内部服务,为字段赋值时建议使用该对象。
 /// </summary>
 /// <param name="billView">单据服务。</param>
 /// <returns>返回动态表单内部服务。</returns>
 public static IDynamicFormViewService AsDynamicFormViewService(this IBillView billView)
 {
     return(billView as IDynamicFormViewService);
 }
        /// <summary>
        /// 分切打印
        /// </summary>
        /// <param name="View"></param>
        /// <param name="Context"></param>
        /// <param name="指定标签模板"></param>
        /// <param name="orgid"></param>
        /// <param name="MacInfo"></param>
        /// <param name="客户"></param>
        /// <param name="物料名"></param>
        /// <param name="条码或者生产订单号+行号的值"></param>
        /// <param name="条码或者生产订单号+行号的类型"></param>
        /// <param name=""></param>
        public static DataSet getPrintModel(IBillView View, Context Context, string ZDPrintModel, string orgid, string MacInfo, string F_SZXY_CUSTID, ref int V)
        {
            DataSet RESDS = null;

            string  SelCust   = $"/*dialect*/select T6.FNAME '客户名' from T_BD_CUSTOMER T5    left join T_BD_CUSTOMER_L t6 on t6.FCUSTID=T5.FCUSTID where t6.FCUSTID='{F_SZXY_CUSTID}'";
            DataSet SelCustDS = DBServiceHelper.ExecuteDataSet(Context, SelCust);

            if (SelCustDS != null && SelCustDS.Tables.Count > 0 && SelCustDS.Tables[0].Rows.Count > 0)
            {
                Logger.Debug($"客户:{Convert.ToString(SelCustDS.Tables[0].Rows[0][0])}", $"指定标签模板:{ZDPrintModel},MAC地址为{MacInfo}");
            }

            #region
            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'  " + ZDPrintModel + " ";
            DataSet DS       = null;
            string  WhereSql = "";

            if (F_SZXY_CUSTID.IsNullOrEmptyOrWhiteSpace() || F_SZXY_CUSTID == "")
            {
                F_SZXY_CUSTID = "0";
            }
            //如果不为空 客户
            WhereSql = $" {SQL12}  and T1.F_SZXY_CustID={F_SZXY_CUSTID}   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 T1.F_SZXY_CustID=0   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 T1.F_SZXY_CustID={F_SZXY_CUSTID}   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;
                        }
                    }

                    else
                    {
                        WhereSql = $" {SQL12}  and T1.F_SZXY_CustID=0 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;
                            }
                        }
                        else
                        {
                            View.ShowWarnningMessage("没有匹配到模板!");
                        }
                    }
                }
            }

            Logger.Debug("匹配单据套打模板编码Sql", WhereSql);
            if (RESDS != null && RESDS.Tables.Count > 0 && RESDS.Tables[0].Rows.Count > 0)
            {
                string BQ = Convert.ToString(RESDS.Tables[0].Rows[0]["标签"]);
                Logger.Debug("匹配单据套打模板编码", BQ);
            }
            return(RESDS);

            #endregion
        }
        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
        }
Esempio n. 21
0
        /// <summary>
        /// 组装销售订单数据并保存
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public ReturnParam SaleOrder(DataTable dt, DataTable dtbt, int a)
        {
            ReturnParam param = new ReturnParam();

            #region 方法二: 创建视图、模型,模拟手工新增,会触发大部分的表单服务和插件
            FormMetadata             meta = MetaDataServiceHelper.Load(this.Context, "SAL_SaleOrder") as FormMetadata;
            BusinessInfo             info = meta.BusinessInfo;
            IResourceServiceProvider formServiceProvider = meta.BusinessInfo.GetForm().GetFormServiceProvider(true);
            IBillViewService         billViewService     = formServiceProvider.GetService(typeof(IDynamicFormView)) as IBillViewService;

            /******创建单据打开参数*************/
            Form form = meta.BusinessInfo.GetForm();
            BillOpenParameter billOpenParameter = new BillOpenParameter(form.Id, meta.GetLayoutInfo().Id);
            billOpenParameter                       = new BillOpenParameter(form.Id, string.Empty);
            billOpenParameter.Context               = Context;
            billOpenParameter.ServiceName           = form.FormServiceName;
            billOpenParameter.PageId                = Guid.NewGuid().ToString();
            billOpenParameter.FormMetaData          = meta;
            billOpenParameter.LayoutId              = meta.GetLayoutInfo().Id;
            billOpenParameter.Status                = OperationStatus.ADDNEW;
            billOpenParameter.PkValue               = null;
            billOpenParameter.CreateFrom            = CreateFrom.Default;
            billOpenParameter.ParentId              = 0;
            billOpenParameter.GroupId               = "";
            billOpenParameter.DefaultBillTypeId     = null;
            billOpenParameter.DefaultBusinessFlowId = null;
            billOpenParameter.SetCustomParameter("ShowConfirmDialogWhenChangeOrg", false);
            List <AbstractDynamicFormPlugIn> value = form.CreateFormPlugIns();
            billOpenParameter.SetCustomParameter(FormConst.PlugIns, value);

            ((IDynamicFormViewService)billViewService).Initialize(billOpenParameter, formServiceProvider);

            IBillView bill_view = (IBillView)billViewService;

            bill_view.CreateNewModelData();

            DynamicFormViewPlugInProxy proxy = bill_view.GetService <DynamicFormViewPlugInProxy>();
            proxy.FireOnLoad();
            string FID       = string.Empty;
            string updatesql = string.Empty;
            updatesql = "";
            List <string> listsql      = new List <string>();
            string        FProgramCode = "";
            //表头
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                FID          = dt.Rows[i]["FID"].ToString();
                FProgramCode = dt.Rows[i]["FBILLNO"].ToString();
                bill_view.Model.SetItemValueByID("FSaleOrgId", dt.Rows[i]["FSALEORGID"], 0);
                bill_view.Model.SetValue("FDate", DateTime.Now.ToString());
                //客户
                bill_view.Model.SetItemValueByID("FCustId", dt.Rows[i]["FCUSTID"].ToString(), 0);
                //结算币别
                bill_view.InvokeFieldUpdateService("FCustId", 0);
                bill_view.InvokeFieldUpdateService("FSETTLECURRID", 0);
                //销售员
                bill_view.Model.SetValue("FSalerId", dt.Rows[i]["FSALERID"].ToString(), 0);
                bill_view.InvokeFieldUpdateService("FSALEDEPTID", 0);
                //交货方式
                bill_view.Model.SetValue("FHeadDeliveryWay", dt.Rows[i]["FHEADDELIVERYWAY"].ToString());
                //交货地点
                bill_view.Model.SetValue("FHEADLOCID", dt.Rows[i]["FHEADLOCID"].ToString());
            }
            if (a == 1)
            {
                //表体
                for (int i = 0; i < dtbt.Rows.Count; i++)
                {
                    bill_view.Model.CreateNewEntryRow("FSaleOrderEntry");
                    bill_view.Model.SetValue("FMaterialId", dtbt.Rows[i]["FMATERIALID"].ToString(), i);
                    bill_view.InvokeFieldUpdateService("FMATERIALID", i);
                    bill_view.InvokeFieldUpdateService("FUNITID", i);
                    bill_view.InvokeFieldUpdateService("FBASEUNITID", i);
                    // 销售数量
                    bill_view.Model.SetValue("FQty", Convert.ToDouble(dtbt.Rows[i]["FQTY"].ToString()), i);
                    bill_view.InvokeFieldUpdateService("FQty", i);          //
                    bill_view.InvokeFieldUpdateService("FPriceUnitQty", i); //计家数量
                    //含税单价
                    bill_view.Model.SetValue("FTaxPrice", 20, i);
                    bill_view.InvokeFieldUpdateService("FTaxPrice", i);
                    bill_view.InvokeFieldUpdateService("FPrice", i);
                    bill_view.InvokeFieldUpdateService("FAmount", i);
                    bill_view.InvokeFieldUpdateService("FAllAmount", i);
                    bill_view.InvokeFieldUpdateService("FAllAmount", i);
                    //要货日期DateTime.Now.AddDays(10
                    bill_view.Model.SetValue("FDeliveryDate", DateTime.Now.AddDays(10), i);
                    //计划交货日期
                    bill_view.Model.SetValue("FMinPlanDeliveryDate", DateTime.Now.AddDays(10), i);
                    //结算组织
                    bill_view.Model.SetItemValueByID("FSettleOrgIds", this.Context.CurrentOrganizationInfo.ID, i);
                    //批号FLot
                    bill_view.Model.SetValue("FLot", dtbt.Rows[i]["FLOT"].ToString(), i);
                    // bill_view.Model.SetValue("FLOT_TEXT", dtbt.Rows[i]["FINVOICE"].ToString() + "_" + dtbt.Rows[i]["FBOARDNO"].ToString() + "_" + dtbt.Rows[i]["FCARTONNO"].ToString(), i);
                    int FSEQ = i + 1;
                    updatesql = "update T_SAL_ORDERENTRY set FAUXPROPID='" + dtbt.Rows[i]["FAUXPROPID"].ToString() + "',FLOT_TEXT='" + dtbt.Rows[i]["FINVOICE"].ToString() + "_" + dtbt.Rows[i]["FBOARDNO"].ToString() + "_" + dtbt.Rows[i]["FCARTONNO"].ToString() + "',FLOT=" + dtbt.Rows[i]["FLOT"].ToString() + " where FSEQ=" + FSEQ + "";
                    listsql.Add(updatesql);
                }
            }
            else if (a == 2)
            {
                //表体
                for (int i = 0; i < dtbt.Rows.Count; i++)
                {
                    bill_view.Model.CreateNewEntryRow("FSaleOrderEntry");
                    bill_view.Model.SetValue("FMaterialId", dtbt.Rows[i]["FMATERIALID2"].ToString(), i);
                    bill_view.InvokeFieldUpdateService("FMATERIALID", i);
                    bill_view.InvokeFieldUpdateService("FUNITID", i);
                    bill_view.InvokeFieldUpdateService("FBASEUNITID", i);
                    // 销售数量
                    bill_view.Model.SetValue("FQty", Convert.ToDouble(dtbt.Rows[i]["FQTY2"].ToString()), i);
                    bill_view.InvokeFieldUpdateService("FQty", i);          //
                    bill_view.InvokeFieldUpdateService("FPriceUnitQty", i); //计家数量
                                                                            //含税单价
                    bill_view.Model.SetValue("FTaxPrice", 20, i);
                    bill_view.InvokeFieldUpdateService("FTaxPrice", i);
                    bill_view.InvokeFieldUpdateService("FPrice", i);
                    bill_view.InvokeFieldUpdateService("FAmount", i);
                    bill_view.InvokeFieldUpdateService("FAllAmount", i);
                    bill_view.InvokeFieldUpdateService("FAllAmount", i);
                    //要货日期DateTime.Now.AddDays(10
                    bill_view.Model.SetValue("FDeliveryDate", DateTime.Now.AddDays(10), i);
                    //计划交货日期
                    bill_view.Model.SetValue("FMinPlanDeliveryDate", DateTime.Now.AddDays(10), i);
                    //结算组织
                    bill_view.Model.SetItemValueByID("FSettleOrgIds", this.Context.CurrentOrganizationInfo.ID, i);
                    //批号FLot
                    bill_view.Model.SetValue("FLot", dtbt.Rows[i]["FLOT2"].ToString(), i);
                    // bill_view.Model.SetValue("FLOT_TEXT", dtbt.Rows[i]["FINVOICE2"].ToString() + "_" + dtbt.Rows[i]["FBOARDNO2"].ToString() + "_" + dtbt.Rows[i]["FCARTONNO2"].ToString(), i);
                    int FSEQ = i + 1;
                    updatesql = "update T_SAL_ORDERENTRY set FAUXPROPID='" + dtbt.Rows[i]["FAUXPROPID2"].ToString() + "', FLOT_TEXT='" + dtbt.Rows[i]["FINVOICE2"].ToString() + "_" + dtbt.Rows[i]["FBOARDNO2"].ToString() + "_" + dtbt.Rows[i]["FCARTONNO2"].ToString() + "',FLOT =" + dtbt.Rows[i]["FLOT2"].ToString() + " where FSEQ=" + FSEQ + "";
                    listsql.Add(updatesql);
                }
            }
            else if (a == 3)
            {
                //表体
                for (int i = 0; i < dtbt.Rows.Count; i++)
                {
                    bill_view.Model.CreateNewEntryRow("FSaleOrderEntry");
                    bill_view.Model.SetValue("FMaterialId", dtbt.Rows[i]["FMATERIALID3"].ToString(), i);
                    bill_view.InvokeFieldUpdateService("FMATERIALID", i);
                    bill_view.InvokeFieldUpdateService("FUNITID", i);
                    bill_view.InvokeFieldUpdateService("FBASEUNITID", i);
                    // 销售数量
                    bill_view.Model.SetValue("FQty", Convert.ToDouble(dtbt.Rows[i]["FQTY3"].ToString()), i);
                    bill_view.InvokeFieldUpdateService("FQty", i);          //
                    bill_view.InvokeFieldUpdateService("FPriceUnitQty", i); //计家数量
                                                                            //含税单价
                    bill_view.Model.SetValue("FTaxPrice", 20, i);
                    bill_view.InvokeFieldUpdateService("FTaxPrice", i);
                    bill_view.InvokeFieldUpdateService("FPrice", i);
                    bill_view.InvokeFieldUpdateService("FAmount", i);
                    bill_view.InvokeFieldUpdateService("FAllAmount", i);
                    bill_view.InvokeFieldUpdateService("FAllAmount", i);
                    //要货日期DateTime.Now.AddDays(10
                    bill_view.Model.SetValue("FDeliveryDate", DateTime.Now.AddDays(10), i);
                    //计划交货日期
                    bill_view.Model.SetValue("FMinPlanDeliveryDate", DateTime.Now.AddDays(10), i);
                    //结算组织
                    bill_view.Model.SetItemValueByID("FSettleOrgIds", this.Context.CurrentOrganizationInfo.ID, i);
                    //批号FLot
                    bill_view.Model.SetValue("FLot", dtbt.Rows[i]["FLOT3"].ToString(), i);
                    // bill_view.Model.SetValue("FLOT_TEXT", dtbt.Rows[i]["FINVOICE3"].ToString()+"_"+ dtbt.Rows[i]["FBOARDNO3"].ToString()+"_"+ dtbt.Rows[i]["FCARTONNO3"].ToString(), i);
                    int FSEQ = i + 1;
                    updatesql = "update T_SAL_ORDERENTRY set FAUXPROPID='" + dtbt.Rows[i]["FAUXPROPID3"].ToString() + "', FLOT_TEXT='" + dtbt.Rows[i]["FINVOICE3"].ToString() + "_" + dtbt.Rows[i]["FBOARDNO3"].ToString() + "_" + dtbt.Rows[i]["FCARTONNO3"].ToString() + "',FLOT=" + dtbt.Rows[i]["FLOT3"].ToString() + " where FSEQ=" + FSEQ + "";
                    listsql.Add(updatesql);
                }
            }
            string result = "";
            //保存
            IOperationResult save_result = bill_view.Model.Save();
            if (save_result.IsSuccess)
            {
                string fid     = string.Empty;
                string Fnumber = string.Empty;
                OperateResultCollection Collection = save_result.OperateResult;
                foreach (var item in Collection)
                {
                    fid     = item.PKValue.ToString();
                    Fnumber = item.Number.ToString();
                }
                //更新到方案FSalesOrder
                string sql = "update t_OrderPlan set FSalesOrder='" + Fnumber + "'  where  FID=" + FID + ";";
                sql += " update  T_SAL_ORDER set FProgramCode='" + FProgramCode + "'  where  FID=" + fid + ";";
                DBServiceHelper.Execute(this.Context, sql);
                sql = " and FID=" + fid + " ;";
                foreach (var item in listsql)
                {
                    string upsql = item + sql;
                    DBServiceHelper.Execute(this.Context, upsql);
                }
                param.msg    = "生成销售订单成功:" + Fnumber;
                param.status = true;
                return(param);
            }
            else
            {
                for (int mf = 0; mf < save_result.ValidationErrors.Count; mf++)
                {
                    result += "\r\n" + save_result.ValidationErrors[mf].Message;
                }

                param.msg    = "保存失败:" + result;
                param.status = false;
                return(param);
            }
            #endregion
        }
Esempio n. 22
0
        /// <summary>
        /// 生成方案
        /// </summary>
        /// <returns></returns>
        public ReturnParam GenerateSolutions(ReturnInfo returnInfo, Context context)
        {
            string      sql         = string.Empty;
            ReturnParam returnParam = new ReturnParam();

            try
            {
                string Fnumber = returnInfo.Fnumber;
                int    qty     = returnInfo.Qty;
                string dengji  = returnInfo.FGG;
                //截取等级
                string[] array = Regex.Split(dengji, ",", RegexOptions.IgnoreCase);
                //等级
                List <Level> dj = new List <Level>()
                {
                    new Level()
                    {
                        Id = "100002", FAUXPTYNUMBER = "A"
                    },
                    new Level()
                    {
                        Id = "100003", FAUXPTYNUMBER = "B"
                    },
                    new Level()
                    {
                        Id = "100004", FAUXPTYNUMBER = "F"
                    },
                    new Level()
                    {
                        Id = "100005", FAUXPTYNUMBER = "N"
                    },
                    new Level()
                    {
                        Id = "100006", FAUXPTYNUMBER = "TB"
                    },
                    new Level()
                    {
                        Id = "100007", FAUXPTYNUMBER = "T"
                    },
                    new Level()
                    {
                        Id = "100008", FAUXPTYNUMBER = "P"
                    },
                    new Level()
                    {
                        Id = "100009", FAUXPTYNUMBER = "TB/B"
                    },
                    new Level()
                    {
                        Id = "100010", FAUXPTYNUMBER = "B/F"
                    },
                    new Level()
                    {
                        Id = "100011", FAUXPTYNUMBER = "F/N"
                    },
                };
                string        sqldj = "";
                List <string> vs    = new List <string>();
                for (int j = 0; j < array.Length; j++)
                {
                    Level level = dj.SingleOrDefault(p => p.FAUXPTYNUMBER == array[j].ToString());
                    if (level != null)
                    {
                        if (j == 0)
                        {
                            sqldj += "  t1.FMATERIALID=" + Fnumber + " and t1.FBASEQTY > 0 and t1.FAUXPROPID='" + level.Id + "' ";
                        }
                        else
                        {
                            sqldj += " or t1.FMATERIALID=" + Fnumber + " and t1.FBASEQTY > 0 and t1.FAUXPROPID='" + level.Id + "' ";
                        }
                    }
                }
                double PCSCONVERT = 1;
                double FDXQTY     = 1;
                //获取库存数据
                sql = "select t1.FMATERIALID,t1.FLOT,t2.FNUMBER,t1.FBASEQTY, t4.FDATE ,t5.FPCSCONVERT,t5.FDXQTY,t1.FAUXPROPID   From  T_STK_INVENTORY t1" +
                      " left  join  T_BD_LOTMASTER t2 on t1.FLOT = t2.FLOTID" +
                      " left join T_STK_INSTOCKENTRY t3 on  t3.FLOT = t1.FLOT and t3.FMATERIALID = t1.FMATERIALID" +
                      " left join t_STK_InStock t4 on t3.FID = t4.FID" +
                      " left join  T_BD_MATERIAL t5 on t5.FMATERIALID=t1.FMATERIALID" +
                      " where ";
                string sqlend = " order by t4.FDATE asc";
                if (string.IsNullOrEmpty(dengji))
                {
                    sqldj = "t1.FMATERIALID=" + Fnumber + " and t1.FBASEQTY > 0 " + sqlend;
                    sql   = sql + sqldj;
                }
                else
                {
                    sql = sql + sqldj + sqlend;
                }
                DataSet   ds = DBServiceHelper.ExecuteDataSet(context, sql);
                DataTable dt = ds.Tables[0];
                #region 方法二: 创建视图、模型,模拟手工新增,会触发大部分的表单服务和插件
                FormMetadata             meta = MetaDataServiceHelper.Load(context, "PAEZ_OrderPlan") as FormMetadata;
                BusinessInfo             info = meta.BusinessInfo;
                IResourceServiceProvider formServiceProvider = meta.BusinessInfo.GetForm().GetFormServiceProvider(true);
                IBillViewService         billViewService     = formServiceProvider.GetService(typeof(IDynamicFormView)) as IBillViewService;

                /******创建单据打开参数*************/
                Form form = meta.BusinessInfo.GetForm();
                BillOpenParameter billOpenParameter = new BillOpenParameter(form.Id, meta.GetLayoutInfo().Id);
                billOpenParameter                       = new BillOpenParameter(form.Id, string.Empty);
                billOpenParameter.Context               = context;
                billOpenParameter.ServiceName           = form.FormServiceName;
                billOpenParameter.PageId                = Guid.NewGuid().ToString();
                billOpenParameter.FormMetaData          = meta;
                billOpenParameter.LayoutId              = meta.GetLayoutInfo().Id;
                billOpenParameter.Status                = OperationStatus.ADDNEW;
                billOpenParameter.PkValue               = null;
                billOpenParameter.CreateFrom            = CreateFrom.Default;
                billOpenParameter.ParentId              = 0;
                billOpenParameter.GroupId               = "";
                billOpenParameter.DefaultBillTypeId     = null;
                billOpenParameter.DefaultBusinessFlowId = null;
                billOpenParameter.SetCustomParameter("ShowConfirmDialogWhenChangeOrg", false);
                List <AbstractDynamicFormPlugIn> value = form.CreateFormPlugIns();
                billOpenParameter.SetCustomParameter(FormConst.PlugIns, value);

                ((IDynamicFormViewService)billViewService).Initialize(billOpenParameter, formServiceProvider);

                IBillView bill_view = (IBillView)billViewService;

                bill_view.CreateNewModelData();

                DynamicFormViewPlugInProxy proxy = bill_view.GetService <DynamicFormViewPlugInProxy>();
                proxy.FireOnLoad();
                bill_view.Model.SetItemValueByID("FSaleOrgId", context.CurrentOrganizationInfo.ID, 0);
                bill_view.Model.SetValue("FDate", DateTime.Now.ToString());
                List <OrderPlan> orderPlans = new List <OrderPlan>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    OrderPlan order = new OrderPlan();
                    bill_view.Model.CreateNewEntryRow("FEntity");
                    bill_view.Model.SetValue("FMATERIALID", dt.Rows[i]["FMATERIALID"].ToString(), i);
                    string[] str = Regex.Split(dt.Rows[i]["FNUMBER"].ToString(), "_", RegexOptions.IgnoreCase);
                    // string level= dj.Select(x => x.Id = dt.Rows[i]["FAUXPROPID"].ToString()).First();
                    Level level = dj.SingleOrDefault(p => p.Id == dt.Rows[i]["FAUXPROPID"].ToString());
                    if (level != null)
                    {
                        //等级
                        bill_view.Model.SetItemValueByNumber("$$FAUXPROPID__FF100001", level.FAUXPTYNUMBER, i);
                    }
                    bill_view.Model.SetValue("FINVOICE", str[0].ToString(), i);
                    //板号
                    bill_view.Model.SetValue("FBoardNo", str[1].ToString(), i);
                    //箱号
                    bill_view.Model.SetValue("FCartonNo", str[2].ToString(), i);
                    //库存数量
                    bill_view.Model.SetValue("FQTY", dt.Rows[i]["FBASEQTY"].ToString(), i);
                    //入库日期
                    bill_view.Model.SetValue("FInboundDate", dt.Rows[i]["FDATE"].ToString(), i);
                    //下单数量
                    bill_view.Model.SetValue("FOrderQty", qty, i);
                    //批号
                    bill_view.Model.SetValue("FLOT", dt.Rows[i]["FLOT"].ToString(), i);
                    double FPCSCONVERT = 1;
                    if (string.IsNullOrEmpty(dt.Rows[i]["FPCSCONVERT"].ToString()))
                    {
                        FPCSCONVERT = Convert.ToDouble(dt.Rows[i]["FBASEQTY"].ToString());
                    }
                    else
                    {
                        PCSCONVERT  = Convert.ToDouble(dt.Rows[i]["FPCSCONVERT"].ToString());
                        FPCSCONVERT = Convert.ToDouble(dt.Rows[i]["FPCSCONVERT"].ToString()) * Convert.ToDouble(dt.Rows[i]["FBASEQTY"].ToString());
                    }
                    FDXQTY = Convert.ToDouble(dt.Rows[i]["FDXQTY"].ToString());
                    //转化pcs数量
                    bill_view.Model.SetValue("FPCSQTY", FPCSCONVERT, i);
                    //保存数据
                    order.FMATERIALID  = dt.Rows[i]["FMATERIALID"].ToString();
                    order.FINVOICE     = str[0].ToString();
                    order.FBoardNo     = str[1].ToString();
                    order.FCartonNo    = str[2].ToString();
                    order.FQTY         = Convert.ToDouble(dt.Rows[i]["FBASEQTY"].ToString());
                    order.FInboundDate = dt.Rows[i]["FDATE"].ToString();
                    order.FOrderQty    = qty;
                    order.FLOT         = dt.Rows[i]["FLOT"].ToString();
                    order.FPCSCONVERT  = FPCSCONVERT;
                    order.FAUXPROPID   = dt.Rows[i]["FAUXPROPID"].ToString();
                    orderPlans.Add(order);
                }

                //计算出最优方案 1.计算是刚好等于西单数量的 2.计算出最靠近下单数量的

                // 单箱的pcs
                double SingleFCartonNo = PCSCONVERT * FDXQTY;

                int TotalFCartonNo = Convert.ToInt32(Math.Floor(qty / SingleFCartonNo));

                //剩余数量
                double    RemainQty         = qty % SingleFCartonNo;
                OrderPlan order2            = new OrderPlan();
                bool      Isminimum         = false;
                OrderPlan order3            = new OrderPlan();
                double    differenceQty     = 0;
                double    olddifferenceQty  = 0;
                double    newdifferenceQty2 = 0;
                if (RemainQty != 0)
                {
                    #region  计算出最靠近剩余数量的数并多于下单数量(最右原则)
                    foreach (var item in orderPlans)
                    {
                        if (differenceQty == 0 && item.FPCSCONVERT - RemainQty >= 0)
                        {
                            differenceQty       = item.FPCSCONVERT - RemainQty;
                            order2.FMATERIALID  = item.FMATERIALID;
                            order2.FINVOICE     = item.FINVOICE;
                            order2.FBoardNo     = item.FBoardNo;
                            order2.FCartonNo    = item.FCartonNo;
                            order2.FQTY         = item.FQTY;
                            order2.FInboundDate = item.FInboundDate;
                            order2.FOrderQty    = item.FOrderQty;
                            order2.FLOT         = item.FLOT;
                            order2.FAUXPROPID   = item.FAUXPROPID;
                            order2.FPCSCONVERT  = item.FPCSCONVERT;
                        }
                        else
                        {
                            double newdifferenceQty = item.FPCSCONVERT - RemainQty;
                            if (newdifferenceQty > 0 && newdifferenceQty < differenceQty)
                            {
                                differenceQty       = newdifferenceQty;
                                order2.FMATERIALID  = item.FMATERIALID;
                                order2.FINVOICE     = item.FINVOICE;
                                order2.FBoardNo     = item.FBoardNo;
                                order2.FCartonNo    = item.FCartonNo;
                                order2.FQTY         = item.FQTY;
                                order2.FInboundDate = item.FInboundDate;
                                order2.FOrderQty    = item.FOrderQty;
                                order2.FLOT         = item.FLOT;
                                order2.FAUXPROPID   = item.FAUXPROPID;
                                order2.FPCSCONVERT  = item.FPCSCONVERT;
                            }
                        }
                    }

                    #endregion

                    #region  计算最靠近的数量并小于下单数量(最左原则)
                    foreach (var item in orderPlans)
                    {
                        newdifferenceQty2 = item.FPCSCONVERT - RemainQty;
                        if (newdifferenceQty2 <= 0)
                        {
                            if (olddifferenceQty != 0)
                            {
                                if (Math.Abs(newdifferenceQty2) < Math.Abs(olddifferenceQty))
                                {
                                    olddifferenceQty    = newdifferenceQty2;
                                    order3.FMATERIALID  = item.FMATERIALID;
                                    order3.FINVOICE     = item.FINVOICE;
                                    order3.FBoardNo     = item.FBoardNo;
                                    order3.FCartonNo    = item.FCartonNo;
                                    order3.FQTY         = item.FQTY;
                                    order3.FInboundDate = item.FInboundDate;
                                    order3.FOrderQty    = item.FOrderQty;
                                    order3.FLOT         = item.FLOT;
                                    order3.FPCSCONVERT  = item.FPCSCONVERT;
                                    order3.FAUXPROPID   = item.FAUXPROPID;
                                    Isminimum           = true;
                                }
                            }
                            else
                            {
                                olddifferenceQty    = newdifferenceQty2;
                                order3.FMATERIALID  = item.FMATERIALID;
                                order3.FINVOICE     = item.FINVOICE;
                                order3.FBoardNo     = item.FBoardNo;
                                order3.FCartonNo    = item.FCartonNo;
                                order3.FQTY         = item.FQTY;
                                order3.FInboundDate = item.FInboundDate;
                                order3.FOrderQty    = item.FOrderQty;
                                order3.FLOT         = item.FLOT;
                                order3.FAUXPROPID   = item.FAUXPROPID;
                                order3.FPCSCONVERT  = item.FPCSCONVERT;
                                Isminimum           = true;
                            }
                        }
                    }

                    #endregion
                }
                #region 组装数据
                //当前库存不够发
                if (orderPlans.Count < TotalFCartonNo)
                {
                    returnParam.status = true;
                    returnParam.msg    = "当前库存数量不够发货";
                    return(returnParam);
                }
                else
                {
                    //排除非整箱
                    List <OrderPlan> orderPlan  = orderPlans.FindAll(t => t.FLOT != order2.FLOT);
                    List <OrderPlan> orderPlan3 = orderPlans.FindAll(t => t.FLOT != order3.FLOT);
                    int j = 0;
                    #region 最右原则
                    foreach (var item in orderPlan)
                    {
                        if (j == TotalFCartonNo)
                        {
                            break;
                        }
                        else
                        {
                            if (item.FPCSCONVERT == SingleFCartonNo)
                            {
                                bill_view.Model.CreateNewEntryRow("F_PAEZ_Entity");
                                bill_view.Model.SetValue("FMATERIALID2", item.FMATERIALID, j);
                                //等级
                                //bill_view.Model.SetItemValueByID("FAUXPROPID2", item.FAUXPROPID, j);

                                Level level = dj.SingleOrDefault(p => p.Id == item.FAUXPROPID);
                                if (level != null)
                                {
                                    //等级
                                    bill_view.Model.SetItemValueByNumber("$$FAUXPROPID2__FF100001", level.FAUXPTYNUMBER, j);
                                }
                                bill_view.Model.SetValue("FINVOICE2", item.FINVOICE, j);
                                //板号
                                bill_view.Model.SetValue("FBoardNo2", item.FBoardNo, j);
                                //箱号
                                bill_view.Model.SetValue("FCartonNo2", item.FCartonNo, j);
                                //库存数量
                                bill_view.Model.SetValue("FQTY2", item.FQTY, j);
                                //入库日期
                                bill_view.Model.SetValue("FInboundDate2", item.FInboundDate, j);
                                //下单数量
                                bill_view.Model.SetValue("FOrderQty2", item.FOrderQty, j);
                                //批号
                                bill_view.Model.SetValue("FLOT2", item.FLOT, j);
                                //转化pcs数量
                                bill_view.Model.SetValue("FPCSQTY2", item.FPCSCONVERT, j);
                                j++;
                            }
                        }
                    }
                    //加入剩余数量
                    if (RemainQty != 0)
                    {
                        bill_view.Model.CreateNewEntryRow("F_PAEZ_Entity");
                        bill_view.Model.SetValue("FMATERIALID2", order2.FMATERIALID, j);
                        //等级
                        if (!string.IsNullOrEmpty(order2.FAUXPROPID) && order2.FAUXPROPID != "0")
                        {
                            Level level = dj.SingleOrDefault(p => p.Id == order2.FAUXPROPID);
                            //等级
                            bill_view.Model.SetItemValueByNumber("$$FAUXPROPID2__FF100001", level.FAUXPTYNUMBER, j);
                        }
                        bill_view.Model.SetValue("FINVOICE2", order2.FINVOICE, j);
                        //板号
                        bill_view.Model.SetValue("FBoardNo2", order2.FBoardNo, j);
                        //箱号
                        bill_view.Model.SetValue("FCartonNo2", order2.FCartonNo, j);
                        //库存数量
                        bill_view.Model.SetValue("FQTY2", order2.FQTY, j);
                        //入库日期
                        bill_view.Model.SetValue("FInboundDate2", order2.FInboundDate, j);
                        //下单数量
                        bill_view.Model.SetValue("FOrderQty2", order2.FOrderQty, j);
                        //批号
                        bill_view.Model.SetValue("FLOT2", order2.FLOT, j);
                        //转化pcs数量
                        bill_view.Model.SetValue("FPCSQTY2", order2.FPCSCONVERT, j);
                    }

                    #endregion

                    #region 最左原则
                    int a = 0;
                    foreach (var item in orderPlan3)
                    {
                        if (a == TotalFCartonNo)
                        {
                            break;
                        }
                        else
                        {
                            if (item.FPCSCONVERT == SingleFCartonNo)
                            {
                                bill_view.Model.CreateNewEntryRow("F_PAEZ_Entity3");
                                bill_view.Model.SetValue("FMATERIALID3", item.FMATERIALID, a);
                                //等级
                                //bill_view.Model.SetItemValueByID("FAUXPROPID3", item.FAUXPROPID, a);
                                Level level = dj.SingleOrDefault(p => p.Id == item.FAUXPROPID);
                                if (level != null)
                                {
                                    //等级
                                    bill_view.Model.SetItemValueByNumber("$$FAUXPROPID3__FF100001", level.FAUXPTYNUMBER, a);
                                }
                                bill_view.Model.SetValue("FINVOICE3", item.FINVOICE, a);
                                //板号
                                bill_view.Model.SetValue("FBoardNo3", item.FBoardNo, a);
                                //箱号
                                bill_view.Model.SetValue("FCartonNo3", item.FCartonNo, a);
                                //库存数量
                                bill_view.Model.SetValue("FQTY3", item.FQTY, a);
                                //入库日期
                                bill_view.Model.SetValue("FInboundDate3", item.FInboundDate, a);
                                //下单数量
                                bill_view.Model.SetValue("FOrderQty3", item.FOrderQty, a);
                                //批号
                                bill_view.Model.SetValue("FLOT3", item.FLOT, a);
                                //转化pcs数量
                                bill_view.Model.SetValue("FPCSQTY3", item.FPCSCONVERT, a);
                                a++;
                            }
                        }
                    }
                    //加入剩余数量
                    if (RemainQty != 0)
                    {
                        bill_view.Model.CreateNewEntryRow("F_PAEZ_Entity3");
                        bill_view.Model.SetValue("FMATERIALID3", order3.FMATERIALID, a);
                        //等级
                        if (!string.IsNullOrEmpty(order3.FAUXPROPID) && order3.FAUXPROPID != "0")
                        {
                            Level level = dj.SingleOrDefault(p => p.Id == order3.FAUXPROPID);
                            //等级
                            bill_view.Model.SetItemValueByNumber("$$FAUXPROPID3__FF100001", level.FAUXPTYNUMBER, a);
                        }
                        bill_view.Model.SetValue("FINVOICE3", order3.FINVOICE, a);
                        //板号
                        bill_view.Model.SetValue("FBoardNo3", order3.FBoardNo, a);
                        //箱号
                        bill_view.Model.SetValue("FCartonNo3", order3.FCartonNo, a);
                        //库存数量
                        bill_view.Model.SetValue("FQTY3", order3.FQTY, a);
                        //入库日期
                        bill_view.Model.SetValue("FInboundDate3", order3.FInboundDate, a);
                        //下单数量
                        bill_view.Model.SetValue("FOrderQty3", order3.FOrderQty, a);
                        //批号
                        bill_view.Model.SetValue("FLOT3", order3.FLOT, a);
                        //转化pcs数量
                        bill_view.Model.SetValue("FPCSQTY3", order3.FPCSCONVERT, a);
                    }

                    #endregion
                }
                #endregion
                string result = "";

                IOperationResult save_result = bill_view.Model.Save();
                if (save_result.IsSuccess)
                {
                    string fid = string.Empty;
                    OperateResultCollection Collection = save_result.OperateResult;
                    foreach (var item in Collection)
                    {
                        fid = item.PKValue.ToString();
                    }
                    returnParam.FBUSINESSCODE = fid;
                    returnParam.FBIZFORMID    = "PAEZ_OrderPlan";
                    returnParam.msg           = "方案生成功";
                    returnParam.status        = true;
                    return(returnParam);
                }
                else
                {
                    for (int mf = 0; mf < save_result.ValidationErrors.Count; mf++)
                    {
                        result += "\r\n" + save_result.ValidationErrors[mf].Message;
                    }
                }


                #endregion
            }
            catch (Exception ex)
            {
                returnParam.msg    = ex.ToString();
                returnParam.status = false;
                returnParam.msg    = "方案生成失败";
                return(returnParam);
            }
            return(returnParam);
        }
Esempio n. 23
0
 /// <summary>
 /// 设置上下文对象。
 /// </summary>
 /// <param name="view">动态表单视图。</param>
 public void SetContext(IBillView view)
 {
     this.View    = view;
     this.Context = view.Context;
 }
        /// <summary>
        /// 把物料的各属性,填写到IBillView当前所管理的物料中
        /// </summary>
        /// <param name="billView"></param>
        private void FillMaterialPropertys(IBillView billView)
        {
            // 把billView转换为IDynamicFormViewService接口:
            // 调用IDynamicFormViewService.UpdateValue: 会执行字段的值更新事件
            // 调用 dynamicFormView.SetItemValueByNumber :不会执行值更新事件,需要继续调用:
            // ((IDynamicFormView)dynamicFormView).InvokeFieldUpdateService(key, rowIndex);
            IDynamicFormViewService dynamicFormView = billView as IDynamicFormViewService;

            /********************物料页签上的字段******************/
            // 创建组织、使用组织 :
            // 基础资料字段,用编码录入 (SetItemValueByNumber)
            // 特别说明:基础资料字段,也可以使用SetValue函数赋值,填写基础资料内码
            // 本示例,模拟引入数据,并不清楚这些组织的内码是多少,只知道编码,所以选用SetItemValueByNumber
            // 函数参数 : 基础资料字段Key,组织编码,行号
            dynamicFormView.SetItemValueByNumber("FUseOrgId", "101.1", 0);
            dynamicFormView.SetItemValueByNumber("FCreateOrgId", "101.1", 0);
            // 物料编码、名称 :
            // 文本(简单值类型),直接使用SetValue赋值
            dynamicFormView.UpdateValue("FNumber", 0, "物料编码(JD-001)");
            dynamicFormView.UpdateValue("FName", 0, "物料名称(JD-001)");
            // 规格型号 (文本)
            dynamicFormView.UpdateValue("FSpecification", 0, "规格型号(JD-001)");
            // 助记码 (文本)
            dynamicFormView.UpdateValue("FMnemonicCode", 0, "助记码(JD-001)");
            // 描述 (文本)
            dynamicFormView.UpdateValue("FDescription", 0, "描述(JD-001)");
            // 来源 (下拉列表):填写枚举值
            dynamicFormView.UpdateValue("FMaterialSRC", 0, "B");
            // 创建人、创建日期、修改人、修改日期、审核人、审核日期、
            // 禁用人、禁用日期、禁用状态、数据状态等由系统自动赋值
            /********************基本页签上的字段******************/
            // 条码 (文本)
            dynamicFormView.UpdateValue("FBARCODE", 0, "TiaoMa(JD-001)");
            // 物料属性(下拉列表,'1' = 外购,'2' = 自制...)
            dynamicFormView.UpdateValue("FErpClsID", 0, "1");
            // 存货类别(基础资料,按编码赋值 'CHLB01_SYS' = 原材料)
            dynamicFormView.SetItemValueByNumber("FCategoryID", "CHLB01_SYS", 0);
            // 税分类(单选辅助资料-物料的税分类,赋值同基础资料赋值 'WLDSFL01_SYS' = 标准税率)
            dynamicFormView.SetItemValueByNumber("FTaxType", "WLDSFL01_SYS", 0);
            // 允许采购(复选框,简单值类型,值填写true\false)
            dynamicFormView.UpdateValue("FIsPurchase", 0, true);
            // 基本单位(基础资料):非常重要的字段,必须慎重设置
            // 基本单位仅能选择基准计量单位,如kg, m, pcs
            dynamicFormView.SetItemValueByNumber("FBaseUnitId", "kg", 0);
            // 允许库存、允许委外、即时核算、允许销售、允许生产、
            // 允许资产等字段同允许采购字段,已有默认值,无需设置
            // 默认税率已有默认值,无需设置
            // 物料分类(FTypeID,维度关联字段,赋值比较特别,需要针对各仓位维度赋值)
            // 如果没有定义仓位维度,则无需赋值
            // 另外,需要根据仓位维度的值类型,选用适当的赋值函数
            // dynamicFormView.SetItemValueByNumber("$$FTypeID__FF100001", "仓位维度1的编码(JD-001)", 0);
            // 重量单位,默认为kg;
            // 长度单位,默认为m;
            // 毛重(数量,简单值类型,直接填写数值)
            dynamicFormView.UpdateValue("FGROSSWEIGHT", 0, 0);
            // 净重、长、宽、高、体积,非重要属性,忽略
            /********************其他页签上的字段****************************/
            // 演示代码,仅设置必录字段
            // 库存单位(基础资料)
            ((IDynamicFormViewService)billView).SetItemValueByNumber("FStoreUnitID", "kg", 0);
            dynamicFormView.SetItemValueByNumber("FStoreUnitID", "kg", 0);
            // 辅助单位
            dynamicFormView.SetItemValueByNumber("FAuxUnitID", "Pcs", 0);
            // 销售单位
            dynamicFormView.SetItemValueByNumber("FSaleUnitId", "kg", 0);
            // 销售计价单位
            dynamicFormView.SetItemValueByNumber("FSalePriceUnitId", "kg", 0);
            // 采购单位
            dynamicFormView.SetItemValueByNumber("FPurchaseUnitId", "kg", 0);
            // 采购计价单位
            dynamicFormView.SetItemValueByNumber("FPurchasePriceUnitId", "kg", 0);
            // 换算方向(下拉列表, '1' = 库存单位 -> 辅助单位)
            dynamicFormView.UpdateValue("FUnitConvertDir", 0, "1");
            // 配额方式、计划策略、订货策略、
            // 固定提前期单位、变动提前期单位、检验提前期单位、订货间隔期单位、
            // 预留类型、时间单位、发料方式、超发控制方式
            // 上述字段为下拉列表,必录字段,但已经设置了默认值,演示代码忽略
            // 其他非必录字段均采用默认值
            // 推荐:
            // 可以在BOS设计器,打开物料,查看需要填写的字段类型,按照类型填字段值
            /********************库存属性单据体字段******************/
            // 需确定本物料,是否区分如下各库存维度:
            // 仓库、仓位、BOM版本、批号、计划跟踪号;
            // 默认情况下,仅区分仓库维度,仓位等不区分
            for (int rowIndex = 0; rowIndex < billView.Model.GetEntryRowCount("FEntityInvPty"); rowIndex++)
            {
                // 库存属性,基础资料类型:
                // 读取出当前库存属性信息,以便判断本物料是否启用此维度
                DynamicObject invPty = billView.Model.GetValue("FInvPtyId", rowIndex) as DynamicObject;
                if (invPty == null)
                {
                    continue;
                }
                // 读出库存属性编码备用(库存属性的编码 = T_BD_INVPROPERTY.FNumber)
                string invPtyNumber = Convert.ToString(invPty["number"]);
                // 演示代码,增加仓位维度(number = '02')
                if (invPtyNumber.EqualsIgnoreCase("02"))
                {
                    // 库存属性 - 启用(复选框)
                    dynamicFormView.UpdateValue("FIsEnable", rowIndex, true);
                    // 是否影响价格等选项,采用默认值
                }
            }
            /********************辅助属性单据体字段******************/
            // 需逐行判断本物料是否启用各辅助属性
            for (int rowIndex = 0; rowIndex < billView.Model.GetEntryRowCount("FEntityAuxPty"); rowIndex++)
            {
                // 辅助属性、基础资料类型:
                // 读取出当前辅助属性信息,以便判断本物料是否启用
                DynamicObject auxProp = billView.Model.GetValue("FAuxPropertyId", rowIndex) as DynamicObject;
                if (auxProp == null)
                {
                    continue;
                }
                // 读出辅助属性编码备用。
                string auxPropNumber = Convert.ToString(auxProp["number"]);
                // 判断此辅助属性是否启用(辅助属性编码 = T_BD_FLEXAUXPROPERTY.FNumber)
                // 演示代码,仅启用辅助属性 - 等级(Class)
                if (auxPropNumber.EqualsIgnoreCase("Class"))
                {
                    // 辅助属性是否启用(复选框)
                    dynamicFormView.UpdateValue("FIsEnable1", rowIndex, true);
                    // 是否影响价格等选项,采用默认值
                }
            }
            // 扩展的字段:
            dynamicFormView.UpdateValue("FTPBarCode", 0, "自定义编码");
        }
Esempio n. 25
0
        private void SetBillValue(Context context, DataSet fillData, IBillView view, int erow, int XQty, DynamicObject orgobj, string NoType)
        {
            DateTime dt = DateTime.Now;

            if (fillData != null && fillData.Tables.Count > 0 && fillData.Tables[0].Rows.Count > 0)
            {
                string value = "";

                DynamicObjectCollection entry1 = this.Model.DataObject["SZXY_XYDCJXXBEntry"] as DynamicObjectCollection;
                for (int i = 0; i < fillData.Tables[0].Rows.Count; i++)
                {
                    int mm = erow + i;
                    if (Convert.ToString(fillData.Tables[0].Rows[i]["性能等级"]).IsNullOrEmptyOrWhiteSpace() && Convert.ToInt32(fillData.Tables[0].Rows[i]["性能等级"]) <= 0)
                    {
                        this.View.ShowWarnningMessage("此编号没有性能等级!");
                        return;
                    }


                    this.Model.CreateNewEntryRow("F_SZXY_XYDCJXXBEntity");

                    this.View.GetControl <EntryGrid>("F_SZXY_XYDCJXXBEntity").SetEnterMoveNextColumnCell(true);
                    //this.View.UpdateView("F_SZXY_XYDCJXXBEntity");
                    IViewService viewService = ServiceHelper.GetService <IViewService>();
                    //物料编码
                    value = Convert.ToString(fillData.Tables[0].Rows[i]["产品型号"]);

                    if (!value.IsNullOrEmptyOrWhiteSpace())
                    {
                        string RMat = Utils.GetRootMatId(value, orgobj["Id"].ToString(), Context);

                        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);
                    }



                    if (this.Model.GetValue("F_SZXY_operator") is DynamicObject opDo)
                    {
                        value = Convert.ToString(opDo["Id"]);

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

                    this.Model.SetValue("F_SZXY_IsCheck", "true", mm);
                    if (NoType == "FQJY")
                    {
                        //this.Model.SetValue("F_SZXY_NO", Convert.ToString(fillData.Tables[0].Rows[i]["分切编号"]), mm);
                        //DynamicObjectCollection entry1 = this.Model.DataObject["SZXY_XYDCJXXBEntry"] as DynamicObjectCollection;

                        entry1[mm]["F_SZXY_NO"] = Convert.ToString(fillData.Tables[0].Rows[i]["分切编号"]);
                    }


                    //班组
                    value = Convert.ToString(fillData.Tables[0].Rows[i]["班组"]);

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

                    value = Convert.ToString(fillData.Tables[0].Rows[i]["班次"]);

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

                    //工位
                    value = Convert.ToString(fillData.Tables[0].Rows[i]["工位"]);

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

                    value = Convert.ToString(fillData.Tables[0].Rows[i]["特殊标志"]);

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

                    //性能等级
                    value = Convert.ToString(fillData.Tables[0].Rows[i]["性能等级"]);

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


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

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

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

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

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

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

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

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

                    value = Convert.ToString(fillData.Tables[0].Rows[i]["生产日期"]);

                    if (!value.IsNullOrEmptyOrWhiteSpace())
                    {
                        this.Model.SetValue("F_SZXY_Date1", value, mm);
                    }
                    DynamicObject Teamobj = this.Model.GetValue("F_SZXY_Team", mm) as DynamicObject;



                    //string GX = "";

                    string PudType = "";
                    if (View.Model.GetValue("F_SZXY_Material", mm) is DynamicObject Material1)
                    {
                        if (Material1["F_SZXY_Assistant"] is DynamicObject PudTypeObj)
                        {
                            PudType = Convert.ToString(PudTypeObj["Number"]);
                        }
                    }
                    string GX = "";
                    if (PudType.EqualsIgnoreCase("GF"))
                    {
                        GX = "2";
                    }
                    else if (PudType.EqualsIgnoreCase("SF"))
                    {
                        GX = "1";
                    }
                    else if (PudType.Contains("TF"))
                    {
                        GX = "3";
                    }
                    else if (PudType == "")
                    {
                        View.ShowWarnningMessage("请检查产品型号的产品类型!");
                        return;
                    }


                    if (NoType == "FQ")
                    {
                        if (this.Model.GetValue("F_SZXY_BoxNo") is string NewBox)
                        {
                            this.Model.SetValue("F_SZXY_BoxNoE", NewBox, mm);
                        }
                        if (mm > 0 && (mm % Convert.ToInt32(XQty)) == 0)
                        {
                            string BoxNo = GenNo(Context, this.View.BusinessInfo.GetForm().Id, orgobj, Convert.ToDateTime(this.Model.GetValue("FDate")), Teamobj, GX);
                            if (!BoxNo.IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_BoxNo", BoxNo);
                                this.Model.SetValue("F_SZXY_BoxNoE", BoxNo, mm);//
                            }
                        }
                    }
                    //初始化生成箱号

                    if (NoType == "FQJY")
                    {
                        if (mm == 0)
                        {
                            KBNO = GenNo(Context, this.View.BusinessInfo.GetForm().Id, orgobj, Convert.ToDateTime(this.Model.GetValue("FDate")), Teamobj, GX);
                            if (!KBNO.IsNullOrEmptyOrWhiteSpace())
                            {
                                this.Model.SetValue("F_SZXY_BoxNo", KBNO.ToString());      //
                                this.Model.SetValue("F_SZXY_BoxNoE", KBNO.ToString(), mm); //
                            }
                        }
                        else
                        {
                            this.Model.SetValue("F_SZXY_BoxNoE", KBNO, mm);//
                        }
                    }


                    if (erow == 0 && mm == 0 && NoType == "FQ")
                    {
                        string KBNO = GenNo(Context, this.View.BusinessInfo.GetForm().Id, orgobj, Convert.ToDateTime(this.Model.GetValue("FDate")), Teamobj, GX);

                        if (!KBNO.IsNullOrEmptyOrWhiteSpace())
                        {
                            this.Model.SetValue("F_SZXY_BoxNo", KBNO);
                            this.Model.SetValue("F_SZXY_BoxNoE", KBNO, erow);
                        }
                    }



                    this.Model.DataObject["FFormId"] = this.View.BusinessInfo.GetForm().Id;
                    Utils.Save(View, new DynamicObject[] { this.Model.DataObject }, Kingdee.BOS.Orm.OperateOption.Create(), Context);
                    this.View.UpdateView("F_SZXY_XYDCJXXBEntity");
                    this.View.SetEntityFocusRow("F_SZXY_XYDCJXXBEntity", mm + 1);
                }
            }
            else
            {
                this.View.ShowWarnningMessage("没有匹配到数据!"); return;
            }
        }
        private void SetBillValue(Context context, DataSet fillData, IBillView view, int erow, DynamicObject orgobj, string NoType)
        {
            DateTime dt = DateTime.Now;

            if (fillData != null && fillData.Tables.Count > 0 && fillData.Tables[0].Rows.Count > 0)
            {
                string value = "";
                DynamicObjectCollection entry1 = this.Model.DataObject["SZXY_XYCPJYEntry"] as DynamicObjectCollection;


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

                    //if (!Convert.ToString(fillData.Tables[0].Rows[i]["性能等级"]).IsNullOrEmptyOrWhiteSpace() && Convert.ToInt32(fillData.Tables[0].Rows[i]["性能等级"]) > 0)
                    //{
                    this.Model.CreateNewEntryRow("F_SZXY_XYCPJYEntity");

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

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

                    if (!value.IsNullOrEmptyOrWhiteSpace())
                    {
                        string        RMat            = Utils.GetRootMatId(value, orgobj["Id"].ToString(), Context);
                        DynamicObject F_SZXY_Material = this.Model.GetValue("F_SZXY_Material", index) as DynamicObject;
                        if (RMat != "")
                        {
                            Utils.SetBaseDataValue(viewService, entry1[index], (BaseDataField)this.View.BusinessInfo.GetField("F_SZXY_Material"), Convert.ToInt64(RMat), ref F_SZXY_Material, Context);
                        }
                    }

                    if (this.Model.GetValue("F_SZXY_QAINSPECTOH") is DynamicObject opDo)
                    {
                        value = Convert.ToString(opDo["Id"]);

                        if (!value.IsNullOrEmptyOrWhiteSpace())
                        {
                            this.Model.SetValue("F_SZXY_QAInspecto", value, index);
                        }
                    }
                    this.Model.SetValue("F_SZXY_Date", Convert.ToDateTime(this.Model.GetValue("FDate")), index);

                    entry1[index]["F_SZXY_BarCode"] = Convert.ToString(fillData.Tables[0].Rows[i]["分切编号"]);

                    if (!Convert.ToString(fillData.Tables[0].Rows[i]["分切机"]).IsNullOrEmptyOrWhiteSpace())
                    {
                        this.Model.SetValue("F_SZXY_MNo", Convert.ToString(fillData.Tables[0].Rows[i]["分切机"]), index);
                    }

                    if (!Convert.ToString(fillData.Tables[0].Rows[i]["流延机"]).IsNullOrEmptyOrWhiteSpace())
                    {
                        this.Model.SetValue("F_SZXY_LYMac", Convert.ToString(fillData.Tables[0].Rows[i]["流延机"]), index);
                    }

                    if (!Convert.ToString(fillData.Tables[0].Rows[i]["产品编号"]).IsNullOrEmptyOrWhiteSpace())
                    {
                        this.Model.SetValue("F_SZXY_HNO", Convert.ToString(fillData.Tables[0].Rows[i]["产品编号"]), index);
                    }

                    //班组
                    value = Convert.ToString(fillData.Tables[0].Rows[i]["班组"]);

                    if (!value.IsNullOrEmptyOrWhiteSpace())
                    {
                        this.Model.SetValue("F_SZXY_Team", value, index);
                    }

                    value = Convert.ToString(fillData.Tables[0].Rows[i]["班次"]);

                    if (!value.IsNullOrEmptyOrWhiteSpace())
                    {
                        this.Model.SetValue("F_SZXY_Class", value, index);
                    }

                    //工位
                    value = Convert.ToString(fillData.Tables[0].Rows[i]["工位"]);

                    if (!value.IsNullOrEmptyOrWhiteSpace())
                    {
                        this.Model.SetValue("F_SZXY_Station", value, index);
                    }

                    value = Convert.ToString(fillData.Tables[0].Rows[i]["特殊标志"]);

                    if (!value.IsNullOrEmptyOrWhiteSpace())
                    {
                        this.Model.SetValue("F_SZXY_SpecialMark", value, index);
                    }

                    //性能等级
                    value = Convert.ToString(fillData.Tables[0].Rows[i]["性能等级"]);

                    if (!value.IsNullOrEmptyOrWhiteSpace())
                    {
                        this.Model.SetValue("F_SZXY_XNDJ1", value, index);
                    }


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

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

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

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

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

                    if (!value.IsNullOrEmptyOrWhiteSpace())
                    {
                        this.Model.SetValue("F_SZXY_LENGTH", Convert.ToDecimal(value), index);
                    }

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

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



                    //else
                    //{
                    //    this.View.ShowWarnningMessage("此编号没有性能等级!"); return;
                    //}
                    this.View.UpdateView("F_SZXY_XYCPJYEntity");
                    this.View.SetEntityFocusRow("F_SZXY_XYCPJYEntity", index + 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");
            }
            else
            {
                this.View.ShowWarnningMessage("没有匹配到数据!"); return;
            }
        }
Esempio n. 27
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);
        }
        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;
                }
            }
        }
Esempio n. 29
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------------------");
        }