Пример #1
0
        public bool Insert(FlowProcess_FlowProcessSubProperty dataItem)
        {
            bool _result = false;

            try
            {
                _resultData = _models.Insert(dataItem);
                if (_resultData.StatusOnDb == true)
                {
                    MessageBox.Show(_resultData.MessageOnDb, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    _result = true;
                }
                else
                {
                    MessageBox.Show(_resultData.MessageOnDb, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(_result);
        }
 public OutputOnDbProperty Insert(FlowProcess_FlowProcessSubProperty dataItem)
 {
     _resultData = _services.Insert(dataItem);
     return(_resultData);
 }
Пример #3
0
        private void CreateFlow()
        {
            if (treeViewSetProcess.Nodes.Count == 0)
            {
                MessageBox.Show("Please Select Process For Create Flow", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            int NOProcess    = 0;
            int NOProcessSub = 0;

            List <ProcessFlowProperty>    _listFlowProcess    = new List <ProcessFlowProperty>();
            List <ProcessSubFlowProperty> _listFlowProcessSub = new List <ProcessSubFlowProperty>();

            foreach (TreeNode processMainNode in treeViewSetProcess.Nodes)
            {
                NOProcessSub = 0;

                FlowProperty _flowProperty = new FlowProperty
                {
                    FLOW_NAME = txtFlowName.Text,
                    FLOW_TYPE = new FlowTypeProperty
                    {
                        ID = "1"
                    },
                    PRODUCT_SUB_CODE = (cmbProduct.SelectedItem as ComboboxItem).Value.ToString()
                };

                ProcessFlowProperty _flowProcessProperty = new ProcessFlowProperty
                {
                    FLOW    = _flowProperty,
                    PROCESS = new ProcessProperty()
                    {
                        ID = processMainNode.Name.ToString()
                    },
                    NO          = (++NOProcess).ToString(),
                    CREATE_USER = _frmMain._empLogin.code
                };

                _listFlowProcess.Add(_flowProcessProperty);

                foreach (TreeNode processSubNode in processMainNode.Nodes)
                {
                    ProcessSubFlowProperty _flowProcessSubProperty = new ProcessSubFlowProperty
                    {
                        FLOW        = _flowProperty,
                        PROCESS_SUB = new ProcessSubProperty
                        {
                            PROCESS_SUB_ID = processSubNode.Name
                        },
                        NO          = (++NOProcessSub).ToString(),
                        CREATE_USER = _frmMain._empLogin.code
                    };
                    _listFlowProcessSub.Add(_flowProcessSubProperty);
                }
            }

            ////Get Procress for get id
            //List<ProcessProperty> _getProcess = new List<ProcessProperty>();
            //for (int i = 0; i < treeViewSetProcess.Items.Count; i++)
            //{
            //    int NOProcess = i + 1;
            //    ProcessProperty _process = new ProcessProperty()
            //    {
            //        ID = listSelectProcess[i].ID.ToString()
            //        ,
            //        PROCESS_NAME = listSelectProcess[i].PROCESS_NAME.ToString()
            //        ,
            //        NO = NOProcess.ToString()
            //    };
            //    _getProcess.Add(_process);
            //}

            //FlowProcessProperty _flowInsert = new FlowProcessProperty();
            //_flowInsert.FLOW = new FlowProperty
            //{
            //    FLOW_NAME = txtFlowName.Text
            //};

            //_flowInsert.PROCESS = new List<ProcessProperty>();
            //_flowInsert.PROCESS = _getProcess;
            //////Get Process ID.
            ////foreach (ProcessProperty _process in _getProcess)
            ////{
            ////    foreach (ProcessProperty _processAll in _listProcessAll)
            ////    {
            ////        if (_process.PROCESS_NAME == _processAll.PROCESS_NAME)
            ////        {
            ////            ProcessProperty _orderprocess = new ProcessProperty()
            ////            {
            ////                ID = _processAll.ID
            ////                ,NO  = _process.NO
            ////                ,PROCESS_NAME = _processAll.PROCESS_NAME
            ////            };
            ////            _flowInsert.PROCESS.Add(_orderprocess);
            ////        }
            ////    }
            ////}

            //// Check Flow process
            //_listFlowProcess = new List<FlowProcessProperty>();
            //string countNoProcess = Convert.ToString(_getProcess.Count);
            //_listFlowProcess = _controllers.CheckDuplicateFlowProcess(countNoProcess);

            //bool status = false;
            //foreach (FlowProcessProperty flow in _listFlowProcess)
            //{
            //    int j = 0;
            //    for (int i = 0; i < Convert.ToInt16(countNoProcess); i++)
            //    {
            //        status = false;
            //        if (flow.PROCESS[i].PROCESS_NAME.ToString() == listSelectProcess[i].PROCESS_NAME.ToString())
            //        {
            //            status = true;
            //        }
            //        if (!status)
            //        {
            //            break;
            //        }
            //    }
            //    if (status)
            //    {
            //        MessageBox.Show("Duplicate Flow name : " + flow.FLOW.FLOW_NAME, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //        return;
            //    }
            //}


            ////for (int i = 0; i < _listFlowProcess.Count; i++)
            ////{
            ////    int checkFlow = 0;
            ////    for (int j = 0; j < _listFlowProcess[i].PROCESS.Count; j++)
            ////    {
            ////        if (_listFlowProcess[i].PROCESS[j].ID == _flowInsert.PROCESS[j].ID)
            ////        {
            ////            checkFlow = checkFlow + 1;
            ////            if (checkFlow == _flowInsert.PROCESS.Count)
            ////            {
            ////                MessageBox.Show("Have FlowProcess in Database " +
            ////                    "\n" + "Flow name : " + _listFlowProcess[i].FLOW.FLOW_NAME +
            ////                    "\n" + "Status : " + _listFlowProcess[i].FLOW.STATUS, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            ////                return;
            ////            }
            ////        }
            ////        else { break; }
            ////    }
            ////}



            //Insert Flow.
            //if (_controllers.InsertFlow(_flowInsert)) { _frmMain.Load_SetFlow(); }

            FlowProcess_FlowProcessSubProperty flowProcess_FlowProcessSubProperty = new FlowProcess_FlowProcessSubProperty
            {
                listProcessFlowProperty    = _listFlowProcess,
                listProcessSubFlowProperty = _listFlowProcessSub
            };

            if (_flowProcess_FlowProcessSubController.Insert(flowProcess_FlowProcessSubProperty))
            {
                _frmMain.Load_SetFlow();
                btnBack.PerformClick();
            }
        }