1.本篇主要介绍销售报价单设计,界面如下:
这里我们要用极致平台实现如下功能:
1.界面的往来单位,不管手动输入还是到往来单位一览表,都只能选择是客户的往来单位,利用文本框的AutoDropDownListFilter即可实现
2.输入往来单位,自动将该往来单位的结算方式带出来,并可以修改,利用携带并且映射界面即可实现。
3.初始化的时候,界面的组织机构,部门,职员自动填充当前用户所对应的职员。
4.初始化的时候币别默认为人民币汇率为1,选择币别,自动将该组织的该币别的汇率带出,利用极致平台提供的汇率有固定汇率和浮动汇率两种,只要事先在初始化的时候设置好币别汇率即可。其他代码实现选择币别自动带出汇率。
5.子表选择物料后,自动将物料的单位,规格型号自动带出来,并且映射到单据子表的规格型号单位上,使用者还可以对其进行修改。
6.输入了物料的单位,数量后自动根据销售价格记录表自动算出该物料的价格,如果没有该物料的价格,保存后,点击更新价格,将该客户的单价体系更新到价格体系表中。
7.销售的过程中,点击即时库存页签可以看到本次报价的物料库存情况。也可以点击菜单上的即时库存,可以查看本次报价物料的库存情况。
8.自动将子表价格汇总到父表,以方便在使用的时候根据金额走流程,比如金额大于100万的,自动跑到总经理处,让总经理过目。有了如此设计,后续才会非常方便灵活定义工作流。
9.因为我们引用了期间管理,那么报价肯定不能允许使用者还做几年前的报价,只能做当前期间及以后的报价。所以我们需要在服务端写个基类来判断当前单据的日期是否在当前期间。
下面是实现上诉各种复杂功能的客户端代码:
/// <summary> /// 销售报价单 /// </summary> class SaleBaojia : SCMBaseBill { } /// <summary> /// SCM单据管理基类 /// </summary> class SCMBaseBill : Jeez.MulEntityInput.BaseBillUI { //控件声明定义 private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txWLDW;//往来单位 private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txOrg;//组织机构 private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txDept;//部门 private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txEmployee;//业务员 private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txBibie;//币别 private Jeez.Control.JeezNumberTextBox.JeezNumberTextBox txRat;//汇率 private Jeez.Control.JeezCurrencyTextBox.JeezCurrencyTextBox txYBMoney;//原币金额 private Jeez.Control.JeezCurrencyTextBox.JeezCurrencyTextBox txYBYF;//原币运费 private Jeez.Control.JeezCurrencyTextBox.JeezCurrencyTextBox txRMBMoney;//人民币金额 private Jeez.Control.JeezCurrencyTextBox.JeezCurrencyTextBox txRMBYF;//人民币运费 private Jeez.Control.JeezUltraCalendarCombo.JeezUltraCalendarCombo dtDate;//日期 private Jeez.Control.JeezGrid.JeezGrid gridZY;//明细grid private Jeez.Control.JeezUltraTabControl.JeezUltraTabControl pagecontrol1 = null;//下方页框控件 private Jeez.Control.JeezGrid.JeezGrid gridKucun;//库存 private Jeez.Control.JeezGrid.JeezGrid gridBaojiaHistory;//历史报价 private bool isLoading=true; //定义几个初始化常见的值 private static int BibieID=0;//默认币别ID private static int WLDWID = 0;//默认往来单位ID /// <summary> /// 加载控件,以及控件相关事件定义 /// </summary> /// <returns></returns> public override bool LoadUI() { bool b = base.LoadUI(); if (b) { txWLDW = base.GetControlByName("JeezTextBox5") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox; txOrg = base.GetControlByName("JeezTextBox3") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox; txDept = base.GetControlByName("JeezTextBox4") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox; txEmployee = base.GetControlByName("JeezTextBox6") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox; txBibie = base.GetControlByName("JeezTextBox8") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox; txRat = base.GetControlByName("JeezNumberTextBox1") as Jeez.Control.JeezNumberTextBox.JeezNumberTextBox; txYBMoney = base.GetControlByName("JeezCurrencyTextBox1") as Jeez.Control.JeezCurrencyTextBox.JeezCurrencyTextBox; txYBYF = base.GetControlByName("JeezCurrencyTextBox2") as Jeez.Control.JeezCurrencyTextBox.JeezCurrencyTextBox; txRMBMoney = base.GetControlByName("JeezCurrencyTextBox3") as Jeez.Control.JeezCurrencyTextBox.JeezCurrencyTextBox; txRMBYF = base.GetControlByName("JeezCurrencyTextBox4") as Jeez.Control.JeezCurrencyTextBox.JeezCurrencyTextBox; gridZY = base.GetControlByName("JeezGrid1") as Jeez.Control.JeezGrid.JeezGrid; dtDate = base.GetControlByName("JeezCalendarCombo1") as Jeez.Control.JeezUltraCalendarCombo.JeezUltraCalendarCombo; pagecontrol1 = base.GetControlByName("JeezTabControl1") as Jeez.Control.JeezUltraTabControl.JeezUltraTabControl; gridKucun = base.GetControlByName("gridKucun") as Jeez.Control.JeezGrid.JeezGrid; gridBaojiaHistory = base.GetControlByName("gridRefHistory") as Jeez.Control.JeezGrid.JeezGrid; pagecontrol1.SelectedTabChanged += new Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventHandler(pagecontrol1_SelectedTabChanged); txBibie.ValueChanged += new EventHandler(txBibie_ValueChanged); txRat.TextChanged += new EventHandler(txRat_TextChanged); txWLDW.ValueChanged += new EventHandler(txWLDW_ValueChanged); gridZY.AfterCellUpdate += new CellEventHandler(gridZY_AfterCellUpdate); } return b; } /// <summary> /// 页框轮换点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void pagecontrol1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (e.Tab.Index == 1) { //如果点的是第二个页框,用来显示即时库存 if (gridKucun != null) { StringBuilder strMatID = new StringBuilder(); strMatID.Append("(0"); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridZY.Rows) { if (row.Cells["matid"].Value.ToString() != "") { //获取物料 EntityObject eoMat = base.GetRefEntityObjectByGridEntityCol(gridZY, row.Cells["matid"]); strMatID.Append(string.Format(",{0}", (int)eoMat.PrimaryKeyValue)); } } strMatID.Append(")"); DataTable dt = new DataTable(); DataSet ds = new DataSet(); Jeez.Core.NativeQueryCommand cmd; Jeez.Core.INativeQuery quary = Jeez.Login.RemoteCall.GetNativeQuery(); cmd = new NativeQueryCommand(); cmd.CommandText = string.Format(@"select b.Number as 物料代码,b.Name as 物料名称,c.Name as 计量单位,sum(a.Many) as 总数量,sum(a.UseMany) as 占用数量,sum(a.Many)-sum(a.UseMany) as 可用数量 from jzNowKucun a left join jzMat b on a.MatID=b.ID left join jzJiliangdanwei c on a.JiliangdanweiID=c.ID where a.MatID in {0} group by b.Number,b.Name,c.Name", strMatID); try { dt = quary.GetDataTable(this.objContext.ConnectionString, cmd); ds = new System.Data.DataSet(); ds.Tables.Add(dt); gridKucun.DataSource = ds.Tables[0]; } catch (Exception ex) { Jeez.Common.UI.MsgBox.Show(ex.Message.ToString()); } } } else if (e.Tab.Index == 2) { if (gridBaojiaHistory != null) { if (txWLDW.Tag != null && (int)txWLDW.Tag != 0 && txBibie.Tag != null && (int)txBibie.Tag != 0) { StringBuilder strMatID = new StringBuilder(); strMatID.Append("(0"); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridZY.Rows) { if (row.Cells["matid"].Value.ToString() != "") { //获取物料 EntityObject eoMat = base.GetRefEntityObjectByGridEntityCol(gridZY, row.Cells["matid"]); strMatID.Append(string.Format(",{0}", (int)eoMat.PrimaryKeyValue)); } } strMatID.Append(")"); DataTable dt = new DataTable(); DataSet ds = new DataSet(); Jeez.Core.NativeQueryCommand cmd; Jeez.Core.INativeQuery quary = Jeez.Login.RemoteCall.GetNativeQuery(); cmd = new NativeQueryCommand(); if (this.entityobject == null) { cmd.CommandText = string.Format(@"select d.BillNO as 报价单号,d.Date as 日期,b.Number as 物料代码,b.Name as 物料名称,c.Name as 计量单位,a.Many as 数量,f.Name as 币别,d.Rate as 汇率,a.Danjia as 单价,a.Amount as 金额 from jzSaleBaojiaDetail a left join jzMat b on a.MatID=b.ID left join jzJiliangdanwei c on a.JiliangdanweiID=c.ID inner join jzSaleBaojia d on d.ID=a.SaleBaojiaID left join jzRefUnit e on e.ID=d.RefUnitID left join jzCurrency f on f.ID=d.CurrencyID where a.MatID in {0} and e.ID={1} and f.ID={2} ", strMatID, (int)txWLDW.Tag, (int)txBibie.Tag); } else { cmd.CommandText = string.Format(@"select d.BillNO as 报价单号,d.Date as 日期,b.Number as 物料代码,b.Name as 物料名称,c.Name as 计量单位,a.Many as 数量,f.Name as 币别,d.Rate as 汇率,a.Danjia as 单价,a.Amount as 金额 from jzSaleBaojiaDetail a left join jzMat b on a.MatID=b.ID left join jzJiliangdanwei c on a.JiliangdanweiID=c.ID inner join jzSaleBaojia d on d.ID=a.SaleBaojiaID left join jzRefUnit e on e.ID=d.RefUnitID left join jzCurrency f on f.ID=d.CurrencyID where a.MatID in {0} and e.ID={1} and f.ID={2} and d.ID<>{3} ", strMatID, (int)txWLDW.Tag, (int)txBibie.Tag,(int)this.entityobject.PrimaryKeyValue); } try { dt = quary.GetDataTable(this.objContext.ConnectionString, cmd); ds = new System.Data.DataSet(); ds.Tables.Add(dt); gridBaojiaHistory.DataSource = ds.Tables[0]; } catch (Exception ex) { Jeez.Common.UI.MsgBox.Show(ex.Message.ToString()); } } } } } /// <summary> /// 保存前检查事件 /// </summary> /// <returns></returns> protected override bool BeforeSaveCheck() { bool b=base.BeforeSaveCheck(); if (b) { } return b; } /// <summary> /// 新增事件 /// </summary> protected override void AddNew() { base.AddNew(); if (this.entityobject == null) { InitByDefine(); } } void txWLDW_ValueChanged(object sender, EventArgs e) { if (!isLoading) return; CalMatPrice(); } /// <summary> /// 汇率手动调整后改变单价 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void txRat_TextChanged(object sender, EventArgs e) { if (!isLoading) return; foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.gridZY.Rows) { if (row.Cells["matid"].Value.ToString() != "") { row.Cells["RDanjia"].Value = Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Danjia"].Value, 0m)) * Convert.ToDecimal(BaseFunc.IsNull(txRat.PropertyPage.Value, 0m)); row.Cells["RAmount"].Value = Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Danjia"].Value, 0m)) * Convert.ToDecimal(BaseFunc.IsNull(txRat.PropertyPage.Value, 0m)) * Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Many"].Value, 0m)); ; } } } /// <summary> /// 币别变化事件,要自动算出该币别该单据的汇率,是固定汇率还是浮动汇率,还要调整子表的物料单价 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void txBibie_ValueChanged(object sender, EventArgs e) { if (!isLoading) return; CalRat(); //重新计算物料子表的单价 CalMatPrice(); } /// <summary> /// 计算物料单价 /// </summary> void CalMatPrice() { if (txWLDW.Tag != null && (int)txWLDW.Tag != 0 && txBibie.Tag != null && (int)txBibie.Tag != 0) { if (gridZY.Rows != null) { foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridZY.Rows) { if (row.Cells["matid"].Value.ToString() != "") { //获取物料 EntityObject eoMat = base.GetRefEntityObjectByGridEntityCol(gridZY, row.Cells["matid"]); //获取计量单位 EntityObject eoUnit = base.GetRefEntityObjectByGridEntityCol(gridZY, row.Cells["jiliangdanweiid"]); if (eoMat != null && eoUnit != null && Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Many"].Value, 0m)) > 0) { EntityObjectList eoChildList = eoMat.GetChildEntityObjects(EntityIDEnum.MatSalePrice); EntityObjectList eoChildl = eoChildList.Find("RefUnitID={0} and CurrencyID={1} and MinQty<={2} and JiliangdanweiID={3} and checkID=0", (int)txWLDW.Tag, (int)txBibie.Tag, Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Many"].Value, 0m)), (int)eoUnit.PrimaryKeyValue); eoChildl.Sort("MinQty", SortDirection.Descending); //如果存在销售价格记录 if (eoChildl.Count > 0) { EntityObject eoChild = eoChildl[0]; if (eoChild != null) { row.Cells["Danjia"].Value = Convert.ToDecimal(BaseFunc.IsNull(eoChild.GetProperty("Danjia"), 0m)); } else { Jeez.Common.UI.MsgBox.Show("物料销售价格表中还没有该物料价格,请先手动输入该物料本次价格,然后再保存单据后点击更新销售价格表!"); return; } } else { //看公共往来单位是否存在销售价格记录 EntityObjectList eolChildPublic = eoChildList.Find("RefUnitID={0} and CurrencyID={1} and MinQty<={2} and JiliangdanweiID={3} and checkID=0", WLDWID, (int)txBibie.Tag, Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Many"].Value, 0m)), (int)eoUnit.PrimaryKeyValue); eolChildPublic.Sort("MinQty", SortDirection.Descending); if (eolChildPublic.Count > 0) { EntityObject eoChildPublic = eolChildPublic[0]; if (eoChildPublic != null) { row.Cells["Danjia"].Value = Convert.ToDecimal(BaseFunc.IsNull(eoChildPublic.GetProperty("Danjia"), 0m)); } } else { Jeez.Common.UI.MsgBox.Show("物料销售价格表中还没有该物料价格,请先手动输入该物料本次价格,然后再保存单据后点击更新销售价格表!"); return; } } } } } } } } /// <summary> /// 计算汇率 /// </summary> void CalRat() { if ((int)txBibie.Tag != 0 && (int)txBibie.PropertyPage.Value.IndexOf("RMB")<0&&txBibie.PropertyPage.Value.ToString()!="") { //如果不是人民币 if (dtDate.PropertyPage.Datetime == Jeez.Core.Toolkit.GetDateTimeDefaultValue()) { Jeez.Common.UI.MsgBox.Show("请先输入单据日期,因为单据日期决定了币别汇率!"); return; } if (txOrg.Tag == null) { Jeez.Common.UI.MsgBox.Show("请先输入组织机构,因为汇率不同组织机构可能都有差异!"); return; } EntityObjectFactory eofBibi = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.Currency); EntityObject eoBibie = eofBibi.FindObject((int)txBibie.Tag); if (eoBibie != null) { bool IsFixRat = (bool)eoBibie.GetProperty("IsFixRate"); if (IsFixRat) { //如果是固定汇率 EntityObjectList eolFixRat = eoBibie.GetChildEntityObjects(EntityIDEnum.FixedRate); EntityObject eoFixRat = eolFixRat.FindFirst("Year={0} and Period={1} and OrganizationID={2}", (int)dtDate.PropertyPage.Datetime.Year, (int)dtDate.PropertyPage.Datetime.Month, (int)txOrg.Tag); if (eoFixRat != null) { txRat.PropertyPage.Value = (decimal)eoFixRat.GetProperty("AccountBookRate"); } else { Jeez.Common.UI.MsgBox.Show("请先在系统维护,基础资料,币别中输入该币别该期间的固定汇率"); return; } } else { //如果是浮动汇率 EntityObjectList eolFixRat = eoBibie.GetChildEntityObjects(EntityIDEnum.FloatingRate); EntityObject eoFixRat = eolFixRat.FindFirst("OrganizationID={0} and ", (int)txOrg.Tag, dtDate.PropertyPage.Datetime); if (eoFixRat != null) { txRat.PropertyPage.Value = (decimal)eoFixRat.GetProperty("FloatRate"); } else { Jeez.Common.UI.MsgBox.Show("请先在系统维护,基础资料,币别中输入该币别该期间的浮动汇率"); return; } } } } else { txRat.PropertyPage.Value = 1.0m; } } /// <summary> /// 单元格值变化事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void gridZY_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { if (e.Cell.Column.Key.ToLower() == "matid" || e.Cell.Column.Key.ToLower() == "many"||e.Cell.Column.Key.ToLower()=="jiliangdanweiid") { //计算物料单价 CalMatPrice(e); } if (e.Cell.Column.Key.ToLower() == "danjia" || e.Cell.Column.Key.ToLower() == "many") { //计算子表的金额字段=单价*数量 e.Cell.Row.Cells["Amount"].Value = Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Danjia"].Value, 0m)) * Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Many"].Value, 0m)); e.Cell.Row.Cells["RDanjia"].Value = Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Danjia"].Value, 0m)) * Convert.ToDecimal(BaseFunc.IsNull(txRat.PropertyPage.Value, 0m)); e.Cell.Row.Cells["RAmount"].Value = Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Danjia"].Value, 0m)) * Convert.ToDecimal(BaseFunc.IsNull(txRat.PropertyPage.Value, 0m)) * Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Many"].Value, 0m)); ; } if (e.Cell.Column.Key.ToLower() == "amount") { //计算汇总将子表的金额合计汇总到父表 CalAmount(); } } /// <summary> /// 自动计算价格汇总 /// </summary> protected virtual void CalAmount() { decimal amount = 0; if (txYBMoney != null&&txRMBMoney!=null) { foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridZY.Rows) { amount += Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Amount"].Value, 0)); } txYBMoney.PropertyPage.Value = amount; txRMBMoney.PropertyPage.Value = amount * (decimal)txRat.PropertyPage.Value; ; } } /// <summary> /// 自动计算物料单价 /// </summary> /// <param name="e"></param> void CalMatPrice(Infragistics.Win.UltraWinGrid.CellEventArgs e) { if ((int)txBibie.Tag == 0) { Jeez.Common.UI.MsgBox.Show("请先输入币别!"); return; } if (txWLDW.Tag ==null) { Jeez.Common.UI.MsgBox.Show("请先输入往来单位!"); return; } if (txWLDW.Tag != null && (int)txWLDW.Tag != 0 && txBibie.Tag != null && (int)txBibie.Tag != 0) { //获取物料 EntityObject eoMat = base.GetRefEntityObjectByGridEntityCol(gridZY, e.Cell.Row.Cells["matid"]); //获取计量单位 EntityObject eoUnit = base.GetRefEntityObjectByGridEntityCol(gridZY, e.Cell.Row.Cells["jiliangdanweiid"]); if (eoMat != null && eoUnit != null && Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Many"].Value, 0m))>0) { EntityObjectList eoChildList = eoMat.GetChildEntityObjects(EntityIDEnum.MatSalePrice); EntityObjectList eoChildl = eoChildList.Find("RefUnitID={0} and CurrencyID={1} and MinQty<={2} and JiliangdanweiID={3} and checkID=0", (int)txWLDW.Tag, (int)txBibie.Tag, Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Many"].Value, 0m)),(int)eoUnit.PrimaryKeyValue); eoChildl.Sort("MinQty", SortDirection.Descending); //如果存在销售价格记录 if (eoChildl.Count > 0) { EntityObject eoChild = eoChildl[0]; if (eoChild != null) { e.Cell.Row.Cells["Danjia"].Value = Convert.ToDecimal(BaseFunc.IsNull(eoChild.GetProperty("Danjia"), 0m)); } else { Jeez.Common.UI.MsgBox.Show("物料销售价格表中还没有该物料价格,请先手动输入该物料本次价格,然后再保存单据后点击更新销售价格表!"); return; } } else { //看公共往来单位是否存在销售价格记录 EntityObjectList eolChildPublic= eoChildList.Find("RefUnitID={0} and CurrencyID={1} and MinQty<={2} and JiliangdanweiID={3} and checkID=0",WLDWID, (int)txBibie.Tag, Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Many"].Value, 0m)), (int)eoUnit.PrimaryKeyValue); eolChildPublic.Sort("MinQty", SortDirection.Descending); if (eolChildPublic.Count > 0) { EntityObject eoChildPublic = eolChildPublic[0]; if (eoChildPublic != null) { e.Cell.Row.Cells["Danjia"].Value = Convert.ToDecimal(BaseFunc.IsNull(eoChildPublic.GetProperty("Danjia"), 0m)); } } else { Jeez.Common.UI.MsgBox.Show("物料销售价格表中还没有该物料价格,请先手动输入该物料本次价格,然后再保存单据后点击更新销售价格表!"); return; } } } } } /// <summary> /// 弹出窗体事件, /// </summary> /// <param name="sender"></param> /// <param name="EntityID"></param> /// <param name="RunTimeFilter"></param> protected override void ShowUISelectedForm(object sender, int EntityID, ArrayList RunTimeFilter) { //如果是往来单位表 if (EntityID == 1000000008) { ArrayList ar = new ArrayList(); //过滤只有客户的往来单位 Jeez.Runtime.Base.General.RunTimefilterDefine fd; fd = new Jeez.Runtime.Base.General.RunTimefilterDefine("{jzRefUnit.IsCustomer}", 0, 0, Jeez.FormProperty.FilterDefineCompare.Equals, Jeez.FormProperty.FilterDefineLogic.NONE, 1); ar.Add(fd); base.ShowUISelectedForm(sender, EntityID, ar); } else { base.ShowUISelectedForm(sender, EntityID, RunTimeFilter); } } protected override void BillUI_Load(object sender, EventArgs e) { base.BillUI_Load(sender, e); if (this.entityobject == null) { InitByDefine(); } } /// <summary> /// 将实体数据banding到控件上的事件 /// </summary> protected override void LoadEntityDataToControl() { isLoading = false; base.LoadEntityDataToControl(); isLoading = true; } /// <summary> /// 自定义初始化控件上的一些值 /// </summary> void InitByDefine() { //实现往来单位只能选择客户数据 txWLDW.AutoDropdownListFilter = string.Format("IsCustomer=1"); //实现自动将当前登录用户所对应的职员信息的部门,组织机构,本身职员信息填充到界面上的三个控件减少输入 EntityObjectFactory eofEmployee = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.Employee); EntityObject eoEmp = eofEmployee.FindFirst("SysUserID={0}", Jeez.Login.Environment.UserID); if (eoEmp != null && txEmployee != null) { txEmployee.Tag = eoEmp.PrimaryKeyValue; txEmployee.VALUE = eoEmp.ToString(); txOrg.Tag = eoEmp.GetRelatedObject("OrganizationID").PrimaryKeyValue; txOrg.VALUE = eoEmp.GetRelatedObject("OrganizationID").ToString(); txDept.Tag = eoEmp.GetRelatedObject("DepartMentID").PrimaryKeyValue; txDept.VALUE = eoEmp.GetRelatedObject("DepartMentID").ToString(); } //默认登录的时候币别为人民币,汇率为1 EntityObjectFactory eofBibie = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.Currency); EntityObject eoBibie = eofBibie.FindFirst("Name='人民币'"); if (eoBibie != null) { txBibie.Tag = eoBibie.PrimaryKeyValue; txBibie.VALUE = eoBibie.ToString(); txRat.PropertyPage.Value = 1.0m; BibieID = (int)eoBibie.PrimaryKeyValue; } ////默认登录的时候往来单位ID获取 EntityObjectFactory eofInnit = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.SystemInit); EntityObject eoInit = eofInnit.FindFirst("ID>0"); if (eoInit != null) { WLDWID = (int)eoInit.GetProperty("RefUnitID"); } this.gridZY.RowCount= 5;//默认设置5行 } /// <summary> /// 指定服务端调用的类 /// </summary> /// <param name="ServerDllName"></param> /// <param name="ServerClassName"></param> protected override void SetInvokeBusiLogicName(out string ServerDllName, out string ServerClassName) { ServerDllName = "FolyerERPServer.dll"; ServerClassName = "FolyerERPServer.FolyerERPServer_SCM.SCMBaseServer"; } /// <summary> /// 菜单事件的扩展 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <param name="Tool"></param> public override void ResponseMenuToolClickEvent(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e, object Tool) { Jeez.FormProperty.JeezTool tool = Tool as Jeez.FormProperty.JeezTool; if (tool == null) return; this.Cursor = Jeez.Common.UI.Waitcursor.WaitCursor; switch (tool.Name) { //弹出即时库存界面 case "toolKucun": //获取当前子表的物料明细ID StringBuilder strMatID = new StringBuilder(); strMatID.Append("(0"); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridZY.Rows) { if (row.Cells["matid"].Value.ToString() != "") { //获取物料 EntityObject eoMat = base.GetRefEntityObjectByGridEntityCol(gridZY, row.Cells["matid"]); strMatID.Append(string.Format(",{0}", (int)eoMat.PrimaryKeyValue)); } } strMatID.Append(")"); //构建一个过滤集合 ArrayList ar = new ArrayList(); //过滤当前物料存在的物料,不然库存显示没有意义 Jeez.Runtime.Base.General.RunTimefilterDefine fd; fd = new Jeez.Runtime.Base.General.RunTimefilterDefine("{jzNowKucun.MatID}", 0, 0, Jeez.FormProperty.FilterDefineCompare.In, Jeez.FormProperty.FilterDefineLogic.NONE, strMatID.ToString()); ar.Add(fd); base.ShowForm(EntityFormIDEnum.即时库存一览表供查询3,ar,null); break; //更新销售价格 case "toolUpdate": UpdatePrice(); break; default: break; } base.ResponseMenuToolClickEvent(sender, e, Tool); this.Cursor = Jeez.Common.UI.Waitcursor.Default; } /// <summary> /// 更新物料销售价格表 /// </summary> void UpdatePrice() { if (this.entityobject == null) return; //像批量更改价格的我们最好在服务器端去处理 RemoteObjectProxy proxy = this.objContext.GetRemoteObjectProxy("FolyerERPServer.dll", "FolyerERPServer.FolyerERPServer_SCM.SaleBaojiaServer"); string Message=(string)proxy.Invoke("UpadatePrice", (int)this.entityobject.PrimaryKeyValue); if (Message!=null) { Jeez.Common.UI.MsgBox.Show(Message); } } }
服务端代码如下:
/// <summary> /// 业务对象服务端基类,包含组织机构,日期 /// </summary> class SCMBaseServer : Jeez.Runtime.BusiLogic.RuntimeBusiLogic { /// <summary> /// 服务端保存前检查事件 /// </summary> /// <param name="eo"></param> /// <param name="strMessage"></param> /// <returns></returns> public override bool SaveValidate(EntityObject eo, ref string strMessage) { bool b = base.SaveValidate(eo, ref strMessage); if (b) { DateTime dt = Jeez.Core.Toolkit.GetServerTime(Context); int year = dt.Year; int month = dt.Month; DateTime dtBill=(DateTime)eo.GetProperty("Date");//确保你的业务单据父表都有Date字段 if (year > 2015||dtBill.Year>2015) { strMessage = "免费试用已经过期"; return false; } //判断是否会录入已经结账的期间往前的数据 if (!CheckDate(eo, ref strMessage)) return false; } return b; } /// <summary> /// 服务端删除前检查事件 /// </summary> /// <param name="eo"></param> /// <param name="strMessage"></param> /// <returns></returns> protected override bool DeleteValidate(EntityObject eo, ref string strMessage) { bool b = base.DeleteValidate(eo, ref strMessage); if(b) { //判断是否会录入已经结账的期间往前的数据 if (!CheckDate(eo, ref strMessage)) return false; } return b; } /// <summary> /// 检查录入的业务数据是否为以前期间的数据 /// </summary> /// <param name="eo"></param> /// <param name="strMessage"></param> /// <returns></returns> protected bool CheckDate(EntityObject eo, ref string strMessage) { DateTime dt = DateTime.Now; int OrgID = 0; OrgID = (int)eo.GetProperty("OrganizationID"); dt = Convert.ToDateTime(BaseFunc.IsNull(eo.GetProperty("Date"), Jeez.Core.Toolkit.GetDateTimeDefaultValue())); DateTime dtCur = BaseFunc.GetCurPeriod(Context, OrgID, false, "通用企业ERP"); if (dtCur.Year == 1799) { strMessage = string.Format("单据所属的组织机构没有启用仓库"); return false; } if (dt.Year * 100 + dt.Month < dtCur.Year * 100 + dtCur.Month) { strMessage = string.Format("单据日期在以前期间"); return false; } return true; } /// <summary> /// 审核前检查事件 /// </summary> /// <param name="eo"></param> /// <param name="IsCheck"></param> /// <param name="strMessage"></param> /// <returns></returns> protected override bool CheckValidate(EntityObject eo, bool IsCheck, ref string strMessage) { bool b = base.CheckValidate(eo, IsCheck, ref strMessage); if (b) { if (!CheckDate(eo, ref strMessage)) return false; } return b; } }
这样设计好基类的话,因为我们用了业务单据基类的概念,到时候我们很多类似界面有相关控件参与的如销售订单,销售出库单都可以继承他们,即可实现各自复杂功能了。
欢迎有兴趣的朋友下载我们平台,下载地址:http://www.jeez.com.cn/upfiles/jbfsetuppro.rar 体验我们平台快速开发的乐趣
李先生 平台销售经理
手机:18988763421 18988763421 QQ:180315586 420977542(加我为好友在线为您演示)
极致平台开发十大特点:
1. 一个数据库下可以同时进行N套业务系统开发,开发出来的产品可以根据您客户的需要按模块界面组发布,客户想要啥模块就可以给啥模块。而且一个数据库下开发所有功能,当客户需要从你的人力资源增加客户关系管理模块的时候,你只要做个升级包就可以了。解决企业多个业务系统信息孤岛问题。
2. 智能升级功能,当客户从A模块增加B模块的时候,您只需要做一个升级包即可,给客户升级后,客户原来录入的数据不会有影响,而且所有客户端都是智能感应智能升级,大大节省您的部署成本。
3. 工作流套打报表均可以运行时候自定义,比如费用报销单,您100家客户就有一百种费用报销的流程,套打的格式,用我们平台您只需要设计好这个费用报销单,至于哪个客户走什么流程,完全可以让客户自己去定义,而不需要像传统开发那样,提前在开发中设置好,100个客户就维护100套代码。套打也是如此。
4. 支持数据授权,当您开发多组织架构的系统的时候,我们只要业务单据引用组织机构即可,然后组织机构支持数据授权,这样就可以不需要编写任何一行代码就可以做到,组织与组织之间数据彼此隔离,我想给哪个用户看哪个组织的数据只要给这个用户这个组织的数据权限即可。
5. 支持字段授权,对于一些表的核心字段对用户进行屏蔽直接利用我们平台的字段授权功能即可,比如职员薪酬字段进行字段授权,让有的用户在看职员信息的时候,自动隐藏薪酬的数据。这也是无需编写任何一行代码。
6. 单据界面自动生成,我们开发的时候只要设计好实体,也就是传统开发所说的表结构即可,还可以设置哪些字段是必录,可见,不允许重复,在界面生成的时候,会自动生成一个界面,而且这个界面的增删改查是无需写一行代码的,您只要对您特有业务逻辑编码即可,相对传统开发,你代码量可以节省2/3,开发周期缩短2/3
7.一次开发同时具有单机局域互联网三个版本,客户想要单机就给单机想要互联网版就给互联网版。
8.强大的公式引擎,让您可以灵活设计计算类的项目,比如工资,预算。
9.包含强大的各种控件,比如文本控件支持F8调用,编码名称自动带出。Grid控件支持表头过滤,单元格融合,固定列,表格列,表格行各种公式汇总,复合表头,表格宽度可以自己随意调整,而且关闭后会自动记录之前的宽度。还支持表格列随意调整顺序。
10.平台内置很多基础功能,比如权限管理,用户角色管理,还有实施的一些导入导出工具都能帮助客户大大提高一个项目验收进度。
官网:www.jeez.com.cn
平台介绍:www.jeez.com.cn/jbf
平台下载地址:http://www.jeez.com.cn/upfiles/jbfsetuppro.rar
(下载即可有3个月免费试用)
联系电话:13826519021 18988763421 QQ:180315586 420977542 (加我注明极致软件即可)
平台销售经理:李先生
将互联网时代的管理软件做到极致!
==================================================================