/
CZ_CEEG_BosCrm_SaleOffer.cs
1541 lines (1426 loc) · 64.9 KB
/
CZ_CEEG_BosCrm_SaleOffer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Data;
using System.Collections;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.App.Data;
/*
* 2020-04 关于扣款金额的用途及相关事件说明
* 原则:扣款金额 仅用于行、整单 下浮比例运算 不涉及报价金额的相关运算 表头-扣款金额 锁定
* -原需求定义 表头:总报价=累计报价+扣款金额 拆分报价按钮事件:累计报价=总报价-扣款金额,累计报价按基价权重分配至组
* +调整定义: 表头:总报价=累计报价 拆分报价按钮事件:累计报价=总报价,累计报价(=总报价)按基价权重分配至组
* 相关代码调整:
* DataChanged:FRangeAmt(扣款金额) 注销Act_DC_FRangeAmt(e)方法调用
* DataChanged:FAmtRndRpt(累计报价) 修改Act_DC_FRangeAmt(e),总报价=累计报价
* AfterButtonClick:FRptPrice(分配报价) 扣款金额不参与运算
* 以上调整 相应修改 销售合同评审
*/
namespace CZ.CEEG.BosCrm.SaleOffer
{
/// <summary>
/// BOS_CRM_报价
/// </summary>
[Description("BOS_CRM_报价")]
[Kingdee.BOS.Util.HotUpdate]
public class CZ_CEEG_BosCrm_SaleOffer : AbstractBillPlugIn //AbstractDynamicFormPlugIn
{
#region 明细表体 CRM物料相关基础资料 窗体变量组
/// <summary>
/// 删除Entity行的,保留GUID,供关联删除BPR和Mtl
/// </summary>
ArrayList Al_EntryDelGuID = new ArrayList();
/// <summary>
/// CRM分类 - 独立附件=123323
/// </summary>
string Val_FMtlGroup_XX = "123323";
/// <summary>
/// CRM组件(附件)-主体=123328
/// </summary>
public string Val_FMtlItem_Base { get; set; } = "本体";
//public string Val_FMtlItem_Base { get; set; } = "123328";
/// <summary>
/// 锁定引发变更,当一个流程在执行时,排除其他值更新事件
/// </summary>
string Lock_ChangeVal = "";
/// <summary>
/// 当前登录用户 岗位名称 例:报价员(用于行隐藏设置)
/// </summary>
string Val_FLocalPost = "";
/// <summary>
/// 标签页 材料明细 是否可见 0-不可见 1-可见
/// </summary>
string Val_SeeCrmMtl = "0";
#endregion
#region 汇率 窗体变量组
/// <summary>
/// 1、表单上的创建组织 控件标识
/// 2、如果以其他组织类控件决定币别
/// 3、使用该控件标识 无控件置空""
/// </summary>
string Mkt_FCreateOrg = "FOrgID";
/// <summary>
/// 单据指定币别 控件标识
/// </summary>
string Mkt_FCnyID = "FCurrencyID";
/// <summary>
/// 单据指定本位币 控件标识
/// </summary>
string Mkt_FCnyIDCN = "FCurrencyCN";
/// <summary>
/// 单据指定 汇率类型 控件标识 [页面无此控件可置空]
/// </summary>
string Mkt_FCnyRType = "FRateType";
/// <summary>
/// 单据指定 汇率 值 控件标识
/// </summary>
string Mkt_FRate = "FRate";
#endregion
#region 其他窗体变量 及 预置值
/// <summary>
/// 表体 产品大类列表 ID =FEntity
/// </summary>
string Str_EntryKey_Main = "FEntity";
/// <summary>
/// 表体 报价明细 ID =FBEntryID (BasePriceRound)
/// </summary>
string Str_EntryKey_BPR = "FEntityBPR";
/// <summary>
/// 表体 材料明细 ID =FEntryIDM
/// </summary>
string Str_EntryKey_Mtl = "FEntityM";
#endregion
#region K3 Override
/// <summary>
/// 数据加载完毕
/// </summary>
/// <param name="e"></param>
public override void AfterBindData(EventArgs e)
{
/*
////获取单据体表格, 参数为单据体Key,示例代码假设为FEntity
//Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel.EntryGrid grid = this.View.GetControl<EntryGrid>("FEntity");
////设置第一行的背景色,参数:颜色,6位16进制符号,每2位代表一种基色;从0开始,行序号
//grid.SetRowBackcolor("#FFC080", 0);
////设置第二行F1字段的背景色,参数:字段Key;颜色;行序号
//grid.SetBackcolor("F1", "#FFC080", 1);
*/
Act_Rate_GetOrgCny();
if(this.Context.ClientType.ToString() != "Mobile")
{
//设置结转信息表体
string FNicheNo = this.View.Model.GetValue("FNicheID") == null ? "" : this.View.Model.GetValue("FNicheID").ToString();
//获取持有记录
string sql = string.Format("select FCrmHdOrgID,FCrmHdDept,FCrmHolder,FCrmSN from ora_CRM_Niche where FBILLNO='{0}'", FNicheNo);
var objs = DBUtils.ExecuteDynamicObject(this.Context, sql);
if (objs.Count > 0)
{
//创建持有记录表体
int cnt = this.View.Model.GetEntryRowCount("FEntityHD");
if (cnt <= 0) this.View.Model.CreateNewEntryRow("FEntityHD");
if (cnt == 1)
{
this.View.Model.SetItemValueByID("FHHdOrgID", objs[0]["FCrmHdOrgID"].ToString(), 0);//持有组织
this.View.Model.SetItemValueByID("FHHdDept", objs[0]["FCrmHdDept"].ToString(), 0);//持有部门
this.View.Model.SetItemValueByID("FHHolder", objs[0]["FCrmHolder"].ToString(), 0);//持有人
this.View.Model.SetValue("FHSN", objs[0]["FCrmSN"].ToString(), 0);//CRM标识码
this.View.Model.SetValue("FHBegDate", DateTime.Now.ToString("yyyy-MM-dd"), 0);//生效日期
this.View.Model.SetValue("FHEndDate", "9999-12-31", 0);//失效日期
}
}
}
string _billStatus = this.CZ_GetFormStatus();
if (_billStatus == "Z")
{
//Act_Hold_GetHoldInfo(this.Context.UserId.ToString());
if (this.CZ_GetValue_DF("FCrmHolder", "Id", "0") == "0")
{
//Act_Hold_GetHoldInfo("157191");
Act_Hold_GetHoldInfo(this.Context.UserId.ToString());
}
//汇率
Act_Rate_GetRate(this.CZ_GetValue_DF("FCreateDate", ""));
}
//创建 或暂存下 检测Entry的FGUID,没有则写入
if (_billStatus == "Z" || _billStatus == "A")
{
Act_ABD_ChkGUID(e);
}
//取用户授权 明细信息列表授权 物料分类
string _FUserID = this.View.Context.UserId.ToString();
string _sql = "exec proc_cztyCrm_OfferGetMtlGroup @FUserID='" + _FUserID + "'";
string _crmFilter = "";
try
{
DataTable _dt = this.CZDB_SearchBase(_sql);
_crmFilter = _dt.Rows[0]["FIDFilter"].ToString();
Val_FLocalPost = _dt.Rows[0]["FPostName"].ToString();
Val_SeeCrmMtl = _dt.Rows[0]["F_Ora_SeeCrmMtl"].ToString();
this.View.Model.SetValue("FLocalFilter", _crmFilter);
}
catch (Exception _ex)
{
return;
}
if (Val_SeeCrmMtl == "0")
{
this.View.StyleManager.SetVisible("F_ora_Tab1_P4", null, false);
}
if (Val_FLocalPost == "报价员")
{
Act_CtrlRow_SetHideMkt(Str_EntryKey_Main, "FMtlGroup", "FIS2W");
Act_EntityFilter(Str_EntryKey_Main, "FIS2W");
Act_CtrlRow_SetHideMkt(Str_EntryKey_BPR, "FBMtlGroup", "FBIS2W");
Act_EntityFilter(Str_EntryKey_BPR, "FBIS2W");
Act_CtrlRow_SetHideMkt(Str_EntryKey_Mtl, "FMMtlGroup", "FMIS2W");
Act_EntityFilter(Str_EntryKey_Mtl, "FMIS2W");
}
else
{
//隐藏 计价计算单 表体菜单按钮 (GetBarItem(EntryKey,BarItemKey)-表体菜单 GetMainBarItem(BarItemKey)-主菜单)
this.View.GetBarItem(Str_EntryKey_Main, "tbBPRnd").Visible = false;
}
}
/// <summary>
/// 添加行后
/// </summary>
/// <param name="e"></param>
public override void AfterCreateNewEntryRow(CreateNewEntryEventArgs e)
{
base.AfterCreateNewEntryRow(e);
Act_AfterCNER(e);
}
/// <summary>
/// 删除行前 记录 删除行的信息 留后续处理(删除BRP表、Mtl表关联行)
/// </summary>
/// <param name="e"></param>
public override void BeforeDeleteRow(BeforeDeleteRowEventArgs e)
{
base.BeforeDeleteRow(e);
if (e.EntityKey == Str_EntryKey_Main)
{
//Al_EntryDelGuID = new ArrayList();
//string _rowFGUID = this.CZ_GetRowValue_DF("FGUID", "Id", e.Row, "");
string _rowFGUID = this.CZ_GetRowValue_DF("FGUID", e.Row, "");
if (_rowFGUID != "" && !Al_EntryDelGuID.Contains(_rowFGUID))
{
Al_EntryDelGuID.Add(_rowFGUID);
}
}
}
public override void AfterDeleteRow(AfterDeleteRowEventArgs e)
{
////tbDeleteEntry 按钮-删除行
//Act_AfterEBIC_tbDeleteEntry();
////Act_EntityFilter(Str_EntryKey_Main, "FIS2W");
//Act_AEBIC_ReSetFilter();
//base.AfterDeleteRow(e);
}
/// <summary>
/// 值更新 物料组-附件-分组号[项次] | 基本单价-数量-报价 : 基价合计 : 总基价-总报价-【扣款】
/// </summary>
/// <param name="e"></param>
public override void DataChanged(DataChangedEventArgs e)
{
string _key = e.Field.Key.ToUpperInvariant();
if (Lock_ChangeVal != "")
{
return;
}
switch (_key)
{
//多币别 汇率相关属性 变动
case "FCURRENCYID":
//FCurrencyID 币别
Act_Rate_GetRate(this.CZ_GetValue_DF("FCreateDate", ""));
break;
case "FRATE":
//汇率 FRate
Act_DC_FRate(e);
break;
//基本信息| 表头信息
case "FRANGEAMT": //表头 FRangeAmt 扣款金额
//Act_DC_FRangeAmt(e);
//Act_DC_RndFBDownPoints();
break;
case "FAMTRNDRPT": //表头 FAmtRndRpt E表报价和
Act_DC_FRangeAmt(e);
//Act_DC_RndFBDownPoints();
break;
case "FAMOUNTRPT": //表头 FAmountRpt 总报价
Act_DC_FAmountRpt(e);
break;
case "FAMOUNT": //表头 FAmount 总基价
Act_DC_FAmount(e);
//Act_DC_RndFBDownPoints();
break;
case "FCRMHDDEPT": //FCrmHdDept
break;
//明细信息
case "FQTY": //行 FQty 数量
//Act_DC_BP8Qty(e);
//Act_DC_RndAmount();
break;
case "FBRPTPRICE": //行 FBRptPrice 报价
Act_DC_FBRptPrice(e);
break;
case "FBRANGEAMTONE": //单台扣款 FBRangeAmtOne
Act_DC_FBRangeAmtOne(e);
break;
case "FBRANGEAMTGP": //汇总扣款 FBRangeAmtGP
Act_DC_FBRangeAmtGP(e);
break;
//基价计算单 值更新方法组
default:
break;
}
base.DataChanged(e);
}
/// <summary>
/// 值更新前 验证用 条件排除
/// </summary>
/// <param name="e"></param>
public override void BeforeUpdateValue(BeforeUpdateValueEventArgs e)
{
string _key = e.Key.ToUpperInvariant();
if (Lock_ChangeVal != "")
{
return;
}
switch (_key)
{
case "FBRANGEAMTONE": //单台扣款 FBRangeAmtOne
string _FBPRndSEQ = this.CZ_GetRowValue_DF("FBPRndSEQ", e.Row, "0");
if (_FBPRndSEQ != "1")
{
e.Cancel = true;
}
break;
//case "FQTY": //测试用
// if (e.Row != 0)
// {
// e.Cancel = true;
// }
// break;
default:
break;
}
base.BeforeUpdateValue(e);
}
/// <summary>
/// 按钮事件
/// <param name="e"></param>
public override void AfterButtonClick(AfterButtonClickEventArgs e)
{
string _key = e.Key.ToUpperInvariant();
switch (_key)
{
case "FBTNTEST": //测试按钮
//Act_Control_Visable();
break;
case "FBTNANZRPT": //FRptPrice 分配报价
Act_BC_AnzFRptPrice();
//Act_DC_RndFBDownPoints();
break;
default:
break;
}
base.AfterButtonClick(e);
}
/// <summary>
/// 单据体 菜单按钮事件
/// </summary>
/// <param name="e"></param>
public override void AfterEntryBarItemClick(AfterBarItemClickEventArgs e)
{
base.AfterEntryBarItemClick(e);
string _key = e.BarItemKey.ToUpperInvariant();
switch (_key)
{
case "TBNEWLIST":
//tbNewList 下拉按钮-新增行
//Act_EntityFilter(Str_EntryKey_Main, "FIS2W");
Act_AEBIC_ReSetFilter();
break;
case "TBNEWENTRY":
//tbNewEntry 按钮-新增行
//Act_EntityFilter(Str_EntryKey_Main, "FIS2W");
Act_AEBIC_ReSetFilter();
break;
case "TBINSERtENTRY":
//tbInsertEntry 按钮-插入行
//Act_EntityFilter(Str_EntryKey_Main, "FIS2W");
Act_AEBIC_ReSetFilter();
break;
case "TBDELETEENTRY":
//tbDeleteEntry 按钮-删除行
Act_AfterEBIC_tbDeleteEntry();
//Act_EntityFilter(Str_EntryKey_Main, "FIS2W");
Act_AEBIC_ReSetFilter();
break;
case "TBBPRND":
Act_AfterEBIC_tbBPRnd(e);
//tbBPRnd 打开基价计算单
break;
default:
break;
}
}
/// <summary>
/// 在根据编码检索数据之前调用;
/// 通过重载本事件,可以设置必要的过滤条件,以限定检索范围;
/// 还可以控制当前过滤是否启用组织隔离,数据状态隔离
/// </summary>
/// <param name="e"></param>
public override void BeforeSetItemValueByNumber(BeforeSetItemValueByNumberArgs e)
{
string _crmFilter;
switch (e.BaseDataField.Key.ToUpperInvariant())
{
//case "FXXX":通过字段的Key[大写]来区分不同的基础资料
//e.Filter = "FXXX= AND fxxy=";过滤的字段使用对应基础资料的字段的Key,支持ksql语法
//break;
case "FMTLGROUP":
_crmFilter = this.CZ_GetValue("FLocalFilter");
if (_crmFilter != "")
{
e.Filter = " FID in(" + _crmFilter + ")";
}
break;
default:
break;
}
}
/// <summary>
/// 显示基础资料列表之前调用
/// 通过重载本事件,可以设置必要的过滤条件,以限定检索范围;
/// </summary>
/// <param name="e"></param>
public override void BeforeF7Select(BeforeF7SelectEventArgs e)
{
string _crmFilter;
switch (e.FieldKey.ToUpperInvariant())
{
//case "FXXX":通过字段的Key[大写]来区分不同的基础资料
// e.ListFilterParameter.Filter = "FXXX= AND fxxy=";过滤的字段使用对应基础资料的字段的Key,支持ksql语法
//break;
case "FMTLGROUP":
_crmFilter = this.CZ_GetValue("FLocalFilter");
if (_crmFilter != "")
{
e.ListFilterParameter.Filter = " FID in(" + _crmFilter + ")";
}
break;
default:
break;
}
base.BeforeF7Select(e);
}
/// <summary>
/// 单据持有事件变更
/// </summary>
/// <param name="e"></param>
public override void AfterDoOperation(AfterDoOperationEventArgs e)
{
base.AfterDoOperation(e);
string _eOpActName = e.Operation.Operation.ToUpperInvariant();
switch (_eOpActName)
{
//case "SAVE": 表单定义的事件都可以在这里执行,需要通过事件的代码[大写]区分不同事件
//break;
case "SAVE":
Act_AfterDO_Save();
//this.View.Refresh();
break;
default:
break;
}
}
#endregion
#region Actions
/// <summary>
/// 隐藏元素
/// </summary>
private void Act_Control_Visable()
{
this.View.StyleManager.SetVisible("F_ora_Tab1_P4", null, false);
}
/// <summary>
/// 保存后调用
/// </summary>
private void Act_AfterDO_Save()
{
string _billStatus = this.CZ_GetFormStatus();
string _FID = this.CZ_GetFormID();
if (_billStatus == "Z")
{
return;
}
string _sql = "exec proc_cztyCrm_SaleOffer_AfterSave @FID='" + _FID + "'";
DataTable _dt = this.CZDB_SearchBase(_sql);
if (_dt.Rows.Count > 0)
{
this.View.Refresh();
}
}
#region Action - 报价相关方法 包含扣款方法
/// <summary>
/// 报价表体 值更新事件 单台扣款 FBRangeAmtOne
/// </summary>
/// <param name="e"></param>
private void Act_DC_FBRangeAmtOne(DataChangedEventArgs e)
{
double _FBQty = double.Parse(this.CZ_GetRowValue_DF("FBQty", e.Row, "0"));
double _FBRangeAmtOne = double.Parse(this.CZ_GetRowValue_DF("FBRangeAmtOne", e.Row, "0"));
this.View.Model.SetValue("FBRangeAmtGP", _FBQty * _FBRangeAmtOne, e.Row);
}
/// <summary>
/// 报价表体 值更新事件 汇总扣款 FBRangeAmtGP
/// </summary>
/// <param name="e"></param>
private void Act_DC_FBRangeAmtGP(DataChangedEventArgs e)
{
//double _eValOld = e.OldValue == null ? 0 : double.Parse(e.OldValue.ToString());
//double _eValNew = e.NewValue == null ? 0 : double.Parse(e.NewValue.ToString());
//double _FRangeAmt = double.Parse(this.CZ_GetValue_DF("FRangeAmt", "0"));
//this.View.Model.SetValue("FRangeAmt", _FRangeAmt - _eValOld + _eValNew);
double _FRangeAmt = 0;
int _maxIdx = this.View.Model.GetEntryRowCount(Str_EntryKey_BPR);
for (int i = 0; i < _maxIdx; i++)
{
string _FBPRndSEQ = this.CZ_GetRowValue_DF("FBPRndSEQ", i, "0");
if (_FBPRndSEQ != "1")
{
continue;
}
double _FBRangeAmtGP = double.Parse(this.CZ_GetRowValue_DF("FBRangeAmtGP", i, "0").ToString());
_FRangeAmt += _FBRangeAmtGP;
}
this.View.Model.SetValue("FRangeAmt", _FRangeAmt);
Act_DC_RndFBDownPoints(e.Row, true);
}
/// <summary>
/// 报价改变
/// </summary>
/// <param name="e"></param>
private void Act_DC_FAmountRpt(DataChangedEventArgs e)
{
double _FRate = Double.Parse(this.CZ_GetValue_DF("FRate", "0"));
double _newValue = e.NewValue == null ? 0 : Double.Parse(e.NewValue.ToString());
this.View.Model.SetValue("FAmtRptCN", _FRate * _newValue);
}
/// <summary>
/// 总基价改变
/// </summary>
/// <param name="e"></param>
private void Act_DC_FAmount(DataChangedEventArgs e)
{
double _FRate = Double.Parse(this.CZ_GetValue_DF("FRate", "0"));
double _newValue = e.NewValue == null ? 0 : Double.Parse(e.NewValue.ToString());
this.View.Model.SetValue("FAmtCN", _FRate * _newValue);
}
/// <summary>
/// 扣款金额 报价行合计发生改变
/// </summary>
/// <param name="e"></param>
private void Act_DC_FRangeAmt(DataChangedEventArgs e)
{
//double _FRate = Double.Parse(this.CZ_GetValue_DF("FRate", "0"));
//double _FRangeAmt = Double.Parse(this.CZ_GetValue_DF("FRangeAmt", "0"));
double _FAmtRndRpt = Double.Parse(this.CZ_GetValue_DF("FAmtRndRpt", "0"));
//this.View.Model.SetValue("FAmountRpt", _FRangeAmt + _FAmtRndRpt);
this.View.Model.SetValue("FAmountRpt", _FAmtRndRpt);
this.View.InvokeFieldUpdateService("FAmountRpt", 0);
}
/// <summary>
/// 行报价变更 更新表头报价行合计 重算下浮
/// </summary>
/// <param name="e"></param>
private void Act_DC_FBRptPrice(DataChangedEventArgs e)
{
double _FRate = Double.Parse(this.CZ_GetValue_DF("FRate", "0"));
double _newValue = e.NewValue == null ? 0 : Double.Parse(e.NewValue.ToString());
double _oldValue = e.OldValue == null ? 0 : Double.Parse(e.OldValue.ToString());
double _FAmtRndRpt = Double.Parse(this.CZ_GetValue_DF("FAmtRndRpt", "0"));
this.View.Model.SetValue("FAmtRndRpt", _FAmtRndRpt - _oldValue + _newValue);
this.View.Model.SetValue("FBRptPrcLc", _newValue * _FRate, e.Row);
Act_DC_RndFBDownPoints(e.Row, true);
}
/// <summary>
/// 分配报价
/// </summary>
private void Act_BC_AnzFRptPrice()
{
double _FRate = Double.Parse(this.CZ_GetValue_DF("FRate", "0"));
int _maxCnt = this.View.Model.GetEntryRowCount(Str_EntryKey_BPR);
if (_maxCnt == 0)
{
return;
}
Lock_ChangeVal = "Act_BC_AnzFRptPrice";
double _FAmount = Double.Parse(this.CZ_GetValue_DF("FAmount", "0")); //总基价
double _FAmountRpt = Double.Parse(this.CZ_GetValue_DF("FAmountRpt", "0")); //总报价
double _FRangeAmt = Double.Parse(this.CZ_GetValue_DF("FRangeAmt", "0")); //扣款金额
//double _FAmtRndRpt = _FAmountRpt - _FRangeAmt; //分配到行的报价和 //
double _FAmtRndRpt = _FAmountRpt;
this.View.Model.SetValue("FAmtRndRpt", _FAmtRndRpt);
//计算基数
string _rowFBMtlItem = ""; //行物料
double _rowFBRptPrice = 0; //行报价
double _rowFBPAmt = 0; //行基价金额
double _rowFBPAmtGroup = 0; //产品基价合计
double _rndSumPBA = 0; //用于计算的基价分母合计
double _rowFBUnitRPTPrice = 0;//行 单台报价
double _rowFBQty = 0;
_rndSumPBA = _FAmount; //基价分母合计=总基价
#region 已注销代码段
//for (int i = 0; i < _maxCnt; i++)
//{
// _rowFBMtlItem = this.CZ_GetRowValue_DF("FBMtlItem", "Id", i, "0");
// _rowFBRptPrice = Double.Parse(this.CZ_GetRowValue_DF("FBRptPrice", i, "0"));
// _rowFBPAmt = Double.Parse(this.CZ_GetRowValue_DF("FBPAmt", i, "0"));
// _rowFBPAmtGroup = Double.Parse(this.CZ_GetRowValue_DF("FBPAmtGroup", i, "0"));
// if (_rowFBMtlItem != Val_FMtlItem_Base && _rowFBRptPrice == 0)
// {
// continue;
// }
// if (_rowFBMtlItem == Val_FMtlItem_Base)
// {
// _rndSumPBA += _rowFBPAmtGroup;
// continue;
// }
// if (_rowFBMtlItem != Val_FMtlItem_Base && _rowFBRptPrice != 0)
// {
// _rndSumPBA += _rowFBPAmt;
// continue;
// }
//}
#endregion
//分配报价 分配至有产品基价合计的行 其他行报价置空
//double _rndAmtBP = 0; //用于计算分配的基价分子
for (int i = 0; i < _maxCnt; i++)
{
_rowFBMtlItem = this.CZ_GetRowValue_DF("FBMtlItem", "Id", i, "0");
_rowFBRptPrice = Double.Parse(this.CZ_GetRowValue_DF("FBRptPrice", i, "0"));
_rowFBPAmt = Double.Parse(this.CZ_GetRowValue_DF("FBPAmt", i, "0"));
_rowFBPAmtGroup = Double.Parse(this.CZ_GetRowValue_DF("FBPAmtGroup", i, "0"));
_rowFBQty = Double.Parse(this.CZ_GetRowValue_DF("FBQty", i, "0"));
#region 已注销代码段
//if (_rowFBMtlItem == Val_FMtlItem_Base || _rowFBRptPrice != 0)
//{
// _rndAmtBP = _rowFBPAmtGroup == 0 ? _rowFBPAmt : _rowFBPAmtGroup;
// _rowFBRptPrice = _rndAmtBP * _FAmtRndRpt / _rndSumPBA;
// this.View.Model.SetValue("FBRptPrice", _rowFBRptPrice, i);
// this.View.Model.SetValue("FBRptPrcLc", _rowFBRptPrice * _FRate, i);
// Act_DC_RndFBDownPoints(i);
//}
#endregion
_rowFBRptPrice = _rowFBPAmtGroup > 0 ? (_rowFBPAmtGroup * _FAmtRndRpt / _rndSumPBA) : 0;
_rowFBUnitRPTPrice = _rowFBQty == 0 ? 0 : _rowFBRptPrice / _rowFBQty;
this.View.Model.SetValue("FBRptPrice", _rowFBRptPrice, i);
this.View.Model.SetValue("FBRptPrcLc", _rowFBRptPrice * _FRate, i);
this.View.Model.SetValue("FBUnitRPTPrice", _rowFBUnitRPTPrice, i);
Act_DC_RndFBDownPoints(i, false);
}
Act_DC_RndFBDownPoints();
Lock_ChangeVal = "";
}
/// <summary>
/// 计算行 下浮点数%
/// </summary>
/// <param name="_rowIdx"></param>
/// <param name="_doBillRnd">是否启动表单计算</param>
private void Act_DC_RndFBDownPoints(int _rowIdx, bool _doBillRnd)
{
string _eFBGUID = this.CZ_GetRowValue_DF("FBGUID", _rowIdx, "0");
string _eFBPRndSEQ = this.CZ_GetRowValue_DF("FBPRndSEQ", _rowIdx, "0");
double _rowFRptPrice = 0;
int _mainIdx = 0;
double _FRptPrice = 0;
int _maxIdx = this.View.Model.GetEntryRowCount(Str_EntryKey_BPR);
for (int i = 0; i < _maxIdx; i++)
{
string _FBGUID = this.CZ_GetRowValue_DF("FBGUID", i, "0");
if (_eFBGUID != _FBGUID)
{
continue; //不同GUID的行 跳出
}
string _FBPRndSEQ = this.CZ_GetRowValue_DF("FBPRndSEQ", i, "0");
if (_FBPRndSEQ == "1")
{
_mainIdx = i; //计算单行号=1 记录主行
}
_rowFRptPrice = Double.Parse(this.CZ_GetRowValue_DF("FBRptPrice", i, "0"));
_FRptPrice += _rowFRptPrice;
}
_rowIdx = _mainIdx;
//double _FRptPrice = Double.Parse(this.CZ_GetRowValue_DF("FBRptPrice", _rowIdx, "0")); //报价
double _FBPAmtGroup = Double.Parse(this.CZ_GetRowValue_DF("FBPAmtGroup", _rowIdx, "0")); //产品基价合计
double _FBPAmt = Double.Parse(this.CZ_GetRowValue_DF("FBPAmt", _rowIdx, "0")); //行基价金额
double _FBRangeAmtGP = Double.Parse(this.CZ_GetRowValue_DF("FBRangeAmtGP", _rowIdx, "0")); //行汇总扣款
double _FRndRowBP = _FBPAmtGroup; //_FBPAmtGroup == 0 ? _FBPAmt : _FBPAmtGroup;
double _FBDownPoints = 0;
//下浮点数% (基价-报价)*100/报价,只算组1行
//2020-04 修改公式下浮比例%=(基价-行报价+扣款)*100/基价
//this.View.Model.SetValue("FBDownPoints", _FRptPrice == 0 ? 0 : (_FRndRowBP - _FRptPrice) * 100 / _FRptPrice, _rowIdx);
if (_FRptPrice != 0 && _FRndRowBP != 0) //当用于计算的基价 或 报价 存在=0时,设下浮点数=0
{
_FBDownPoints = (_FRndRowBP - _FRptPrice + _FBRangeAmtGP) * 100 / _FRndRowBP;
}
this.View.Model.SetValue("FBDownPoints", _FBDownPoints, _rowIdx);
if (_doBillRnd)
{
Act_DC_RndFBDownPoints();
}
}
/// <summary>
/// 计算表头 下浮点数%
/// </summary>
private void Act_DC_RndFBDownPoints()
{
double _FMaxDnPts = 0; //最大下浮比
double _rowDownPoints = 0; //行下浮比
int _rowCont = this.View.Model.GetEntryRowCount(Str_EntryKey_BPR);
for (int i = 0; i < _rowCont; i++)
{
_rowDownPoints = double.Parse(this.CZ_GetRowValue_DF("FBDownPoints", i, "0"));
if (_rowDownPoints == 0)
{
continue;
}
_FMaxDnPts = _FMaxDnPts > _rowDownPoints ? _FMaxDnPts : _rowDownPoints;
}
double _FAvgDnPts = 0; //平均下浮
double _FAmountRpt = double.Parse(this.CZ_GetValue_DF("FAmountRpt", "0")); //总报价
double _FAmount = double.Parse(this.CZ_GetValue_DF("FAmount", "0")); //总基价
double _FRangeAmt = double.Parse(this.CZ_GetValue_DF("FRangeAmt", "0")); //扣款金额
if (_FAmount != 0)
{
_FAvgDnPts = (_FAmount - _FAmountRpt + _FRangeAmt) * 100 / _FAmount;
}
this.View.Model.SetValue("FMaxDnPts", _FMaxDnPts);
this.View.Model.SetValue("FAvgDnPts", _FAvgDnPts);
}
/// <summary>
/// 重新合计报价
/// </summary>
private void Act_Do_RndSumFRptPrice()
{
int _maxCnt = this.View.Model.GetEntryRowCount(Str_EntryKey_BPR);
double _FAmtRndRpt = 0; //小数2 累计报价
double _rowFBRptPrice = 0;
double _rowFAmount = 0; //总基价
for (int i = 0; i < _maxCnt; i++)
{
_rowFBRptPrice = Double.Parse(this.CZ_GetRowValue_DF("FBRptPrice", i, "0"));
_FAmtRndRpt += _rowFBRptPrice;
}
this.View.Model.SetValue("FAmtRndRpt", _FAmtRndRpt);
}
#endregion
/// <summary>
/// 获取单据所有权(持有)数据 从登录用户 返回主任岗位的 数据链
/// </summary>
/// <param name="_FHolder">单据持有人 maybe Holder|Creator</param>
private void Act_Hold_GetHoldInfo(string _FHolder)
{
//string _FHolder = this.Context.UserId.ToString();
string _FHoldOrgID = "";
string _FHoldDeptID = "";
string _FCrmSN = "";
string _sql = "exec proc_cztyCrm_GetCrmSN @FUserID='" + _FHolder + "'";
DataTable _dt = this.CZDB_SearchBase(_sql);
if (_dt.Rows.Count == 0)
{
return;
}
//FUserID FEmpID FEmpName FDeptID FDeptOrg FLevelCode FPostID FLeaderPost
//157191 157131 郭俊 156178 156139 .156178. 157121 1
_FHoldOrgID = _dt.Rows[0]["FDeptOrg"].ToString();
_FHoldDeptID = _dt.Rows[0]["FDeptID"].ToString();
_FCrmSN = _dt.Rows[0]["FLevelCode"].ToString();
this.View.Model.SetValue("FCrmHdOrgID", _FHoldOrgID);
this.View.Model.SetValue("FCrmHdDept", _FHoldDeptID);
this.View.Model.SetValue("FCrmHolder", _FHolder);
this.View.Model.SetValue("FCrmSN", _FCrmSN);
int _EHdRowCnt = this.View.Model.GetEntryRowCount("FEntityHD");
if (_EHdRowCnt == 1)
{
this.View.Model.SetValue("FHHdOrgID", _FHoldOrgID, 0);
this.View.Model.SetValue("FHHdDept", _FHoldDeptID, 0);
this.View.Model.SetValue("FHHolder", _FHolder, 0);
this.View.Model.SetValue("FHSN", _FCrmSN, 0);
this.View.Model.SetValue("FHBegDate", DateTime.Now.ToString("yyyy-MM-dd"), 0);
this.View.Model.SetValue("FHEndDate", "9999-12-31", 0);
}
}
#region 作废的方法
/*
/// <summary>
/// 计算行过滤 需要过滤时 标记行
/// 跟据Crm产品类别确认明细信息是否可显示行
/// 提取【明细信息】可显示的分组号限定【基价计算单】的分组号 用于限定显示及使用
/// </summary>
private void Act_CtrlRow_SetHideMkt()
{
string _crmFilter = this.CZ_GetValue("FLocalFilter");
if (_crmFilter == "")
{
return;
}
ArrayList _alCrmMtlGroup = new ArrayList();
_alCrmMtlGroup.AddRange(_crmFilter.Split(','));
//AL_EntryBPRFilter = new ArrayList();
int _rowCnt = this.View.Model.GetEntryRowCount("FEntity");
string _rowFMtlGroup = "0";
//string _rowFDataGroup = "0";
string _rowFIS2W = "0";
for (int i = 0; i < _rowCnt; i++)
{
_rowFMtlGroup = this.CZ_GetRowValue_DF("FMtlGroup", "Id", i, "0");
if (_rowFMtlGroup == "0")
{
_rowFIS2W = "0";
}
else
{
_rowFIS2W = _alCrmMtlGroup.Contains(_rowFMtlGroup) ? "0" : "1";
}
this.View.Model.SetValue("FIS2W", _rowFIS2W, i);
}
}
*/
#endregion
/// <summary>
/// 设置隐藏
/// </summary>
/// <param name="_entity">子表体ID</param>
/// <param name="_FMtlG_Col">列名 CRM产品大类</param>
/// <param name="_FHide_Col">列名 判定隐藏列</param>
private void Act_CtrlRow_SetHideMkt(string _entity, string _FMtlG_Col, string _FHide_Col)
{
string _crmFilter = this.CZ_GetValue("FLocalFilter");
if (_crmFilter == "")
{
return;
}
ArrayList _alCrmMtlGroup = new ArrayList();
_alCrmMtlGroup.AddRange(_crmFilter.Split(','));
//AL_EntryBPRFilter = new ArrayList();
int _rowCnt = this.View.Model.GetEntryRowCount(_entity);
string _rowFMtlGroup = "0"; //行 物料分类
string _rowFIS2W = "0"; //行是否隐藏
for (int i = 0; i < _rowCnt; i++)
{
_rowFMtlGroup = this.CZ_GetRowValue_DF(_FMtlG_Col, "Id", i, "0");
if (_rowFMtlGroup == "0")
{
_rowFIS2W = "0";
}
else
{
_rowFIS2W = _alCrmMtlGroup.Contains(_rowFMtlGroup) ? "0" : "1";
}
this.View.Model.SetValue(_FHide_Col, _rowFIS2W, i);
}
}
#region 废弃的方法
/*
/// <summary>
/// FEntity表体 报价员 按授权 CRM-产品分类 过滤 明细信息表体
/// </summary>
private void Act_EntityFilter()
{
if (Val_FLocalPost != "报价员")
{
return;
}
string _crmFilter = this.CZ_GetValue("FLocalFilter");
if (_crmFilter == "")
{
return;
}
EntryGrid grid = this.View.GetControl<EntryGrid>("FEntity");
String filter = string.Format("FIS2W=0 or FIS2W=''");
grid.SetFilterString(filter);
//grid.SetCustomPropertyValue("AllowSorting", false);
//this.View.UpdateView("FEntity");
}
*/
#endregion
/// <summary>
/// 过滤 明细信息表体
/// </summary>
/// <param name="_entity">子表体ID</param>
/// <param name="_FHide_Col">列名 判定隐藏列</param>
private void Act_EntityFilter(string _entity, string _FHide_Col)
{
if (Val_FLocalPost != "报价员")
{
return;
}
string _crmFilter = this.CZ_GetValue("FLocalFilter");
if (_crmFilter == "")
{
return;
}
EntryGrid grid = this.View.GetControl<EntryGrid>(_entity);
//String filter = string.Format(_FHide_Col + "=0 or " + _FHide_Col + "=''");
String filter = "";
if (this.Context.ClientType.ToString() == "WPF")
{
//filter = string.Format(" {0}=0 or {1}='' ", _FHide_Col, _FHide_Col);
filter = string.Format(_FHide_Col + "='0' or " + _FHide_Col + "=''");
}
else
{
filter = _FHide_Col + "=''";
//filter = string.Format(_FHide_Col + "=''");
}
grid.SetFilterString(filter);
grid.SetCustomPropertyValue("AllowSorting", false);
this.View.UpdateView(_entity);
}
/// <summary>
/// 单据体 刷新后 根据客户端类型 启动隐藏行重置
/// </summary>
private void Act_AEBIC_ReSetFilter()
{
string ClientType = this.Context.ClientType.ToString();
if (ClientType == "WPF")
{
Act_EntityFilter(Str_EntryKey_Main, "FIS2W");
}
}
/// <summary>
/// 添加行后 Entity主表体 生成GUID
/// </summary>
/// <param name="e"></param>
private void Act_AfterCNER(CreateNewEntryEventArgs e)
{
string _EntryName = e.Entity.DynamicObjectType.ToString(); //引发事件的表体名 FEntity-明细信息 | FEntityBPR-基价计算表体
string _FEGuID = "";
if (_EntryName == Str_EntryKey_Main)
{
_FEGuID = this.CZ_GetRowValue_DF("FGUID", e.Row, "");
if (_FEGuID == "")
{
//_FEGuID = new System.Guid().ToString();
this.View.Model.SetValue("FGUID", System.Guid.NewGuid().ToString(), e.Row);
this.View.Model.SetValue("FIS2W", "0", e.Row);
//this.View.Model.SetValue(Str_ItemVisCol_Main, "0", e.Row);
}
}