Ejemplo n.º 1
0
        private void LabelDragDrop(object sender, DragEventArgs e)
        {
            Label label = sender as Label;

            label.BorderStyle = BorderStyle.Fixed3D;
            DragItem     item = e.Data.GetData(typeof(DragItem)) as DragItem;
            MyProductRow row  = item.row;

            if (label.Tag == row)
            {
                return;
            }
            label.Text      = item.ToString();
            label.BackColor = Color.SeaShell;
            label.Tag       = row;
            m_Modified      = true;
            if (item.label != null)
            {
                item.label.Text      = "";
                item.label.BackColor = Color.SeaShell;
                item.label.Tag       = null;
            }
            if (row == null)
            {
                return;
            }
            // Check duplicate
            int code = row.Code;

            Label[,] currentFoodTable = tabControl1.SelectedTab.Tag as Label[, ];    // FoodTable放到TabPage.Tag去
            foreach (Label l in currentFoodTable)
            {
                var ro = l.Tag as MyProductRow;      // Label[,]內的label.Tag放著ProductRow
                if (ro == null)
                {
                    continue;
                }
                if (l == label)
                {
                    continue;
                }
                if (ro.Code == code)
                {
                    l.Text      = "";
                    l.BackColor = Color.SeaShell;
                    l.Tag       = null;
                }
            }
        }
Ejemplo n.º 2
0
        private void LabelDragDrop(object sender, DragEventArgs e)
        {
            Label label = sender as Label;

            label.BorderStyle = BorderStyle.None;
            DragItem item = e.Data.GetData(typeof(DragItem)) as DragItem;

            BasicDataSet.ProductRow row = item.row;
            if (label.Tag == row)
            {
                return;
            }
            label.Text      = item.ToString();
            label.BackColor = Color.SeaShell;
            label.Tag       = row;
            m_Modified      = true;
            if (item.label != null)
            {
                item.label.Text      = "";
                item.label.BackColor = Color.SeaShell;
                item.label.Tag       = null;
            }
            if (row == null)
            {
                return;
            }
            // Check duplicate
            int code = row.Code;

            foreach (Label l in m_FoodName)
            {
                BasicDataSet.ProductRow ro = l.Tag as BasicDataSet.ProductRow;
                if (ro == null)
                {
                    continue;
                }
                if (l == label)
                {
                    continue;
                }
                if (ro.Code == code)
                {
                    l.Text      = "";
                    l.BackColor = Color.SeaShell;
                    l.Tag       = null;
                }
            }
        }