public string Insert(ProcessFlowProperty dataItem) { sql = @"INSERT INTO process_flow ( FLOW_ID , NO , PROCESS_ID , DESCRIPTION , CREATE_USER ) VALUES ( (SELECT ID FROM flow WHERE FLOW_NAME = 'dataItem.FLOW.FLOW_NAME' AND INUSE = 1) , 'dataItem.NO' , 'dataItem.PROCESS_ID' , 'dataItem.DESCRIPTION' , 'dataItem.CREATE_USER' )"; sql = sql.Replace("dataItem.FLOW.FLOW_NAME", dataItem.FLOW.FLOW_NAME); sql = sql.Replace("dataItem.FLOW_ID", dataItem.FLOW.ID); sql = sql.Replace("dataItem.NO", dataItem.NO); sql = sql.Replace("dataItem.PROCESS_ID", dataItem.PROCESS.ID); sql = sql.Replace("dataItem.DESCRIPTION", dataItem.DESCRIPTION); sql = sql.Replace("dataItem.CREATE_USER", dataItem.CREATE_USER); sql = sql.Replace("dataItem.LAST_USER", dataItem.LAST_USER); sql = sql.Replace("dataItem.CREATE_DATE", dataItem.CREATE_DATE); sql = sql.Replace("dataItem.LAST_DATE", dataItem.LAST_DATE); return(sql); }
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(); } }