using System; using System.Collections.Generic; using System.ComponentModel; using System.Collections.ObjectModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Threading; using DBLayer_Lib; using System.Data.SqlClient; using DevExpress.Utils; using DevExpress.Diagram.Core; using DevExpress.XtraDiagram; using DevExpress.XtraGrid.Views.Grid.ViewInfo; namespace Implementer { public partial class MainForm : Form { #region intit and globals public MainForm() { InitializeComponent(); DevExpress.XtraGrid.Views.Grid.GridView gridView = new DevExpress.XtraGrid.Views.Grid.GridView(); var transactions = new ObservableCollection<Item>(); for (int i = 0; i <= 100; i++) { transactions.Add(new Item { Content = "Item " + i }); } grdTransactions.AllowDrop = true; grdTransactions.DataSource = transactions; dgmWf.AddingNewItem += (s, e) => transactions.Remove(e.Item.Tag as Item); } Point mouseDownLocation; GridHitInfo gridHitInfo; #endregion #region events public void Mainform_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'vA_ERP4_ADMINDataSet.SYSTEM_MODULES' table. You can move, or remove it, as needed. //Project intiation //Fill drop down for project list cmbProject.SelectedIndex = 0; DataAccess dataAccess = new DataAccess(GlobalFunctions.GetConnectionString()); DataTable dtResult = dataAccess.ExecuteQueryDataSet("select MODULE_CODE ,MODULE_DESC from SYSTEM_MODULES where module_is_active=1").Tables[0]; cmbProject.DisplayMember = "MODULE_DESC"; cmbProject.ValueMember = "MODULE_CODE"; cmbProject.DataSource = dtResult; } private void cmbProject_SelectedIndexChanged(object sender, EventArgs e) { lblCurrentProject.Text = cmbProject.Text; if (cmbProject.Text != null) { DataAccess dataAccess = new DataAccess(GlobalFunctions.GetConnectionString()); DataTable dtTransactions = dataAccess.ExecuteQueryDataSet("select sys_trans_id, sys_trans_desc1 from WF_SYSTEM_TRANS where MODULE_CODE= '" + cmbProject.Text + "'").Tables[0]; grdTransactions.DataSource = dtTransactions; } } private void btnSalesInvoice_Click(object sender, EventArgs e) { int sysTransId = 1001; FillTransactionDetails(sysTransId); } #endregion #region drag drop private void grdTransactions_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && CanStartDragDrop(e.Location)) { StartDragDrop(); } } private void grdTransactions_MouseDown(object sender, MouseEventArgs e) { gridHitInfo = grdVTransactions.CalcHitInfo(e.Location); mouseDownLocation = e.Location; } private void grdTransactions_MouseLeave(object sender, EventArgs e) { if (gridHitInfo != null) gridHitInfo.View.ResetCursor(); gridHitInfo = null; } private bool CanStartDragDrop(Point location) { return gridHitInfo.InDataRow && (Math.Abs(location.X - mouseDownLocation.X) > 2 || Math.Abs(location.Y - mouseDownLocation.Y) > 2); } public void StartDragDrop() { var draggedRow = gridHitInfo.View.GetRow(gridHitInfo.RowHandle) as Item; var tool = new FactoryItemTool(" ", () => " ", diagram => new DiagramShape(BasicShapes.Rectangle) { Content = draggedRow.Content, Tag = draggedRow }, new System.Windows.Size(150, 100), false); dgmWf.Commands.Execute(DiagramCommandsBase.StartDragToolCommand, tool, null); } #endregion #region function private void FillTransactionDetails(int systemTransactionId) { //Fill document //Fill steps DataAccess dataAccess = new DataAccess(GlobalFunctions.GetConnectionString()); DataTable transactionDetails = dataAccess.ExecuteQueryDataSet("SELECT DOC_TYPE_DESC1 FROM WF_SYSTEM_TRANS_DT WHERE SYS_TRANS_ID=1001 and MODULE_CODE= '" + cmbProject.Text + "'").Tables[0]; transactionDetails.Rows.Add(); grdDocuments.DataSource = transactionDetails; grdDocuments.Columns["Details"].DisplayIndex = 2; grdDocuments.Columns["Delete"].DisplayIndex = 2; DataTable transactionSteps = dataAccess.ExecuteQueryDataSet("select WF_STEP_DESC1 from WF_STEPS where wf_id= 10101 and MODULE_CODE= '" + cmbProject.Text + "'").Tables[0]; transactionSteps.Rows.Add(); grdSteps.DataSource = transactionSteps; } #endregion } public class Item { public string Content { get; set; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)