How to add a new tab to Instant Info
Posted on July 1, 2016 | By Mohd Imran
Contents
Introduction
To add a new tab into a Instant Info would require a programmer to do 2 things. First would be to create a separate .dll file that will contain the UI class for the information to be displayed. The second would be to add some codes to call the UI class in the AutoCount Accounting system.
Creating the UI
The UI class
The following codes is for the UI design and control:
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using BCE.AutoCount.XtraUtils.LookupEditBuilder;
- using BCE.Data;
- using DevExpress.Utils.Menu;
- using DevExpress.Utils;
- using DevExpress.XtraGrid;
- namespace MyAutoCountProject
- {
- ///<summary>
- /// Delegate use for Item Code Inquiry.
- ///</summary>
- public delegate void ItemCodeChanged(string itemCode, string uom);
- ///<summary>
- /// Summary description for UCPriceHistory.
- ///</summary>
- public class UCPriceHistory : DevExpress.XtraEditors.XtraUserControl
- {
- private DBSetting myDbSetting;
- private ItemCodeChanged myItemCodeChanged;
- private string myItemCode;
- private string myUom;
- private object myFromDate;
- private object myToDate;
- private bool myShowDebtor;
- private bool myShowCreditor;
- ///<summary>
- /// Determine this is use by InstantInfo or not.
- ///</summary>
- private bool myIsInstantInfo;
- private PriceHistory myPriceHistoryInquiry;
- private BCE.XtraUtils.MouseDownHelper myMouseDownHelper;
- #region Windows Generated Variable
- private DevExpress.XtraGrid.GridControl gctrPriceHistory;
- private DevExpress.XtraGrid.Views.Grid.GridView gvPriceHistory;
- private DevExpress.XtraGrid.Columns.GridColumn colItemCode;
- private DevExpress.XtraGrid.Columns.GridColumn colDocType;
- private DevExpress.XtraGrid.Columns.GridColumn colDocDate;
- private DevExpress.XtraGrid.Columns.GridColumn colDocNo;
- private DevExpress.XtraGrid.Columns.GridColumn colDescription;
- private DevExpress.XtraGrid.Columns.GridColumn colLocation;
- private DevExpress.XtraGrid.Columns.GridColumn colUOM;
- private DevExpress.XtraGrid.Columns.GridColumn colQty;
- private DevExpress.XtraGrid.Columns.GridColumn colUnitPrice;
- private DevExpress.XtraGrid.Columns.GridColumn colDiscount;
- private DevExpress.XtraGrid.Columns.GridColumn colSubTotal;
- private DevExpress.XtraGrid.Columns.GridColumn colDocKey;
- private DevExpress.XtraGrid.Columns.GridColumn colAccNo;
- private DevExpress.XtraGrid.Columns.GridColumn colDeptNo;
- private DevExpress.XtraGrid.Columns.GridColumn colProjNo;
- private DevExpress.XtraGrid.Columns.GridColumn colRate;
- private DevExpress.XtraGrid.Columns.GridColumn colSmallestQty;
- private DevExpress.XtraGrid.Columns.GridColumn colTaxType;
- private DevExpress.XtraGrid.Columns.GridColumn colBranchCode;
- private DevExpress.XtraGrid.Columns.GridColumn colFOCQty;
- private DevExpress.XtraEditors.PanelControl pnAccNo;
- private DevExpress.XtraGrid.Columns.GridColumn colCompanyName;
- private DevExpress.XtraGrid.Columns.GridColumn colFurtherDesc;
- private DevExpress.XtraEditors.Repository.RepositoryItemButtonEdit repositoryItemButtonEdit1;
- private DevExpress.XtraGrid.Columns.GridColumn colLocalUnitPrice;
- private DevExpress.XtraGrid.Columns.GridColumn colLocalSubTotal;
- private DevExpress.XtraGrid.Columns.GridColumn colCurrencyRate;
- private DevExpress.XtraGrid.Columns.GridColumn colCurrencyCode;
- private DevExpress.XtraEditors.CheckEdit ckEdtShowCreditor;
- private DevExpress.XtraEditors.CheckEdit ckEdtShowDebtor;
- private System.ComponentModel.IContainer components;
- #endregion
- ///<summary>
- /// Use to set ItemCodeChanged Delegate
- ///</summary>
- public ItemCodeChanged SetItemCodeChanged
- {
- set {myItemCodeChanged = value;}
- }
- public UCPriceHistory()
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- gctrPriceHistory.ForceInitialize();
- myIsInstantInfo = false;
- Reset();
- myMouseDownHelper = new BCE.XtraUtils.MouseDownHelper();
- myMouseDownHelper.Init(gvPriceHistory);
- BCE.XtraUtils.GridViewUtils.EnableRightMouseDownAsRowSelect(gvPriceHistory);
- BCE.AutoCount.XtraUtils.FormControlUtil f = new BCE.AutoCount.XtraUtils.FormControlUtil(myDbSetting);
- f.AddField(“DocDate”, BCE.AutoCount.XtraUtils.FormControlUtil.DATE_FIELD);
- f.AddField(“Rate”, BCE.AutoCount.XtraUtils.FormControlUtil.QUANTITY_FIELD);
- f.AddField(“Qty”, BCE.AutoCount.XtraUtils.FormControlUtil.QUANTITY_FIELD);
- f.AddField(“SmallestQty”, BCE.AutoCount.XtraUtils.FormControlUtil.QUANTITY_FIELD);
- f.AddField(“UnitPrice”, BCE.AutoCount.XtraUtils.FormControlUtil.PRICE_FIELD);
- f.AddField(“SubTotal”, BCE.AutoCount.XtraUtils.FormControlUtil.CURRENCY_FIELD);
- f.AddField(“LocalUnitPrice”, BCE.AutoCount.XtraUtils.FormControlUtil.PRICE_FIELD);
- f.AddField(“LocalSubTotal”, BCE.AutoCount.XtraUtils.FormControlUtil.CURRENCY_FIELD);
- f.AddField(“CurrencyRate”, BCE.AutoCount.XtraUtils.FormControlUtil.CURRENCYRATE_FIELD);
- f.InitControls(this);
- LoadSaveSetting();
- }
- private void LoadSaveSetting()
- {
- UCPriceHistorySetting IPHistSetting = null;
- try
- {
- IPHistSetting = (UCPriceHistorySetting)
- BCE.AutoCount.PersistenceUtil.LoadUserSetting(“UCPriceHistory.setting”);
- }
- catch{}
- if (IPHistSetting == null)
- IPHistSetting = new UCPriceHistorySetting();
- myShowDebtor = IPHistSetting.ShowDebtor;
- myShowCreditor = IPHistSetting.ShowCreditor;
- ckEdtShowDebtor.Checked = myShowDebtor;
- ckEdtShowCreditor.Checked = myShowCreditor;
- }
- ///<summary>
- /// Clean up any resources being used.
- ///</summary>
- protected override void Dispose( bool disposing )
- {
- UCPriceHistorySetting IPHistSetting = new UCPriceHistorySetting();
- IPHistSetting.ShowDebtor = ckEdtShowDebtor.Checked;
- IPHistSetting.ShowCreditor = ckEdtShowCreditor.Checked;
- BCE.AutoCount.PersistenceUtil.SaveUserSetting(IPHistSetting, “UCPriceHistory.setting”);
- if( disposing )
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows Form Designer generated code
- ///<summary>
- /// Required method for Designer support – do not modify
- /// the contents of this method with the code editor.
- ///</summary>
- private void InitializeComponent()
- {
- this.gctrPriceHistory = new DevExpress.XtraGrid.GridControl();
- this.gvPriceHistory = new DevExpress.XtraGrid.Views.Grid.GridView();
- this.colAccNo = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colCompanyName = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colBranchCode = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colItemCode = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colUOM = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colDocType = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colDocDate = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colDocNo = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colDescription = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colLocation = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colQty = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colUnitPrice = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colLocalUnitPrice = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colDiscount = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colSubTotal = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colLocalSubTotal = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colDocKey = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colProjNo = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colDeptNo = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colRate = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colSmallestQty = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colTaxType = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colFOCQty = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colFurtherDesc = new DevExpress.XtraGrid.Columns.GridColumn();
- this.repositoryItemButtonEdit1 = new DevExpress.XtraEditors.Repository.RepositoryItemButtonEdit();
- this.colCurrencyRate = new DevExpress.XtraGrid.Columns.GridColumn();
- this.colCurrencyCode = new DevExpress.XtraGrid.Columns.GridColumn();
- this.pnAccNo = new DevExpress.XtraEditors.PanelControl();
- this.ckEdtShowCreditor = new DevExpress.XtraEditors.CheckEdit();
- this.ckEdtShowDebtor = new DevExpress.XtraEditors.CheckEdit();
- ((System.ComponentModel.ISupportInitialize)(this.gctrPriceHistory)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.gvPriceHistory)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.repositoryItemButtonEdit1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.pnAccNo)).BeginInit();
- this.pnAccNo.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.ckEdtShowCreditor.Properties)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.ckEdtShowDebtor.Properties)).BeginInit();
- this.SuspendLayout();
- //
- // gctrPriceHistory
- //
- this.gctrPriceHistory.Dock = System.Windows.Forms.DockStyle.Fill;
- this.gctrPriceHistory.EmbeddedNavigator.Buttons.Append.Visible = false;
- this.gctrPriceHistory.EmbeddedNavigator.Buttons.CancelEdit.Visible = false;
- this.gctrPriceHistory.EmbeddedNavigator.Buttons.Edit.Visible = false;
- this.gctrPriceHistory.EmbeddedNavigator.Buttons.EndEdit.Visible = false;
- this.gctrPriceHistory.EmbeddedNavigator.Buttons.Remove.Visible = false;
- this.gctrPriceHistory.EmbeddedNavigator.Name = “”;
- this.gctrPriceHistory.Location = new System.Drawing.Point(0, 24);
- this.gctrPriceHistory.MainView = this.gvPriceHistory;
- this.gctrPriceHistory.Name = “gctrPriceHistory”;
- this.gctrPriceHistory.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
- this.repositoryItemButtonEdit1});
- this.gctrPriceHistory.Size = new System.Drawing.Size(700, 176);
- this.gctrPriceHistory.TabIndex = 2;
- this.gctrPriceHistory.UseEmbeddedNavigator = true;
- this.gctrPriceHistory.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
- this.gvPriceHistory});
- //
- // gvPriceHistory
- //
- this.gvPriceHistory.Appearance.ColumnFilterButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(221)))), ((int)(((byte)(208)))));
- this.gvPriceHistory.Appearance.ColumnFilterButton.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(221)))), ((int)(((byte)(208)))));
- this.gvPriceHistory.Appearance.ColumnFilterButton.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.ColumnFilterButton.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.ColumnFilterButton.Options.UseBorderColor = true;
- this.gvPriceHistory.Appearance.ColumnFilterButton.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.ColumnFilterButtonActive.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(211)))), ((int)(((byte)(226)))), ((int)(((byte)(216)))));
- this.gvPriceHistory.Appearance.ColumnFilterButtonActive.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(211)))), ((int)(((byte)(226)))), ((int)(((byte)(216)))));
- this.gvPriceHistory.Appearance.ColumnFilterButtonActive.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.ColumnFilterButtonActive.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.ColumnFilterButtonActive.Options.UseBorderColor = true;
- this.gvPriceHistory.Appearance.ColumnFilterButtonActive.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.Empty.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(244)))), ((int)(((byte)(236)))));
- this.gvPriceHistory.Appearance.Empty.BackColor2 = System.Drawing.Color.White;
- this.gvPriceHistory.Appearance.Empty.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.EvenRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(221)))), ((int)(((byte)(227)))), ((int)(((byte)(245)))));
- this.gvPriceHistory.Appearance.EvenRow.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(221)))), ((int)(((byte)(227)))), ((int)(((byte)(245)))));
- this.gvPriceHistory.Appearance.EvenRow.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.EvenRow.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.EvenRow.Options.UseBorderColor = true;
- this.gvPriceHistory.Appearance.EvenRow.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.FilterCloseButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(221)))), ((int)(((byte)(208)))));
- this.gvPriceHistory.Appearance.FilterCloseButton.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(221)))), ((int)(((byte)(208)))));
- this.gvPriceHistory.Appearance.FilterCloseButton.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.FilterCloseButton.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.FilterCloseButton.Options.UseBorderColor = true;
- this.gvPriceHistory.Appearance.FilterCloseButton.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.FilterPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(244)))), ((int)(((byte)(236)))));
- this.gvPriceHistory.Appearance.FilterPanel.BackColor2 = System.Drawing.Color.White;
- this.gvPriceHistory.Appearance.FilterPanel.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.FilterPanel.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.FilterPanel.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.FixedLine.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(136)))), ((int)(((byte)(122)))));
- this.gvPriceHistory.Appearance.FixedLine.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.FocusedCell.BackColor = System.Drawing.Color.White;
- this.gvPriceHistory.Appearance.FocusedCell.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.FocusedCell.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.FocusedCell.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.FocusedRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(129)))), ((int)(((byte)(171)))), ((int)(((byte)(177)))));
- this.gvPriceHistory.Appearance.FocusedRow.ForeColor = System.Drawing.Color.White;
- this.gvPriceHistory.Appearance.FocusedRow.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.FocusedRow.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.FooterPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(221)))), ((int)(((byte)(208)))));
- this.gvPriceHistory.Appearance.FooterPanel.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(221)))), ((int)(((byte)(208)))));
- this.gvPriceHistory.Appearance.FooterPanel.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.FooterPanel.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.FooterPanel.Options.UseBorderColor = true;
- this.gvPriceHistory.Appearance.FooterPanel.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.GroupButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(178)))), ((int)(((byte)(209)))), ((int)(((byte)(188)))));
- this.gvPriceHistory.Appearance.GroupButton.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(178)))), ((int)(((byte)(209)))), ((int)(((byte)(188)))));
- this.gvPriceHistory.Appearance.GroupButton.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.GroupButton.Options.UseBorderColor = true;
- this.gvPriceHistory.Appearance.GroupFooter.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(215)))), ((int)(((byte)(234)))), ((int)(((byte)(221)))));
- this.gvPriceHistory.Appearance.GroupFooter.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(215)))), ((int)(((byte)(234)))), ((int)(((byte)(221)))));
- this.gvPriceHistory.Appearance.GroupFooter.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.GroupFooter.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.GroupFooter.Options.UseBorderColor = true;
- this.gvPriceHistory.Appearance.GroupFooter.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.GroupPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(244)))), ((int)(((byte)(236)))));
- this.gvPriceHistory.Appearance.GroupPanel.BackColor2 = System.Drawing.Color.White;
- this.gvPriceHistory.Appearance.GroupPanel.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.GroupPanel.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.GroupPanel.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.GroupRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(215)))), ((int)(((byte)(234)))), ((int)(((byte)(221)))));
- this.gvPriceHistory.Appearance.GroupRow.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(215)))), ((int)(((byte)(234)))), ((int)(((byte)(221)))));
- this.gvPriceHistory.Appearance.GroupRow.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.GroupRow.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.GroupRow.Options.UseBorderColor = true;
- this.gvPriceHistory.Appearance.GroupRow.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.HeaderPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(211)))), ((int)(((byte)(226)))), ((int)(((byte)(216)))));
- this.gvPriceHistory.Appearance.HeaderPanel.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(211)))), ((int)(((byte)(226)))), ((int)(((byte)(216)))));
- this.gvPriceHistory.Appearance.HeaderPanel.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.HeaderPanel.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.HeaderPanel.Options.UseBorderColor = true;
- this.gvPriceHistory.Appearance.HeaderPanel.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.HideSelectionRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(186)))), ((int)(((byte)(211)))), ((int)(((byte)(215)))));
- this.gvPriceHistory.Appearance.HideSelectionRow.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(130)))), ((int)(((byte)(134)))));
- this.gvPriceHistory.Appearance.HideSelectionRow.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.HideSelectionRow.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.HorzLine.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(172)))), ((int)(((byte)(197)))), ((int)(((byte)(180)))));
- this.gvPriceHistory.Appearance.HorzLine.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(136)))), ((int)(((byte)(122)))));
- this.gvPriceHistory.Appearance.HorzLine.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.HorzLine.Options.UseBorderColor = true;
- this.gvPriceHistory.Appearance.OddRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(244)))), ((int)(((byte)(236)))));
- this.gvPriceHistory.Appearance.OddRow.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(244)))), ((int)(((byte)(236)))));
- this.gvPriceHistory.Appearance.OddRow.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.OddRow.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.OddRow.Options.UseBorderColor = true;
- this.gvPriceHistory.Appearance.OddRow.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.Preview.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(240)))));
- this.gvPriceHistory.Appearance.Preview.Font = new System.Drawing.Font(“Verdana”, 7.5F);
- this.gvPriceHistory.Appearance.Preview.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(130)))), ((int)(((byte)(134)))));
- this.gvPriceHistory.Appearance.Preview.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.Preview.Options.UseFont = true;
- this.gvPriceHistory.Appearance.Preview.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.Row.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(244)))), ((int)(((byte)(236)))));
- this.gvPriceHistory.Appearance.Row.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.Row.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.Row.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.RowSeparator.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(244)))), ((int)(((byte)(236)))));
- this.gvPriceHistory.Appearance.RowSeparator.BackColor2 = System.Drawing.Color.White;
- this.gvPriceHistory.Appearance.RowSeparator.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.SelectedRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(159)))), ((int)(((byte)(201)))), ((int)(((byte)(207)))));
- this.gvPriceHistory.Appearance.SelectedRow.ForeColor = System.Drawing.Color.Black;
- this.gvPriceHistory.Appearance.SelectedRow.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.SelectedRow.Options.UseForeColor = true;
- this.gvPriceHistory.Appearance.TopNewRow.BackColor = System.Drawing.Color.White;
- this.gvPriceHistory.Appearance.TopNewRow.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.VertLine.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(172)))), ((int)(((byte)(197)))), ((int)(((byte)(180)))));
- this.gvPriceHistory.Appearance.VertLine.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(136)))), ((int)(((byte)(122)))));
- this.gvPriceHistory.Appearance.VertLine.Options.UseBackColor = true;
- this.gvPriceHistory.Appearance.VertLine.Options.UseBorderColor = true;
- this.gvPriceHistory.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
- this.colAccNo,
- this.colCompanyName,
- this.colBranchCode,
- this.colItemCode,
- this.colUOM,
- this.colDocType,
- this.colDocDate,
- this.colDocNo,
- this.colDescription,
- this.colLocation,
- this.colQty,
- this.colUnitPrice,
- this.colLocalUnitPrice,
- this.colDiscount,
- this.colSubTotal,
- this.colLocalSubTotal,
- this.colDocKey,
- this.colProjNo,
- this.colDeptNo,
- this.colRate,
- this.colSmallestQty,
- this.colTaxType,
- this.colFOCQty,
- this.colFurtherDesc,
- this.colCurrencyRate,
- this.colCurrencyCode});
- this.gvPriceHistory.GridControl = this.gctrPriceHistory;
- this.gvPriceHistory.Name = “gvPriceHistory”;
- this.gvPriceHistory.OptionsBehavior.AllowIncrementalSearch = true;
- this.gvPriceHistory.OptionsView.EnableAppearanceEvenRow = true;
- this.gvPriceHistory.OptionsView.EnableAppearanceOddRow = true;
- this.gvPriceHistory.OptionsView.ShowGroupPanel = false;
- this.gvPriceHistory.SortInfo.AddRange(new DevExpress.XtraGrid.Columns.GridColumnSortInfo[] {
- new DevExpress.XtraGrid.Columns.GridColumnSortInfo(this.colDocDate, DevExpress.Data.ColumnSortOrder.Descending)});
- this.gvPriceHistory.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(this.gvPriceHistory_FocusedRowChanged);
- this.gvPriceHistory.DoubleClick += new System.EventHandler(this.gvPriceHistory_DoubleClick);
- this.gvPriceHistory.CustomDrawCell += new DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventHandler(this.gvPriceHistory_CustomDrawCell);
- //
- // colAccNo
- //
- this.colAccNo.Caption = “Acc. No.”;
- this.colAccNo.FieldName = “AccNo”;
- this.colAccNo.Name = “colAccNo”;
- this.colAccNo.OptionsColumn.AllowEdit = false;
- this.colAccNo.OptionsColumn.ReadOnly = true;
- this.colAccNo.Visible = true;
- this.colAccNo.VisibleIndex = 0;
- this.colAccNo.Width = 47;
- //
- // colCompanyName
- //
- this.colCompanyName.Caption = “Company Name”;
- this.colCompanyName.FieldName = “CompanyName”;
- this.colCompanyName.Name = “colCompanyName”;
- this.colCompanyName.OptionsColumn.AllowEdit = false;
- this.colCompanyName.OptionsColumn.ReadOnly = true;
- this.colCompanyName.Visible = true;
- this.colCompanyName.VisibleIndex = 1;
- //
- // colBranchCode
- //
- this.colBranchCode.Caption = “Branch Code”;
- this.colBranchCode.FieldName = “BranchCode”;
- this.colBranchCode.Name = “colBranchCode”;
- this.colBranchCode.OptionsColumn.AllowEdit = false;
- this.colBranchCode.OptionsColumn.ReadOnly = true;
- this.colBranchCode.Visible = true;
- this.colBranchCode.VisibleIndex = 2;
- this.colBranchCode.Width = 51;
- //
- // colItemCode
- //
- this.colItemCode.Caption = “Item Code”;
- this.colItemCode.FieldName = “ItemCode”;
- this.colItemCode.Name = “colItemCode”;
- this.colItemCode.OptionsColumn.AllowEdit = false;
- this.colItemCode.OptionsColumn.ReadOnly = true;
- this.colItemCode.OptionsFilter.AllowFilter = false;
- this.colItemCode.Visible = true;
- this.colItemCode.VisibleIndex = 3;
- this.colItemCode.Width = 56;
- //
- // colUOM
- //
- this.colUOM.Caption = “UOM”;
- this.colUOM.FieldName = “UOM”;
- this.colUOM.Name = “colUOM”;
- this.colUOM.OptionsColumn.AllowEdit = false;
- this.colUOM.OptionsColumn.ReadOnly = true;
- this.colUOM.Visible = true;
- this.colUOM.VisibleIndex = 4;
- this.colUOM.Width = 25;
- //
- // colDocType
- //
- this.colDocType.Caption = “T”;
- this.colDocType.FieldName = “DocType”;
- this.colDocType.Name = “colDocType”;
- this.colDocType.OptionsColumn.AllowEdit = false;
- this.colDocType.OptionsColumn.ReadOnly = true;
- this.colDocType.Visible = true;
- this.colDocType.VisibleIndex = 5;
- this.colDocType.Width = 23;
- //
- // colDocDate
- //
- this.colDocDate.Caption = “Date”;
- this.colDocDate.FieldName = “DocDate”;
- this.colDocDate.Name = “colDocDate”;
- this.colDocDate.OptionsColumn.AllowEdit = false;
- this.colDocDate.OptionsColumn.ReadOnly = true;
- this.colDocDate.Visible = true;
- this.colDocDate.VisibleIndex = 6;
- this.colDocDate.Width = 44;
- //
- // colDocNo
- //
- this.colDocNo.Caption = “Doc. No”;
- this.colDocNo.FieldName = “DocNo”;
- this.colDocNo.Name = “colDocNo”;
- this.colDocNo.OptionsColumn.AllowEdit = false;
- this.colDocNo.OptionsColumn.ReadOnly = true;
- this.colDocNo.Visible = true;
- this.colDocNo.VisibleIndex = 7;
- this.colDocNo.Width = 41;
- //
- // colDescription
- //
- this.colDescription.Caption = “Description”;
- this.colDescription.FieldName = “Description”;
- this.colDescription.Name = “colDescription”;
- this.colDescription.OptionsColumn.AllowEdit = false;
- this.colDescription.OptionsColumn.ReadOnly = true;
- this.colDescription.Visible = true;
- this.colDescription.VisibleIndex = 8;
- this.colDescription.Width = 123;
- //
- // colLocation
- //
- this.colLocation.Caption = “Location”;
- this.colLocation.FieldName = “Location”;
- this.colLocation.Name = “colLocation”;
- this.colLocation.OptionsColumn.AllowEdit = false;
- this.colLocation.OptionsColumn.ReadOnly = true;
- this.colLocation.Visible = true;
- this.colLocation.VisibleIndex = 9;
- this.colLocation.Width = 30;
- //
- // colQty
- //
- this.colQty.Caption = “Qty”;
- this.colQty.FieldName = “Qty”;
- this.colQty.Name = “colQty”;
- this.colQty.OptionsColumn.AllowEdit = false;
- this.colQty.OptionsColumn.ReadOnly = true;
- this.colQty.Visible = true;
- this.colQty.VisibleIndex = 10;
- this.colQty.Width = 29;
- //
- // colUnitPrice
- //
- this.colUnitPrice.Caption = “Unit Price”;
- this.colUnitPrice.FieldName = “UnitPrice”;
- this.colUnitPrice.Name = “colUnitPrice”;
- this.colUnitPrice.OptionsColumn.AllowEdit = false;
- this.colUnitPrice.OptionsColumn.ReadOnly = true;
- this.colUnitPrice.Visible = true;
- this.colUnitPrice.VisibleIndex = 11;
- this.colUnitPrice.Width = 34;
- //
- // colLocalUnitPrice
- //
- this.colLocalUnitPrice.Caption = “Local Unit Price”;
- this.colLocalUnitPrice.FieldName = “LocalUnitPrice”;
- this.colLocalUnitPrice.Name = “colLocalUnitPrice”;
- this.colLocalUnitPrice.OptionsColumn.AllowEdit = false;
- this.colLocalUnitPrice.OptionsColumn.ReadOnly = true;
- //
- // colDiscount
- //
- this.colDiscount.Caption = “Discount”;
- this.colDiscount.FieldName = “Discount”;
- this.colDiscount.Name = “colDiscount”;
- this.colDiscount.OptionsColumn.AllowEdit = false;
- this.colDiscount.OptionsColumn.ReadOnly = true;
- this.colDiscount.Visible = true;
- this.colDiscount.VisibleIndex = 12;
- this.colDiscount.Width = 39;
- //
- // colSubTotal
- //
- this.colSubTotal.Caption = “SubTotal”;
- this.colSubTotal.FieldName = “SubTotal”;
- this.colSubTotal.Name = “colSubTotal”;
- this.colSubTotal.OptionsColumn.AllowEdit = false;
- this.colSubTotal.OptionsColumn.ReadOnly = true;
- this.colSubTotal.Visible = true;
- this.colSubTotal.VisibleIndex = 13;
- this.colSubTotal.Width = 44;
- //
- // colLocalSubTotal
- //
- this.colLocalSubTotal.Caption = “Local SubTotal”;
- this.colLocalSubTotal.FieldName = “LocalSubTotal”;
- this.colLocalSubTotal.Name = “colLocalSubTotal”;
- this.colLocalSubTotal.OptionsColumn.AllowEdit = false;
- this.colLocalSubTotal.OptionsColumn.ReadOnly = true;
- //
- // colDocKey
- //
- this.colDocKey.Caption = “DocKey”;
- this.colDocKey.FieldName = “DocKey”;
- this.colDocKey.Name = “colDocKey”;
- this.colDocKey.OptionsColumn.AllowEdit = false;
- this.colDocKey.OptionsColumn.ReadOnly = true;
- this.colDocKey.OptionsFilter.AllowFilter = false;
- this.colDocKey.Width = 49;
- //
- // colProjNo
- //
- this.colProjNo.Caption = “Proj. No”;
- this.colProjNo.FieldName = “ProjNo”;
- this.colProjNo.Name = “colProjNo”;
- this.colProjNo.OptionsColumn.AllowEdit = false;
- this.colProjNo.OptionsColumn.ReadOnly = true;
- this.colProjNo.Width = 50;
- //
- // colDeptNo
- //
- this.colDeptNo.Caption = “Dept. No”;
- this.colDeptNo.FieldName = “DeptNo”;
- this.colDeptNo.Name = “colDeptNo”;
- this.colDeptNo.OptionsColumn.AllowEdit = false;
- this.colDeptNo.OptionsColumn.ReadOnly = true;
- this.colDeptNo.Width = 54;
- //
- // colRate
- //
- this.colRate.Caption = “Rate”;
- this.colRate.FieldName = “Rate”;
- this.colRate.Name = “colRate”;
- this.colRate.OptionsColumn.AllowEdit = false;
- this.colRate.OptionsColumn.ReadOnly = true;
- this.colRate.Width = 33;
- //
- // colSmallestQty
- //
- this.colSmallestQty.Caption = “Smallest Qty”;
- this.colSmallestQty.FieldName = “SmallestQty”;
- this.colSmallestQty.Name = “colSmallestQty”;
- this.colSmallestQty.OptionsColumn.AllowEdit = false;
- this.colSmallestQty.OptionsColumn.ReadOnly = true;
- this.colSmallestQty.Width = 73;
- //
- // colTaxType
- //
- this.colTaxType.Caption = “Tax Type”;
- this.colTaxType.FieldName = “TaxType”;
- this.colTaxType.Name = “colTaxType”;
- this.colTaxType.OptionsColumn.AllowEdit = false;
- this.colTaxType.OptionsColumn.ReadOnly = true;
- this.colTaxType.Width = 56;
- //
- // colFOCQty
- //
- this.colFOCQty.Caption = “FOC Qty”;
- this.colFOCQty.FieldName = “FOCQty”;
- this.colFOCQty.Name = “colFOCQty”;
- this.colFOCQty.OptionsColumn.AllowEdit = false;
- this.colFOCQty.OptionsColumn.ReadOnly = true;
- //
- // colFurtherDesc
- //
- this.colFurtherDesc.Caption = “Further Description”;
- this.colFurtherDesc.ColumnEdit = this.repositoryItemButtonEdit1;
- this.colFurtherDesc.FieldName = “FurtherDescription”;
- this.colFurtherDesc.Name = “colFurtherDesc”;
- this.colFurtherDesc.Width = 30;
- //
- // repositoryItemButtonEdit1
- //
- this.repositoryItemButtonEdit1.AutoHeight = false;
- this.repositoryItemButtonEdit1.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
- new DevExpress.XtraEditors.Controls.EditorButton()});
- this.repositoryItemButtonEdit1.Name = “repositoryItemButtonEdit1″;
- this.repositoryItemButtonEdit1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
- this.repositoryItemButtonEdit1.ButtonPressed += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(this.repositoryItemButtonEdit1_ButtonClick);
- //
- // colCurrencyRate
- //
- this.colCurrencyRate.Caption = “Currency Rate”;
- this.colCurrencyRate.FieldName = “CurrencyRate”;
- this.colCurrencyRate.Name = “colCurrencyRate”;
- this.colCurrencyRate.OptionsColumn.AllowEdit = false;
- this.colCurrencyRate.OptionsColumn.ReadOnly = true;
- this.colCurrencyRate.Width = 35;
- //
- // colCurrencyCode
- //
- this.colCurrencyCode.Caption = “Currency Code”;
- this.colCurrencyCode.FieldName = “CurrencyCode”;
- this.colCurrencyCode.Name = “colCurrencyCode”;
- this.colCurrencyCode.OptionsColumn.AllowEdit = false;
- this.colCurrencyCode.OptionsColumn.ReadOnly = true;
- this.colCurrencyCode.Width = 35;
- //
- // pnAccNo
- //
- this.pnAccNo.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
- this.pnAccNo.Controls.Add(this.ckEdtShowCreditor);
- this.pnAccNo.Controls.Add(this.ckEdtShowDebtor);
- this.pnAccNo.Dock = System.Windows.Forms.DockStyle.Top;
- this.pnAccNo.Location = new System.Drawing.Point(0, 0);
- this.pnAccNo.Name = “pnAccNo”;
- this.pnAccNo.Size = new System.Drawing.Size(700, 24);
- this.pnAccNo.TabIndex = 0;
- //
- // ckEdtShowCreditor
- //
- this.ckEdtShowCreditor.EditValue = true;
- this.ckEdtShowCreditor.Location = new System.Drawing.Point(105, 3);
- this.ckEdtShowCreditor.Name = “ckEdtShowCreditor”;
- this.ckEdtShowCreditor.Properties.Caption = “Show Creditor”;
- this.ckEdtShowCreditor.Size = new System.Drawing.Size(93, 19);
- this.ckEdtShowCreditor.TabIndex = 6;
- this.ckEdtShowCreditor.CheckedChanged += new System.EventHandler(this.ckEdtShowCreditor_CheckedChanged);
- //
- // ckEdtShowDebtor
- //
- this.ckEdtShowDebtor.EditValue = true;
- this.ckEdtShowDebtor.Location = new System.Drawing.Point(3, 3);
- this.ckEdtShowDebtor.Name = “ckEdtShowDebtor”;
- this.ckEdtShowDebtor.Properties.Caption = “Show Debtor”;
- this.ckEdtShowDebtor.Size = new System.Drawing.Size(87, 19);
- this.ckEdtShowDebtor.TabIndex = 5;
- this.ckEdtShowDebtor.CheckedChanged += new System.EventHandler(this.ckEdtShowDebtor_CheckedChanged);
- //
- // UCPriceHistory
- //
- this.Controls.Add(this.gctrPriceHistory);
- this.Controls.Add(this.pnAccNo);
- this.Name = “UCPriceHistory”;
- this.Size = new System.Drawing.Size(700, 200);
- ((System.ComponentModel.ISupportInitialize)(this.gctrPriceHistory)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.gvPriceHistory)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.repositoryItemButtonEdit1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.pnAccNo)).EndInit();
- this.pnAccNo.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.ckEdtShowCreditor.Properties)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.ckEdtShowDebtor.Properties)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- ///<summary>
- /// Must be call before use PriceHistory for Instant Info
- ///</summary>
- ///<param name=”dbSetting”></param>
- ///<param name=”itemCode”></param>
- ///<param name=”accNo”></param>
- ///<param name=”branchCode”></param>
- public void Initialize(DBSetting dbSetting, string itemCode)
- {
- myIsInstantInfo = true;
- Initialize(dbSetting, itemCode, “”, null, null);
- }
- ///<summary>
- /// Call by Item Inquiry
- ///</summary>
- ///<param name=”dbSetting”></param>
- ///<param name=”itemCode”></param>
- ///<param name=”accNo”></param>
- ///<param name=”branchCode”></param>
- ///<param name=”uom”></param>
- public void Initialize(DBSetting dbSetting, string itemCode, string uom)
- {
- Initialize(dbSetting, itemCode, uom, null, null);
- }
- ///<summary>
- /// Must be call before can use PriceHistory for Stock Inquiry Use
- ///</summary>
- ///<param name=”dbSetting”></param>
- ///<param name=”itemCode”></param>
- ///<param name=”accNo”></param>
- ///<param name=”branchCode”></param>
- ///<param name=”uom”>if uom length is 0, then it is from Stock Inquiry not Instant Info</param>
- ///<param name=”fromDate”></param>
- ///<param name=”toDate”></param>
- public void Initialize(DBSetting dbSetting, string itemCode, string uom, object fromDate,
- object toDate)
- {
- myDbSetting = dbSetting;
- new BCE.AutoCount.XtraUtils.CustomizeGridLayout(myDbSetting, this.Name, gvPriceHistory,
- new System.EventHandler(this.ReloadAllColumns));
- myPriceHistoryInquiry = PriceHistory.Create(dbSetting);
- Reload(itemCode, uom, fromDate, toDate);
- if (myIsInstantInfo)
- {
- colAccNo.Visible = false;
- colCompanyName.Visible = false;
- }
- ColumnVisibility();
- }
- public bool IsInitialize
- {
- get { return myPriceHistoryInquiry != null; }
- }
- public void SetFilterToBlank()
- {
- myItemCode = string.Empty;
- }
- public void Reload(string itemCode)
- {
- Reload(itemCode, “”, null, null);
- }
- public void Reload(string itemCode, string uom)
- {
- Reload(itemCode, uom, null, null);
- }
- public void Reload(string itemCode, string uom, object fromDate, object toDate)
- {
- if (!IsInitialize)
- return;
- if (itemCode.Length == 0 && uom.Length == 0)
- {
- Reset();
- gctrPriceHistory.DataSource = null;
- return;
- }
- if ((itemCode == myItemCode) && (uom == myUom) && (myShowDebtor == ckEdtShowDebtor.Checked) && (myShowCreditor == ckEdtShowCreditor.Checked))
- {
- bool changed = false;
- if ((fromDate == null && myFromDate != null) || (fromDate != null && myFromDate == null))
- changed = true;
- if ((toDate == null && myToDate != null) || (toDate != null && myToDate == null))
- changed = true;
- if (!changed)
- {
- if (fromDate == null && myFromDate == null && toDate == null && myToDate == null)
- return;
- if (fromDate.Equals(myFromDate) && toDate.Equals(myToDate))
- return;
- }
- }
- myItemCode = itemCode;
- myUom = uom;
- myFromDate = fromDate;
- myToDate = toDate;
- myShowDebtor = ckEdtShowDebtor.Checked;
- myShowCreditor = ckEdtShowCreditor.Checked;
- string[] excludeColumns = {“AccNo”, “BranchCode”, “DocType”, “Description”, “CompanyName”, “ItemCode”, “UOM”,
- “UnitPrice”, “SubTotal”, “CurrencyRate”, “LocalUnitPrice”, “LocalSubTotal”, “CurrencyCode”};
- string columns = BCE.AutoCount.XtraUtils.ColumnViewUtils.BuildSQLColumnListFromColumnView(gvPriceHistory, “A”, false, null, excludeColumns);
- Cursor currentCursor = Cursor.Current;
- Cursor.Current = Cursors.WaitCursor;
- try
- {
- myPriceHistoryInquiry.Inquire(itemCode, uom, BuildDocType(),
- fromDate, toDate, columns);
- }
- catch (BCE.Data.DataAccessException ex)
- {
- BCE.Application.AppMessage.ShowErrorMessage(ex.Message);
- Reset();
- return;
- }
- finally
- {
- Cursor.Current = currentCursor;
- }
- gctrPriceHistory.DataSource = myPriceHistoryInquiry.PriceHistoryTable;
- }
- public void Reset()
- {
- myItemCode = “”;
- myUom = “”;
- myToDate = null;
- myFromDate = null;
- }
- private string[] BuildDocType()
- {
- ArrayList docType = new ArrayList();
- if (ckEdtShowDebtor.Checked)
- {
- docType.Add(“QT”);
- docType.Add(“SO”);
- docType.Add(“DO”);
- docType.Add(“IV”);
- docType.Add(“CS”);
- docType.Add(“CN”);
- docType.Add(“DN”);
- docType.Add(“XS”);
- docType.Add(“DR”);
- }
- if (ckEdtShowCreditor.Checked)
- {
- docType.Add(“PR”);
- docType.Add(“RQ”);
- docType.Add(“PO”);
- docType.Add(“GR”);
- docType.Add(“PI”);
- docType.Add(“CP”);
- docType.Add(“PR”);
- docType.Add(“XP”);
- docType.Add(“GN”);
- }
- string[] myDocType = new string[docType.Count];
- docType.CopyTo(myDocType);
- return myDocType;
- }
- private void ReloadAllColumns(object sender, System.EventArgs e)
- {
- if (!IsInitialize)
- return;
- string[] excludeColumn = {“AccNo”, “BranchCode”, “DocType”, “DocKey”, “Description”, “CompanyName”, “ItemCode”,
- “UOM”, “UnitPrice”, “SubTotal”, “CurrencyRate”, “LocalUnitPrice”, “LocalSubTotal”, “CurrencyCode”};
- string columns = BCE.AutoCount.XtraUtils.ColumnViewUtils.BuildSQLColumnListFromColumnView(gvPriceHistory, “A”, false, null,
- excludeColumn);
- object fromDate, toDate;
- if (myFromDate != null && (DateTime)myFromDate != new DateTime(1, 1, 1))
- fromDate = myFromDate;
- else
- fromDate = null;
- if (myToDate != null && (DateTime)myToDate != new DateTime(1, 1, 1))
- toDate = myToDate;
- else
- toDate = null;
- myPriceHistoryInquiry.Inquire(myItemCode, myUom, BuildDocType(), fromDate, toDate, columns);
- gctrPriceHistory.DataSource = myPriceHistoryInquiry.PriceHistoryTable;
- }
- private void GoToDocument()
- {
- DevExpress.XtraGrid.Views.Base.ColumnView gv =
- (DevExpress.XtraGrid.Views.Base.ColumnView)gctrPriceHistory.FocusedView;
- DataRow r = gv.GetDataRow(gv.FocusedRowHandle);
- if (r != null)
- {
- string sourceType = r[“DocType”].ToString();
- long sourceKey = BCE.Data.Convert.ToInt64(r[“DocKey”]);
- BCE.AutoCount.Controller.DocumentDispatcher.Open(myDbSetting, sourceType, sourceKey);
- }
- }
- private void gvPriceHistory_DoubleClick(object sender, System.EventArgs e)
- {
- if (!myMouseDownHelper.IsLeftMouseDown) return;
- DevExpress.XtraGrid.Views.Grid.GridView view = (DevExpress.XtraGrid.Views.Grid.GridView)sender;
- DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hitInfo = BCE.XtraUtils.GridViewUtils.GetGridHitInfo(view);
- if (hitInfo.InRow && BCE.AutoCount.Authentication.AccessRight.Create(myDbSetting, BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(myDbSetting).LoginUserID).IsAccessible(BCE.AutoCount.Const.AccessRightConst.SYS_BHV_DRILLDOWN))
- GoToDocument();
- }
- ///<summary>
- /// Refactored from barchkShowAllBranches_CheckedChanged
- ///</summary>
- private void ColumnVisibility()
- {
- BCE.AutoCount.Controller.ModuleController modControl = new BCE.AutoCount.Controller.ModuleController();
- colLocalUnitPrice.OptionsColumn.ShowInCustomizationForm = modControl.MultiCurrency.Enable;
- colLocalSubTotal.OptionsColumn.ShowInCustomizationForm = modControl.MultiCurrency.Enable;
- }
- private void gvPriceHistory_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
- {
- if (gvPriceHistory.FocusedRowHandle < 0)
- return;
- DataRow row = gvPriceHistory.GetDataRow(gvPriceHistory.FocusedRowHandle);
- if (myItemCodeChanged != null)
- {
- myItemCodeChanged(row[“ItemCode”].ToString(), row[“UOM”].ToString());
- }
- }
- private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
- {
- DataTable myTable = ((DataView)gvPriceHistory.DataSource).Table;
- BCE.AutoCount.CommonForms.FormRichTextEditor form = new BCE.AutoCount.CommonForms.FormRichTextEditor(myDbSetting, myTable,
- gvPriceHistory.GetDataSourceRowIndex(gvPriceHistory.FocusedRowHandle), “FurtherDescription”, “Further Description”,
- false);
- form.ShowDialog(this);
- form.Dispose();
- }
- public enum FilterType
- {
- None,
- Item,
- AccNo
- }
- private void ckEdtShowDebtor_CheckedChanged(object sender, EventArgs e)
- {
- Reload(myItemCode);
- }
- private void ckEdtShowCreditor_CheckedChanged(object sender, EventArgs e)
- {
- Reload(myItemCode);
- }
- private void gvPriceHistory_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
- {
- DevExpress.XtraGrid.Views.Grid.GridView gv = (DevExpress.XtraGrid.Views.Grid.GridView)sender;
- DataRow row = gv.GetDataRow(e.RowHandle);
- if (row == null) return;
- string docType = row[“DocType”].ToString();
- if (docType == “CN”)
- e.Appearance.ForeColor = Color.Blue;
- else if (docType == “GR” || docType == “PI” || docType == “CP”)
- e.Appearance.ForeColor = Color.Red;
- }
- }
- [Serializable()]
- public class UCPriceHistorySetting
- {
- public bool ShowDebtor = true;
- public bool ShowCreditor = true;
- }
- }
The UI would look like the image below:
The Logic class
The following codes is to handle the logic used by the UI component:
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using BCE.AutoCount;
- using BCE.Data;
- namespace MyAutoCountProject
- {
- ///<summary>
- /// Summary description for PriceHistory.
- ///</summary>
- public class PriceHistory
- {
- public DBSetting myDBSetting;
- protected DataTable myPriceHistoryTable;
- public DataTable PriceHistoryTable
- {
- get { return myPriceHistoryTable; }
- }
- internal PriceHistory()
- {
- myPriceHistoryTable = new DataTable();
- }
- public static PriceHistory Create(DBSetting dbSetting)
- {
- PriceHistory priceHistory;
- if (dbSetting.ServerType == DBServerType.SQL2000)
- priceHistory = new PriceHistorySQL();
- else
- throw new ArgumentException(“Server type: “ + dbSetting.ServerType + ” not supported.”);
- priceHistory.myDBSetting = dbSetting;
- return priceHistory;
- }
- protected string BuildPriceHistorySQL(string itemCode, string uom,
- string[] docType, string columns, IDbCommand cmd, object fromDate, object toDate)
- {
- string cmdTxt;
- if(columns.Length > 0)
- {
- columns += “, A.AccNo, A.BranchCode, A.DocType, A.DocKey, A.Description, “
- +“A.ItemCode, A.UOM, A.UnitPrice, A.SubTotal, “
- +“A.CurrencyRate, (A.UnitPrice * A.CurrencyRate) AS LocalUnitPrice, “
- + “(A.SubTotal * A.CurrencyRate) AS LocalSubTotal, B.Description AS CompanyName, B.CurrencyCode “;
- }
- else
- columns = “*”;
- cmdTxt = “SELECT “ + columns + ” FROM IPHist A “;
- cmdTxt += “LEFT OUTER JOIN GLMast B ON A.AccNo = B.AccNo “;
- string tempSql = string.Empty;
- if (itemCode.Length > 0)
- {
- tempSql += “AND A.ItemCode = @ItemCode “;
- IDbDataParameter param = cmd.CreateParameter();
- param.ParameterName = “@ItemCode”;
- param.Value = itemCode;
- cmd.Parameters.Add(param);
- }
- if (uom.Length > 0)
- {
- tempSql += “AND A.UOM = @UOM “;
- IDbDataParameter param = cmd.CreateParameter();
- param.ParameterName = “@UOM”;
- param.Value = uom;
- cmd.Parameters.Add(param);
- }
- tempSql += SubBuildDocType(docType, cmd);// + ” ORDER BY DocDate DESC”;
- if (fromDate != null)
- {
- tempSql += “AND A.DocDate >= @FromDate “;
- IDbDataParameter param = cmd.CreateParameter();
- param.ParameterName = “@FromDate”;
- param.Value = (DateTime)fromDate;
- cmd.Parameters.Add(param);
- }
- if (toDate != null)
- {
- tempSql += “AND A.DocDate <= @ToDate “;
- IDbDataParameter param2 = cmd.CreateParameter();
- param2.ParameterName = “@ToDate”;
- param2.Value = (DateTime)toDate;
- cmd.Parameters.Add(param2);
- }
- if (tempSql.Length > 0)
- cmdTxt += “WHERE 1=1 “ +tempSql;
- else
- cmdTxt += “WHERE 1=0 “;
- return cmdTxt;
- }
- private string SubBuildDocType(string[] docType, IDbCommand cmd)
- {
- // If select all type
- if (docType.Length == 17)
- return“”;
- string subTxtDocType = “AND A.DocType IN (“;
- for (int i=0; i<docType.Length; i++)
- {
- IDbDataParameter param = cmd.CreateParameter();
- param.ParameterName = “@DocType”+i;
- param.Value = docType[i];
- cmd.Parameters.Add(param);
- if (i == docType.Length-1 )
- subTxtDocType += ” @DocType” +i +” )”;
- else
- subTxtDocType += ” @DocType” +i +“,”;
- }
- return subTxtDocType;
- }
- ///<summary>
- /// Query to get the result
- ///</summary>
- ///<param name=”itemCode”></param>
- ///<param name=”accNo”></param>
- ///<param name=”branchCode”></param>
- ///<param name=”uom”></param>
- ///<param name=”showAllBranches”></param>
- ///<param name=”docType”></param>
- ///<param name=”myDateFilter”></param>
- ///<param name=”fromDate”></param>
- ///<param name=”toDate”></param>
- ///<param name=”columns”>Column available in the grid</param>
- ///<param name=”filterType”></param>
- ///<param name=”filterString”></param>
- public virtual void Inquire(string itemCode, string uom,
- string[] docType, object fromDate, object toDate, string columns)
- {
- }
- public void Inquire(string itemCode, string uom,
- string[] docType)
- {
- Inquire(itemCode, uom, docType, null, null, “*”);
- }
- }
- public class PriceHistorySQL : PriceHistory
- {
- public override void Inquire(string itemCode, string uom,
- string[] docType, object fromDate, object toDate, string columns)
- {
- myPriceHistoryTable.Clear();
- if (docType.Length == 0)
- return;
- SqlConnection myConn = new SqlConnection(myDBSetting.ConnectionString);
- try
- {
- myConn.Open();
- SqlCommand myCmd = new SqlCommand();
- myCmd.Connection = myConn;
- string cmdTxt = BuildPriceHistorySQL(itemCode, uom, docType, columns, myCmd,
- fromDate, toDate);
- myCmd.CommandText = cmdTxt;
- SqlDataAdapter dadPriceHistory = new SqlDataAdapter(myCmd);
- dadPriceHistory.Fill(myPriceHistoryTable);
- }
- catch (SqlException ex)
- {
- DataError.HandleSqlException(ex);
- }
- finally
- {
- myConn.Close();
- myConn.Dispose();
- }
- }
- }
- }
Compile both of the classes above into a .dll and copy it into the installation folder of AutoCount Accounting before calling the class in the script management.
Calling the created class
The following codes is to be added in the Script Maintenance window under the InstantInfo category as shown below.
For Invoicing Instant Info
This is to show the new tab in the Invoicing Instant Info. The Invoicing Instant Info is used in the following windows:
Entry Form using the UCInquiry |
---|
Credit Note Entry |
Debit Note Entry |
Delivery Order Entry |
Quotation Entry |
Sales Order Entry |
Goods Received Note Entry |
Purchase Order Entry |
Purchase Return Entry |
Request Quotation Entry |
Past Sale Entry (Data Entry By Past Sales Records) |
To directly copy this code snippet into the system, just copy and paste the code into the Invoicing Instant Info script under the InstantInfo category in Script Maintenance (as shown in the image previously):
- DevExpress.XtraTab.XtraTabPage myPriceHistoryTabPage;
- UCPriceHistory myUCPriceHistory;
- ///<summary>
- /// Use this event to do user control initialization
- ///</summary>
- ///<param name=”e”>The event argument</param>
- public void OnInitialize(object sender, BCE.AutoCount.Inquiry.UserControls.UCInquiryInitializeEventArgs e)
- {
- myPriceHistoryTabPage = e.TabControl.TabPages.Add();
- myUCPriceHistory = new UCPriceHistory();
- myUCPriceHistory.Location = new System.Drawing.Point(0, 0);
- myUCPriceHistory.Dock = System.Windows.Forms.DockStyle.Fill;
- myPriceHistoryTabPage.Text = “All Price History”;
- myPriceHistoryTabPage.Controls.Add(myUCPriceHistory);
- }
- ///<summary>
- /// Use this event to do reload of the user control
- ///</summary>
- ///<param name=”e”>The event argument</param>
- public void OnReload(object sender, BCE.AutoCount.Inquiry.UserControls.UCInquiryReloadEventArgs e)
- {
- if (!myUCPriceHistory.IsInitialize)
- myUCPriceHistory.Initialize(BCE.AutoCount.Application.DBSetting, e.ItemCode, e.UOM);
- else
- myUCPriceHistory.Reload(e.ItemCode, e.UOM);
- }
For Instant Info with Consignment Info
This is to show the new tab in the Instant Info with Consignment Info. The Instant Info with Consignment Info is used in the following windows:
Entry Form using the UCInquiryCSGN |
---|
Bonus Point Redemption Entry |
Cash Sale Entry |
POS Cash Sale Entry |
Consignment Entry |
Invoice Entry |
Cash Purchase Entry |
Purchase Invoice Entry |
Supplier Consignment Entry |
To directly copy this code snippet into the system, just copy and paste the code into the Instant Info with Consignment Info script under the InstantInfo category in Script Maintenance (as shown in the image previously):
- DevExpress.XtraTab.XtraTabPage myPriceHistoryTabPage;
- UCPriceHistory myUCPriceHistory;
- ///<summary>
- /// Use this event to do user control initialization
- ///</summary>
- ///<param name=”e”>The event argument</param>
- public void OnInitialize(object sender, BCE.AutoCount.Inquiry.UserControls.UCInquiryInitializeEventArgs e)
- {
- myPriceHistoryTabPage = e.TabControl.TabPages.Add();
- myUCPriceHistory = new UCPriceHistory();
- myUCPriceHistory.Location = new System.Drawing.Point(0, 0);
- myUCPriceHistory.Dock = System.Windows.Forms.DockStyle.Fill;
- myPriceHistoryTabPage.Text = “All Price History”;
- myPriceHistoryTabPage.Controls.Add(myUCPriceHistory);
- }
- ///<summary>
- /// Use this event to do reload of the user control
- ///</summary>
- ///<param name=”e”>The event argument</param>
- public void OnReload(object sender, BCE.AutoCount.Inquiry.UserControls.UCInquiryReloadEventArgs e)
- {
- if (!myUCPriceHistory.IsInitialize)
- myUCPriceHistory.Initialize(BCE.AutoCount.Application.DBSetting, e.ItemCode, e.UOM);
- else
- myUCPriceHistory.Reload(e.ItemCode, e.UOM);
- }
For Stock Instant Info
This is to show the new tab in the Stock Instant Info. The Stock Instant Info is used in the following windows:
Entry Form using the UCInquiryStock |
---|
Stock Assembly Entry |
Stock Assembly Order Entry |
Account Inquiry |
Stock Adjustment Entry |
Stock Issue Entry |
Stock Receive Entry |
Stock Transfer Entry |
Stock Write-Off Entry |
To directly copy this code snippet into the system, just copy and paste the code into the Stock Instant Info script under the InstantInfo category in Script Maintenance (as shown in the image previously):
- DevExpress.XtraTab.XtraTabPage myPriceHistoryTabPage;
- UCPriceHistory myUCPriceHistory;
- ///<summary>
- /// Use this event to do user control initialization
- ///</summary>
- ///<param name=”e”>The event argument</param>
- public void OnInitialize(object sender, BCE.AutoCount.Inquiry.UserControls.UCInquiryInitializeEventArgs e)
- {
- myPriceHistoryTabPage = e.TabControl.TabPages.Add();
- myUCPriceHistory = new UCPriceHistory();
- myUCPriceHistory.Location = new System.Drawing.Point(0, 0);
- myUCPriceHistory.Dock = System.Windows.Forms.DockStyle.Fill;
- myPriceHistoryTabPage.Text = “All Price History”;
- myPriceHistoryTabPage.Controls.Add(myUCPriceHistory);
- }
- ///<summary>
- /// Use this event to do reload of the user control
- ///</summary>
- ///<param name=”e”>The event argument</param>
- public void OnReload(object sender, BCE.AutoCount.Inquiry.UserControls.UCInquiryReloadEventArgs e)
- {
- if (!myUCPriceHistory.IsInitialize)
- myUCPriceHistory.Initialize(BCE.AutoCount.Application.DBSetting, e.ItemCode, e.UOM);
- else
- myUCPriceHistory.Reload(e.ItemCode, e.UOM);
- }