public virtual void Clear() { try { if (this.QueryControl != null) { foreach (Sys_Bind sys_Bind in BindList.Where(b => b.Bind_Type == 0).OrderBy(b => b.Bind_Sort)) { Control[] Controls = this.QueryControl.Controls.Find(sys_Bind.Bind_Field, true); if (Controls.Length > 0) { BaseEdit baseEdit = (BaseEdit)Controls[0]; baseEdit.Text = string.Empty; baseEdit.EditValue = sys_Bind.Bind_Default; if (baseEdit.GetType().Equals(typeof(CheckEdit))) { CheckEdit chkEdit = (CheckEdit)baseEdit; chkEdit.Text = string.Empty; chkEdit.Checked = sys_Bind.Bind_Default.ToBoolEx(); } //RefreshEditValue if (baseEdit.GetType().Equals(typeof(CheckedComboBoxEdit))) { CheckedComboBoxEdit chkComboBox = (CheckedComboBoxEdit)baseEdit; chkComboBox.RefreshEditValue(); } } } } } catch (Exception ex) { throw ex; } //if (this.QueryControl != null) //{ // InitializeQuery(); // //ClearControl(this.QueryControl); //} finally { } }
public void RecalculatePrices() { BindList <ComplexRecipeDetail> products = detailsProd; double totalMat = detailsMat.Sum(t => t.Total); double totalProd = products.Sum(t => t.Quantity * t.PriceOut); bool allPriceOutAreZero = false; if (totalProd.IsZero() && products.Count > 0) { allPriceOutAreZero = products.All(t => t.PriceOut <= 0); if (allPriceOutAreZero) { totalProd += products.Sum(t => t.Quantity); } } foreach (ComplexRecipeDetail detail in products.Where(p => p.Quantity != 0)) { detail.OriginalPriceInEvaluate(totalProd.IsZero() ? 0 : (allPriceOutAreZero ? 1 : detail.PriceOut) * totalMat / totalProd); detail.TotalEvaluate(); } }
private void InitializeQuery() { try { if (this.QueryControl == null) { return; } this.QueryControl.DoubleClick += QueryAutoClear; this.QueryControl.Controls.Clear(); this.Width = 1024; this.QueryControl.Width = 1024; LayoutControl eLayoutControl = new LayoutControl(); eLayoutControl.BeginUpdate(); eLayoutControl.AllowCustomization = false; LayoutControlGroup eLayoutControlGroup = new LayoutControlGroup(); eLayoutControl.Dock = System.Windows.Forms.DockStyle.Fill; eLayoutControl.Location = new System.Drawing.Point(2, 21); eLayoutControl.Name = "eLayoutControl"; eLayoutControl.Root = eLayoutControlGroup; eLayoutControl.Size = new System.Drawing.Size(1000, 90); eLayoutControl.TabIndex = 0; eLayoutControl.Text = "QueryLayout"; eLayoutControlGroup.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True; eLayoutControlGroup.GroupBordersVisible = false; eLayoutControlGroup.Location = new Point(0, 0); eLayoutControlGroup.Name = "eLayoutControlGroup"; eLayoutControlGroup.Size = new Size(1000, 90); eLayoutControlGroup.TextVisible = false; this.QueryControl.Controls.Add(eLayoutControl); List <BaseLayoutItem> baseLayoutItems = new List <BaseLayoutItem>(); List <string> baseControls = new List <string>(); int curLeft = 0; int curTop = 0; foreach (Sys_Bind sys_Bind in BindList.Where(b => b.Bind_Name.StartsWith("@") && !string.IsNullOrEmpty(b.Bind_Field) && !b.Bind_Field.Contains(".") && WorkSetList.Find(w => w.WorkSet_Id == b.Bind_WorkSet && (w.WorkSet_Type == (int)Sys_WorkSet_Type.Submit || w.WorkSet_Type == (int)Sys_WorkSet_Type.Grid || w.WorkSet_Type == (int)Sys_WorkSet_Type.Tree)) != null).OrderBy(b => b.Bind_Sort)) { if (baseControls.Contains(sys_Bind.Bind_Field)) { continue; } baseControls.Add(sys_Bind.Bind_Field); sys_Bind.Bind_Type = 0; //查询字段 //界面已有控件不再生成 Control[] Controls = this.Controls.Find(sys_Bind.Bind_Field, true); if (Controls.Length > 0) { if (!string.IsNullOrEmpty(sys_Bind.Bind_Popup)) { BaseEdit cBaseEdit = (BaseEdit)Controls[0]; InitializeBaseEdit(sys_Bind, cBaseEdit); } continue; } BaseEdit baseEdit = InitializeBaseEdit(sys_Bind, null); baseEdit.Name = sys_Bind.Bind_Field; if (!string.IsNullOrEmpty(sys_Bind.Bind_Default)) { object obj = sys_Bind.Bind_Default; if (obj.ToString().StartsWith("wk:")) { obj = BaseService.Get(obj.ToString().Replace("wk:", ""), null); } ReflectionHelper.SetProperty(baseEdit, string.IsNullOrEmpty(sys_Bind.Bind_Property) ? "EditValue" : sys_Bind.Bind_Property, obj); //baseEdit.EditValue = sys_Bind.Bind_Default; if (baseEdit.GetType().Equals(typeof(CheckEdit))) { CheckEdit chkEdit = (CheckEdit)baseEdit; chkEdit.Text = string.Empty; chkEdit.Checked = obj.ToBoolEx(); } } if (baseEdit.GetType().Equals(typeof(CheckedComboBoxEdit))) { CheckedComboBoxEdit chkComboBox = (CheckedComboBoxEdit)baseEdit; chkComboBox.RefreshEditValue(); } baseEdit.EnterMoveNextControl = true; baseEdit.Width = (int)Math.Round(eLayoutControlGroup.Width * (sys_Bind.Bind_Width / 100.00)); baseEdit.Properties.Appearance.Options.UseTextOptions = true; baseEdit.Properties.Appearance.TextOptions.HAlignment = (DevExpress.Utils.HorzAlignment)sys_Bind.Bind_TextAlignment; if (sys_Bind.Bind_ForeColor < 0) { baseEdit.ForeColor = Color.FromArgb(sys_Bind.Bind_ForeColor); } if (sys_Bind.Bind_BackColor < 0) { baseEdit.BackColor = Color.FromArgb(sys_Bind.Bind_BackColor); } if (sys_Bind.Bind_BorderColor < 0) { baseEdit.Properties.Appearance.Options.UseBorderColor = true; baseEdit.Properties.Appearance.BorderColor = Color.FromArgb(sys_Bind.Bind_BorderColor); baseEdit.BorderStyle = BorderStyles.Simple; } baseEdit.ToolTip = sys_Bind.Bind_ToolTip; baseEdit.ReadOnly = sys_Bind.Bind_ReadOnly; baseEdit.Visible = sys_Bind.Bind_Visible; baseEdit.GotFocus += Control_GotFocus; eLayoutControl.GotFocus += Control_GotFocus; LayoutControlItem eLayoutControlItem = new LayoutControlItem(); eLayoutControlItem.Location = new System.Drawing.Point(curLeft, curTop); curLeft += baseEdit.Width; if (curLeft >= eLayoutControlGroup.Width) { curLeft = 0; curTop += baseEdit.Height; } //eLayoutControlItem.Width = (int)Math.Round(eLayoutControl.Width * (sys_Bind.Bind_Width / 100.00)); eLayoutControlItem.AppearanceItemCaption.TextOptions.HAlignment = (DevExpress.Utils.HorzAlignment)sys_Bind.Bind_TitleAlignment; eLayoutControlItem.Name = "oli_" + sys_Bind.Bind_Name; eLayoutControlItem.Text = sys_Bind.Bind_Nick; eLayoutControlItem.Size = new Size(baseEdit.Width, baseEdit.Height); eLayoutControlItem.Control = baseEdit; eLayoutControlItem.Visibility = sys_Bind.Bind_Visible ? DevExpress.XtraLayout.Utils.LayoutVisibility.Always : DevExpress.XtraLayout.Utils.LayoutVisibility.Never; baseLayoutItems.Add(eLayoutControlItem); } if (curLeft < eLayoutControlGroup.Width && curLeft > 0) { EmptySpaceItem emptySpaceItem = new EmptySpaceItem(); emptySpaceItem.AllowHotTrack = false; emptySpaceItem.Location = new System.Drawing.Point(curLeft, curTop); emptySpaceItem.Name = "oli_Space"; emptySpaceItem.Size = new System.Drawing.Size(eLayoutControlGroup.Width - curLeft, 24); baseLayoutItems.Add(emptySpaceItem); } eLayoutControlGroup.Items.AddRange(baseLayoutItems.ToArray()); eLayoutControl.EndUpdate(); } catch (Exception ex) { SharedFunc.RaiseError(ex); } }