public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            InspectionItemSelectionDatatypeValueVo inVo = (InspectionItemSelectionDatatypeValueVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Update m_inspection_item_selection_datatype_value");
            sqlQuery.Append(" Set inspection_item_id = :itemid ");
            sqlQuery.Append(" where factory_cd = :faccd ");
            sqlQuery.Append(" and UPPER(inspection_item_selection_datatype_value_cd)  like UPPER(:inspectionitemselectiondatatypevaluecd) ");
            sqlQuery.Append(" and inspection_item_id = 0 ;");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);
            sqlParameter.AddParameterString("inspectionitemselectiondatatypevaluecd", inVo.InspectionItemCode + "%");
            sqlParameter.AddParameterInteger("itemid", inVo.InspectionItemId);

            UpdateResultVo outVo = new UpdateResultVo
            {
                AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

            return(outVo);
        }
        /// <summary>
        /// insert  the record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Add_btn_Click(object sender, EventArgs e)
        {
            InspectionItemSelectionDatatypeValueVo inVo = new InspectionItemSelectionDatatypeValueVo();

            inVo.InspectionItemId   = inspectionItemdata.InspectionItemId;
            inVo.InspectionItemName = inspectionItemdata.InspectionItemName;
            inVo.InspectionItemCode = inspectionItemdata.InspectionItemCode;

            AddInspectionSelectionDatetypeValueForItemForm newAddForm = new AddInspectionSelectionDatetypeValueForItemForm(CommonConstants.MODE_ADD, inVo);

            newAddForm.InspectionItemCode = InspectionItemCode;
            //if (inspectionItemdata != null)
            //{
            //    newAddForm.InspectionItemId = inspectionItemdata.InspectionItemId;
            //    newAddForm.InspectionItemName = inspectionItemdata.InspectionItemName;
            //    newAddForm.InspectionItemCode = inspectionItemdata.InspectionItemCode;
            //}

            newAddForm.ShowDialog();
            if (newAddForm.IntSuccess > 0)
            {
                messageData = new MessageData("mmci00001", Properties.Resources.mmci00001, null);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);
                GridBind();
            }
        }
        private void checkRunningCount(InspectionItemSelectionDatatypeValueVo inVo)
        {
            InspectionItemSelectionDatatypeValueVo outVo = new InspectionItemSelectionDatatypeValueVo();

            try
            {
                outVo = (InspectionItemSelectionDatatypeValueVo)base.InvokeCbm(new GetInspectionItemSelectionDatatypeValueSeqCbm(), inVo, false);
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }

            RunningNumber = 1;

            if (outVo != null && outVo.InspectionItemSelectionDatatypeValueCode != null)
            {
                string strTemp;
                strTemp = outVo.InspectionItemSelectionDatatypeValueCode;
                if (strTemp.LastIndexOf(GlobalMasterDataTypeEnum.CODE_SEPARATOR.GetValue()) > 0)
                {
                    strTemp = strTemp.Substring(strTemp.LastIndexOf(GlobalMasterDataTypeEnum.CODE_SEPARATOR.GetValue()) + 1);
                    if (strTemp.All(Char.IsDigit))
                    {
                        RunningNumber = Convert.ToInt32(strTemp) + 1;
                    }
                }
            }
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            InspectionItemSelectionDatatypeValueVo inVo = (InspectionItemSelectionDatatypeValueVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Update m_inspection_item_selection_datatype_value");
            sqlQuery.Append(" Set ");
            sqlQuery.Append(" inspection_item_selection_datatype_value_text = :datatypevaluetext, ");
            sqlQuery.Append(" display_order = :displayorder ");
            sqlQuery.Append(" where factory_cd = :faccd ");
            sqlQuery.Append(" and inspection_item_selection_datatype_value_id = :datatypeid ;");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);
            sqlParameter.AddParameterInteger("datatypeid", inVo.InspectionItemSelectionDatatypeValueId);
            sqlParameter.AddParameterString("datatypevaluetext", inVo.InspectionItemSelectionDatatypeValueText);
            sqlParameter.AddParameterInteger("displayorder", inVo.DisplayOrder);

            UpdateResultVo outVo = new UpdateResultVo
            {
                AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

            return(outVo);
        }
예제 #5
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            InspectionItemSelectionDatatypeValueVo inVo = (InspectionItemSelectionDatatypeValueVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Select  max(display_order)+1 display_order ");
            sqlQuery.Append(" from m_inspection_item_selection_datatype_value ");
            sqlQuery.Append(" where factory_cd = :factcd");

            sqlQuery.Append(" and inspection_item_id = :inspectionitemid");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterString("factcd", UserData.GetUserData().FactoryCode);

            sqlParameter.AddParameterInteger("inspectionitemid", inVo.InspectionItemId);

            //execute SQL
            IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            InspectionItemSelectionDatatypeValueVo outVo = new InspectionItemSelectionDatatypeValueVo();

            while (dataReader.Read())
            {
                outVo.DisplayOrder = ConvertDBNull <int>(dataReader, "display_order");
            }
            dataReader.Close();

            return(outVo);
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            InspectionItemSelectionDatatypeValueVo inVo = (InspectionItemSelectionDatatypeValueVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            //create SQL
            sqlQuery.Append(" Select dtv.inspection_item_selection_datatype_value_id,  ");
            sqlQuery.Append("       dtv.inspection_item_selection_datatype_value_cd,  ");
            sqlQuery.Append("       dtv.inspection_item_selection_datatype_value_text,  ");
            sqlQuery.Append("       it.inspection_item_id,");
            sqlQuery.Append("       it.inspection_item_cd,");
            sqlQuery.Append("       it.inspection_item_name,");
            sqlQuery.Append("       dtv.display_order");
            sqlQuery.Append(" from m_inspection_item_selection_datatype_value dtv ");
            sqlQuery.Append(" left join m_inspection_item it on  it.inspection_item_id = dtv.inspection_item_id  ");
            sqlQuery.Append(" where dtv.factory_cd = :factcd");
            sqlQuery.Append(" and dtv.inspection_item_id = :inspectionitemid ");

            sqlQuery.Append(" order by dtv.display_order,dtv.inspection_item_selection_datatype_value_cd");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterInteger("inspectionitemid", inVo.InspectionItemId);
            sqlParameter.AddParameterString("factcd", UserData.GetUserData().FactoryCode);

            //execute SQL
            IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            ValueObjectList <InspectionItemSelectionDatatypeValueVo> outVo = null;

            while (dataReader.Read())
            {
                InspectionItemSelectionDatatypeValueVo currOutVo = new InspectionItemSelectionDatatypeValueVo();

                currOutVo.InspectionItemSelectionDatatypeValueId   = ConvertDBNull <int>(dataReader, "inspection_item_selection_datatype_value_id");
                currOutVo.InspectionItemSelectionDatatypeValueCode = ConvertDBNull <string>(dataReader, "inspection_item_selection_datatype_value_cd");
                currOutVo.InspectionItemSelectionDatatypeValueText = ConvertDBNull <string>(dataReader, "inspection_item_selection_datatype_value_text");
                currOutVo.DisplayOrder       = ConvertDBNull <int>(dataReader, "display_order");
                currOutVo.InspectionItemId   = ConvertDBNull <int>(dataReader, "inspection_item_id");
                currOutVo.InspectionItemCode = ConvertDBNull <string>(dataReader, "inspection_item_cd");
                currOutVo.InspectionItemName = ConvertDBNull <string>(dataReader, "inspection_item_name");


                if (outVo == null)
                {
                    outVo = new ValueObjectList <InspectionItemSelectionDatatypeValueVo>();
                }
                outVo.add(currOutVo);
            }

            dataReader.Close();

            return(outVo);
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            InspectionItemSelectionDatatypeValueVo inVo = (InspectionItemSelectionDatatypeValueVo)arg;

            StringBuilder sql = new StringBuilder();

            //create SQL
            sql.Append("Select Count(*) as InspectionItemSelectionDataTypeCount from m_inspection_item_selection_datatype_value");
            sql.Append(" where factory_cd = :faccd ");

            if (inVo.InspectionItemSelectionDatatypeValueText != null)
            {
                sql.Append(" and UPPER(inspection_item_selection_datatype_value_text) = UPPER(:datatypevaluetext)");
            }

            if (inVo.InspectionItemId > 0)
            {
                sql.Append(" and inspection_item_id = :inspectionitemid ;");
            }
            else
            {
                sql.Append(" and inspection_item_id = 0 ;");
            }

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);

            if (inVo.InspectionItemSelectionDatatypeValueText != null)
            {
                sqlParameter.AddParameterString("datatypevaluetext", inVo.InspectionItemSelectionDatatypeValueText);
            }

            if (inVo.InspectionItemId > 0)
            {
                sqlParameter.AddParameterInteger("inspectionitemid", inVo.InspectionItemId);
            }

            //execute SQL
            IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            InspectionItemSelectionDatatypeValueVo outVo = new InspectionItemSelectionDatatypeValueVo();

            while (dataReader.Read())
            {
                outVo.AffectedCount = Convert.ToInt32(dataReader["InspectionItemSelectionDataTypeCount"]);
            }

            dataReader.Close();

            return(outVo);
        }
예제 #8
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            ValueObjectList <ValueObjectList <ValueObject> > inVo = (ValueObjectList <ValueObjectList <ValueObject> >)arg;
            List <int> ItemList = new List <int>();

            foreach (ValueObjectList <ValueObject> getItemVo in inVo.GetList())
            {
                if ((((InspectionItemVo)getItemVo.GetList()[0]).InspectionItemId) != 0)
                {
                    ItemList.Add(((InspectionItemVo)getItemVo.GetList()[0]).InspectionItemId);
                }
            }

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("select * ");
            sqlQuery.Append(" from m_inspection_item_selection_datatype_value");
            sqlQuery.Append(" where factory_cd = :faccd ");
            sqlQuery.Append(" and inspection_item_id = ANY (:inspectionItemId) ");

            sqlQuery.Append(" order by inspection_item_selection_datatype_value_id ");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);
            sqlParameter.AddParameter("inspectionItemId", ItemList);

            //execute SQL
            IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            ValueObjectList <InspectionItemSelectionDatatypeValueVo> outVo = null;

            while (dataReader.Read())
            {
                InspectionItemSelectionDatatypeValueVo currOutVo = new InspectionItemSelectionDatatypeValueVo();

                currOutVo.InspectionItemSelectionDatatypeValueId   = ConvertDBNull <int>(dataReader, "inspection_item_selection_datatype_value_id");
                currOutVo.InspectionItemSelectionDatatypeValueCode = ConvertDBNull <string>(dataReader, "inspection_item_selection_datatype_value_cd");
                currOutVo.InspectionItemSelectionDatatypeValueText = ConvertDBNull <string>(dataReader, "inspection_item_selection_datatype_value_text");
                currOutVo.DisplayOrder     = ConvertDBNull <int>(dataReader, "display_order");
                currOutVo.InspectionItemId = ConvertDBNull <int>(dataReader, "inspection_item_id");

                if (outVo == null)
                {
                    outVo = new ValueObjectList <InspectionItemSelectionDatatypeValueVo>();
                }
                outVo.add(currOutVo);
            }
            dataReader.Close();

            return(outVo);
        }
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="pmode"></param>
        /// <param name="userItem"></param>
        public AddInspectionSelectionDatetypeValueForItemForm(string pmode, InspectionItemSelectionDatatypeValueVo userItem = null)
        {
            InitializeComponent();

            mode       = pmode;
            updateData = userItem;
            if (string.Equals(mode, CommonConstants.MODE_UPDATE))
            {
                this.Text = UpdateText_lbl.Text;
            }
        }
        /// <summary>
        /// Fills all user records to gridview control
        /// </summary>
        private void GridBind()
        {
            Update_btn.Enabled = false;

            Delete_btn.Enabled = false;

            InspectionSelectionValue_dgv.DataSource = null;


            InspectionItemSelectionDatatypeValueVo conditionInVo = new InspectionItemSelectionDatatypeValueVo();

            if (inspectionItemdata == null || inspectionItemdata.InspectionItemId == 0)
            {
                conditionInVo.InspectionItemId = 0;
            }
            else
            {
                conditionInVo.InspectionItemId = inspectionItemdata.InspectionItemId;
            }


            ValueObjectList <InspectionItemSelectionDatatypeValueVo> outVo = null;

            try
            {
                outVo = (ValueObjectList <InspectionItemSelectionDatatypeValueVo>)base.InvokeCbm(new GetInspectionItemSelectionDatatypeValueCbm(), conditionInVo, false);
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }

            if (outVo == null || outVo.GetList() == null || outVo.GetList().Count == 0)
            {
                return;
            }
            InspectionSelectionValue_dgv.AutoGenerateColumns = false;

            BindingSource bindingSource1 = new BindingSource(outVo.GetList(), null);

            if (bindingSource1 != null && bindingSource1.Count > 0)
            {
                InspectionSelectionValue_dgv.DataSource = bindingSource1;
            }
            else
            {
                messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);
            }
            InspectionSelectionValue_dgv.ClearSelection();
        }
        public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InspectionItemVo inVo = (InspectionItemVo)vo;

            ValueObjectList <ValueObjectList <ValueObject> > outVo = null;

            //if process data not found return the vo
            if (inVo == null || inVo.InspectionItemIdCopy == 0)
            {
                return(outVo);
            }

            InspectionItemVo returnItemVo = null;

            returnItemVo = (InspectionItemVo)addInspectionItemMasterMntCbm.Execute(trxContext, inVo);

            //To get the old record for InspectionItem Insertion
            inVo.InspectionItemId = inVo.InspectionItemIdCopy;

            //No records Added
            if (returnItemVo == null || returnItemVo.InspectionItemId == 0)
            {
                return(outVo);
            }

            returnItemVo.InspectionItemCode = inVo.InspectionItemCode;

            if (inVo.InspectionItemDataType.ToString() == GlobalMasterDataTypeEnum.DATATYPE_SELECTION.GetValue().ToString())
            {
                //To insert selection value.
                InspectionItemSelectionDatatypeValueVo inspectionItemSelectionDatatypeValueVo = new InspectionItemSelectionDatatypeValueVo();
                inspectionItemSelectionDatatypeValueVo.InspectionItemCode = inVo.InspectionItemCode;
                inspectionItemSelectionDatatypeValueVo.InspectionItemId   = returnItemVo.InspectionItemId;

                UpdateResultVo updateResultVo = (UpdateResultVo)updateInspectionItemIdForSelectionValueCbm.Execute(trxContext, inspectionItemSelectionDatatypeValueVo);
            }

            ValueObjectList <ValueObject> CombinationVo = new ValueObjectList <ValueObject>();

            CombinationVo.add(inVo);
            CombinationVo.add(returnItemVo);

            if (outVo == null)
            {
                outVo = new ValueObjectList <ValueObjectList <ValueObject> >();
            }
            outVo.add(CombinationVo);
            return(outVo);
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            InspectionItemSelectionDatatypeValueVo inVo = (InspectionItemSelectionDatatypeValueVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Insert into m_inspection_item_selection_datatype_value");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" inspection_item_selection_datatype_value_cd, ");
            sqlQuery.Append(" inspection_item_selection_datatype_value_text, ");
            sqlQuery.Append(" display_order,");
            sqlQuery.Append(" inspection_item_id, ");
            sqlQuery.Append(" registration_user_cd, ");
            sqlQuery.Append(" registration_date_time, ");
            sqlQuery.Append(" factory_cd ");
            sqlQuery.Append(" ) ");
            sqlQuery.Append("VALUES	");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" :datatypevaluecd ,");
            sqlQuery.Append(" :datatypevaluetext ,");
            sqlQuery.Append(" :displayorder,");
            sqlQuery.Append(" :itemid,");
            sqlQuery.Append(" :registrationusercode ,");
            sqlQuery.Append(" :registrationdatetime, ");
            sqlQuery.Append(" :factorycode ");
            sqlQuery.Append(" ); ");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterString("datatypevaluecd", inVo.InspectionItemSelectionDatatypeValueCode);
            sqlParameter.AddParameterString("datatypevaluetext", inVo.InspectionItemSelectionDatatypeValueText);
            sqlParameter.AddParameterInteger("displayorder", inVo.DisplayOrder);
            sqlParameter.AddParameterInteger("itemid", inVo.InspectionItemId);
            sqlParameter.AddParameterString("registrationusercode", UserData.GetUserData().UserCode);
            sqlParameter.AddParameterDateTime("registrationdatetime", trxContext.ProcessingDBDateTime);
            sqlParameter.AddParameterString("factorycode", UserData.GetUserData().FactoryCode);

            UpdateResultVo outVo = new UpdateResultVo
            {
                AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

            return(outVo);
        }
        /// <summary>
        /// checks duplicate Display Record
        /// </summary>
        /// <param name="defectVo"></param>
        /// <returns></returns>
        private InspectionItemSelectionDatatypeValueVo DuplicateDisplayCheck(InspectionItemSelectionDatatypeValueVo defectVo)
        {
            InspectionItemSelectionDatatypeValueVo outVo = new InspectionItemSelectionDatatypeValueVo();

            try
            {
                outVo = (InspectionItemSelectionDatatypeValueVo)base.InvokeCbm(new CheckInspectionItemSelectionDatatypeValueDisplayOrderCbm(), defectVo, false);
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }

            return(outVo);
        }
        /// <summary>
        /// form load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddInspectionSelectionDatetypeValueForItemForm_Load(object sender, EventArgs e)
        {
            if (string.Equals(mode, CommonConstants.MODE_ADD))
            {
                InspectionItemSelectionDatatypeValueVo inVo = new InspectionItemSelectionDatatypeValueVo();

                if (updateData != null)
                {
                    inVo.InspectionItemId = updateData.InspectionItemId;
                }

                InspectionItemSelectionDatatypeValueVo outVo = (InspectionItemSelectionDatatypeValueVo)base.InvokeCbm(new GetInspItemSelectionDatatypeValueDisplayOrderNextValCbm(), inVo, false);
                if (outVo != null && outVo.DisplayOrder > 0)
                {
                    InspectionItemDisplayOrder_txt.Text = outVo.DisplayOrder.ToString();
                }
                else
                {
                    InspectionItemDisplayOrder_txt.Text = "1";
                }

                checkRunningCount(inVo);
            }

            SelectionDatatypeValueText_txt.Select();

            if (mode == CommonConstants.MODE_ADD)
            {
                return;
            }
            this.InspectionItem_cmb.Text = updateData.InspectionItemName;

            this.SelectionDatatypeValueText_txt.Text = updateData.InspectionItemSelectionDatatypeValueText;

            this.InspectionItemDisplayOrder_txt.Text = updateData.DisplayOrder.ToString();

            this.InspectionItem_cmb.Text = updateData.InspectionItemName;
        }
        /// <summary>
        /// passing update data to update form
        /// </summary>
        private void BindUpdateInspectionTestInstructionDetailData()
        {
            int selectedrowindex = InspectionSelectionValue_dgv.SelectedCells[0].RowIndex;

            InspectionItemSelectionDatatypeValueVo inspTestInstructionVo = (InspectionItemSelectionDatatypeValueVo)InspectionSelectionValue_dgv.Rows[selectedrowindex].DataBoundItem;

            AddInspectionSelectionDatetypeValueForItemForm newAddForm = new AddInspectionSelectionDatetypeValueForItemForm(CommonConstants.MODE_UPDATE, inspTestInstructionVo);

            newAddForm.ShowDialog(this);
            UpdateInspectionItemSelectionDatatypeValueVo = new InspectionItemSelectionDatatypeValueVo();
            UpdateInspectionItemSelectionDatatypeValueVo = newAddForm.UpdateInspectionItemSelectionDatatypeValueVo;

            if (newAddForm.IntSuccess > 0)
            {
                messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);

                if (newAddForm.InspectionItemId > 0)
                {
                    inspectionItemdata.InspectionItemId = newAddForm.InspectionItemId;
                    InspectionItemId    = newAddForm.InspectionItemId;
                    InspectionProcessId = newAddForm.InspectionProcessId;
                }
            }
            else if (newAddForm.IntSuccess == 0)
            {
                messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);
            }
            GridBind();

            InspectionSelectionValue_dgv.Rows[selectedrowindex].Selected = true;
            InspectionTestInstructionDetail_dgv_CellClick(this, new DataGridViewCellEventArgs(0, selectedrowindex));
            InspectionSelectionValue_dgv.FirstDisplayedScrollingRowIndex = selectedrowindex;
        }
        public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InspectionFormatVo            inVo     = new InspectionFormatVo();
            ValueObjectList <ValueObject> inListVo = (ValueObjectList <ValueObject>)vo;
            InspectionReturnVo            outVo    = null;

            if (inListVo == null && inListVo.GetList() == null && inListVo.GetList().Count == 0)
            {
                return(null);
            }

            InspectionFormatVo  updateFormatVo  = (InspectionFormatVo)inListVo.GetList()[0];
            InspectionProcessVo updateprocessVo = (InspectionProcessVo)inListVo.GetList()[1];
            InspectionItemVo    updateitemVo    = (InspectionItemVo)inListVo.GetList()[2];
            InspectionItemSelectionDatatypeValueVo updateSelectionDataTypeValueVo = (InspectionItemSelectionDatatypeValueVo)inListVo.GetList()[3];
            InspectionSpecificationVo   updateSpecificationVo         = (InspectionSpecificationVo)inListVo.GetList()[4];
            InspectionTestInstructionVo updateTestInstructionVo       = (InspectionTestInstructionVo)inListVo.GetList()[5];
            InspectionTestInstructionVo updateTestInstructionDetailVo = (InspectionTestInstructionVo)inListVo.GetList()[6];

            if (!(updateprocessVo != null && updateprocessVo.InspectionProcessIdCopy > 0 && updateitemVo != null && updateitemVo.InspectionItemIdCopy > 0))
            {
                InspectionFormatVo inspFormatVo = new InspectionFormatVo();
                inspFormatVo.InspectionFormatId   = updateFormatVo.InspectionFormatIdCopy;
                inspFormatVo.InspectionFormatCode = updateFormatVo.InspectionFormatCode;
                inspFormatVo.InspectionFormatName = updateFormatVo.InspectionFormatName;

                UpdateResultVo updateResultVo = (UpdateResultVo)checkInspectionFormatExitInTransactionCbm.Execute(trxContext, inspFormatVo);
                if (updateResultVo.AffectedCount == 0)
                {
                    outVo = new InspectionReturnVo();

                    if (updateFormatVo.Mode == CommonConstants.MODE_UPDATE)
                    {
                        //update inspectionformat
                        InspectionFormatVo inspectionFormatVo = (InspectionFormatVo)updateInspectionFormatMasterMntCbm.Execute(trxContext, inspFormatVo);

                        outVo.AffectedCount      = inspectionFormatVo.AffectedCount;
                        outVo.InspectionFormatId = inspFormatVo.InspectionFormatId;
                        return(outVo);
                    }

                    if (updateprocessVo != null)
                    {
                        InspectionProcessVo inspectionProcessVo = new InspectionProcessVo();

                        if (updateprocessVo.DeleteFlag)
                        {
                            //delete inspectionprocess
                            return((InspectionReturnVo)deleteAllInspectionFunctionMasterMntCbm.Execute(trxContext, vo));
                        }
                        else
                        {
                            //update inspectionprocess
                            inspectionProcessVo = (InspectionProcessVo)updateInspectionProcessMasterMntCbm.Execute(trxContext, updateprocessVo);
                        }

                        outVo.AffectedCount       = inspectionProcessVo.AffectedCount;
                        outVo.InspectionProcessId = updateprocessVo.InspectionProcessId;
                        outVo.InspectionFormatId  = inspFormatVo.InspectionFormatId;
                        return(outVo);
                    }
                    if (updateSelectionDataTypeValueVo != null)
                    {
                        if (updateSelectionDataTypeValueVo.DeleteFlag)
                        {
                            //delete inspectionitemselectionvalue
                            return((InspectionReturnVo)deleteAllInspectionFunctionMasterMntCbm.Execute(trxContext, vo));
                        }
                        else
                        {
                            //update inspectionitemselectionvalue
                            UpdateResultVo inspectionItemSelectionDatatypeValueVo = (UpdateResultVo)updateInspectionItemSelectionDatatypeValueCbm.Execute(trxContext, updateSelectionDataTypeValueVo);

                            outVo.AffectedCount    = inspectionItemSelectionDatatypeValueVo.AffectedCount;
                            outVo.InspectionItemId = updateSelectionDataTypeValueVo.InspectionItemId;
                            return(outVo);
                        }
                    }
                    if (updateitemVo != null)
                    {
                        InspectionItemVo inspectionItemVo = new InspectionItemVo();

                        if (updateitemVo.DeleteFlag)
                        {
                            //delete inspectionitem
                            return((InspectionReturnVo)deleteAllInspectionFunctionMasterMntCbm.Execute(trxContext, vo));
                        }
                        else
                        {
                            //update inspectionitem
                            inspectionItemVo = (InspectionItemVo)updateInspectionItemMasterMntCbm.Execute(trxContext, updateitemVo);
                        }

                        outVo.AffectedCount       = inspectionItemVo.AffectedCount;
                        outVo.InspectionItemId    = updateitemVo.InspectionItemId;
                        outVo.InspectionProcessId = updateitemVo.InspectionProcessId;
                        return(outVo);
                    }
                    if (updateSpecificationVo != null)
                    {
                        InspectionSpecificationVo inspectionSpecificationVo = new InspectionSpecificationVo();

                        if (updateSpecificationVo.DeleteFlag)
                        {
                            //delete inspectionspecification
                            return((InspectionReturnVo)deleteAllInspectionFunctionMasterMntCbm.Execute(trxContext, vo));
                        }
                        else
                        {
                            //update inspectionspecification
                            inspectionSpecificationVo = (InspectionSpecificationVo)updateInspectionSpecificationMasterMntCbm.Execute(trxContext, updateSpecificationVo);
                        }

                        outVo.AffectedCount    = inspectionSpecificationVo.AffectedCount;
                        outVo.InspectionItemId = updateSpecificationVo.InspectionItemId;
                        return(outVo);
                    }
                    if (updateTestInstructionVo != null)
                    {
                        InspectionTestInstructionVo inspectionTestInstructionVo = new InspectionTestInstructionVo();

                        if (updateTestInstructionVo.DeleteFlag)
                        {
                            //delete inspectiontestinstruction
                            return((InspectionReturnVo)deleteAllInspectionFunctionMasterMntCbm.Execute(trxContext, vo));
                        }
                        else
                        {
                            //update inspectiontestinstruction
                            inspectionTestInstructionVo = (InspectionTestInstructionVo)updateInspectionTestInstructionMasterMntCbm.Execute(trxContext, updateTestInstructionVo);
                        }

                        outVo.AffectedCount               = inspectionTestInstructionVo.AffectedCount;
                        outVo.InspectionItemId            = updateTestInstructionVo.InspectionItemId;
                        outVo.InspectionTestInstructionId = updateTestInstructionVo.InspectionTestInstructionId;
                        return(outVo);
                    }
                    if (updateTestInstructionDetailVo != null)
                    {
                        InspectionTestInstructionVo inspectionTestInstructionDetailVo = new InspectionTestInstructionVo();

                        if (updateTestInstructionDetailVo.DeleteFlag)
                        {
                            //delete inspectiontestinstructiondetail
                            return((InspectionReturnVo)deleteAllInspectionFunctionMasterMntCbm.Execute(trxContext, vo));
                        }
                        else
                        {
                            //update inspectiontestinstructiondetail
                            inspectionTestInstructionDetailVo = (InspectionTestInstructionVo)updateInspectionTestInstructionDetailMasterMntCbm.Execute(trxContext, updateTestInstructionDetailVo);
                        }

                        outVo.AffectedCount = inspectionTestInstructionDetailVo.AffectedCount;
                        outVo.InspectionTestInstructionId = updateTestInstructionDetailVo.InspectionTestInstructionId;
                        return(outVo);
                    }
                }
            }

            inVo = (InspectionFormatVo)inListVo.GetList()[0];
            inVo.InspectionFormatId = inVo.InspectionFormatIdCopy;

            updateInspectionFormatDeleteFlagMasterMntCbm.Execute(trxContext, inVo);
            return(copyInspectionFormatMasterMntCbm.Execute(trxContext, vo));
        }
예제 #17
0
        /// <summary>
        /// update data to db
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Ok_btn_Click(object sender, EventArgs e)
        {
            var sch = StringCheckHelper.GetInstance();

            InspectionItemVo inVo = new InspectionItemVo();

            if (CheckMandatory())
            {
                inVo.InspectionItemName = InspectionItemName_txt.Text.Trim();

                if (ParentItemCode_cmb.SelectedIndex > -1)
                {
                    inVo.ParentInspectionItemId = Convert.ToInt32(ParentItemCode_cmb.SelectedValue.ToString());
                }
                //if (InspectionProcess_cmb.SelectedIndex > -1)
                //{
                //    inVo.InspectionProcessId = Convert.ToInt32(InspectionProcess_cmb.SelectedValue);
                //}

                inVo.InspectionProcessId = updateData.InspectionProcessId;

                inVo.InspectionItemMandatory = Convert.ToInt32(InspectionItemMandatory_chk.Checked);

                inVo.InspectionEmployeeMandatory = Convert.ToInt32(InspectionEmployeeMandatory_chk.Checked);

                inVo.InspectionMachineMandatory = Convert.ToInt32(InspectionMachineMandatory_chk.Checked);

                inVo.InspectionItemDataType = Convert.ToInt32(InspectionItemDataType_cmb.SelectedValue);

                inVo.DisplayOrder = Convert.ToInt32(InspectionItemDisplayOrder_txt.Text);

                if (!string.IsNullOrEmpty(ResultItemDecimalDigits_txt.Text))
                {
                    inVo.InspectionResultItemDecimalDigits = Convert.ToInt32(ResultItemDecimalDigits_txt.Text);
                }

                if (string.Equals(mode, CommonConstants.MODE_ADD))
                {
                    InspectionItemVo checkVo = DuplicateCheck(inVo);
                    if (checkVo != null && checkVo.AffectedCount > 0)
                    {
                        messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, InspectionItemName_lbl.Text + " : " + InspectionItemName_txt.Text);
                        popUpMessage.Information(messageData, Text);

                        return;
                    }

                    InspectionItemVo checkDisplayVo = DuplicateDisplayCheck(inVo);
                    if (checkDisplayVo != null && checkDisplayVo.AffectedCount > 0)
                    {
                        messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, InspectionItemDisplayOrder_lbl.Text + " : " + InspectionItemDisplayOrder_txt.Text);
                        logger.Info(messageData);
                        popUpMessage.Information(messageData, Text);
                        InspectionItemDisplayOrder_txt.Focus();
                        return;
                    }
                }
                else if (string.Equals(mode, CommonConstants.MODE_UPDATE))
                {
                    if (updateData.InspectionItemName != InspectionItemName_txt.Text)
                    {
                        InspectionItemVo checkVo = DuplicateCheck(inVo);
                        if (checkVo != null && checkVo.AffectedCount > 0)
                        {
                            messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, InspectionItemName_lbl.Text + " : " + InspectionItemName_txt.Text);
                            popUpMessage.Information(messageData, Text);

                            return;
                        }
                    }

                    if (updateData.DisplayOrder != Convert.ToInt32(InspectionItemDisplayOrder_txt.Text))
                    {
                        InspectionItemVo checkDisplayVo = DuplicateDisplayCheck(inVo);
                        if (checkDisplayVo != null && checkDisplayVo.AffectedCount > 0)
                        {
                            messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, InspectionItemDisplayOrder_lbl.Text + " : " + InspectionItemDisplayOrder_txt.Text);
                            logger.Info(messageData);
                            popUpMessage.Information(messageData, Text);
                            InspectionItemDisplayOrder_txt.Focus();
                            return;
                        }
                    }
                }
                if (string.Equals(mode, CommonConstants.MODE_ADD))
                {
                    inVo.InspectionItemCode = InspectionItemCode;

                    if (InspectionItemCopyId == 0)
                    {
                        InspectionItemVo outVo = null;
                        try
                        {
                            outVo = (InspectionItemVo)base.InvokeCbm(new AddInspectionItemMasterMntCbm(), inVo, false);
                        }
                        catch (Framework.ApplicationException exception)
                        {
                            popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                            logger.Error(exception.GetMessageData());
                            return;
                        }
                        if (outVo == null && outVo.InspectionItemId == 0)
                        {
                            return;
                        }

                        IntSuccess = outVo.InspectionItemId;

                        //
                        if (InspectionItemDataType_cmb.SelectedIndex > -1 &&
                            InspectionItemDataType_cmb.SelectedValue.ToString() == GlobalMasterDataTypeEnum.DATATYPE_SELECTION.GetValue().ToString())
                        {
                            InspectionItemSelectionDatatypeValueVo inspectionItemSelectionDatatypeValueVo = new InspectionItemSelectionDatatypeValueVo();
                            inspectionItemSelectionDatatypeValueVo.InspectionItemCode = InspectionItemCode;
                            inspectionItemSelectionDatatypeValueVo.InspectionItemId   = outVo.InspectionItemId;
                            try
                            {
                                UpdateResultVo updateResultVo = (UpdateResultVo)base.InvokeCbm(new UpdateInspectionItemIdForSelectionValueCbm(), inspectionItemSelectionDatatypeValueVo, false);
                            }
                            catch (Framework.ApplicationException exception)
                            {
                                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                                logger.Error(exception.GetMessageData());
                                return;
                            }
                        }
                    }
                    else
                    {
                        inVo.InspectionItemIdCopy = InspectionItemCopyId;
                        //InspectionFormatVo getformatvo = inspectionFormatOutVo.GetList().Where(t => t.InspectionFormatId == inVo.InspectionFormatId).FirstOrDefault();
                        //if (getformatvo == null) return;

                        if (!CheckDataExist(InspectionItemCopyId))
                        {
                            messageData = new MessageData("mmci00048", Properties.Resources.mmci00048.ToString(), CopyItem_txt.Text);
                            logger.Info(messageData);
                            DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text);
                            if (dialogResult != DialogResult.OK)
                            {
                                return;
                            }
                        }

                        string message = string.Format(Properties.Resources.mmci00045, CopyItem_txt.Text);
                        base.StartProgress(message);

                        inVo.InspectionProcessCode = updateData.InspectionProcessCode; // getformatvo.InspectionFormatCode;
                        //inVo.SequenceNo = RunningNumber;

                        ValueObjectList <ValueObject> inVoList = new ValueObjectList <ValueObject>();
                        inVoList.add(null);
                        inVoList.add(null);
                        inVoList.add(inVo);
                        inVoList.add(null);
                        inVoList.add(null);
                        inVoList.add(null);
                        inVoList.add(null);
                        InspectionReturnVo OutVo = null;
                        try
                        {
                            OutVo = (InspectionReturnVo)base.InvokeCbm(new CopyInspectionItemFromItemAllCbm(), inVoList, false);
                        }
                        catch (Framework.ApplicationException exception)
                        {
                            popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                            logger.Error(exception.GetMessageData());
                            return;
                        }
                        finally
                        {
                            CompleteProgress();
                        }
                        if (OutVo != null && OutVo.AffectedCount > 0)
                        {
                            IntSuccess      = OutVo.InspectionItemId;
                            ReturnProcessId = OutVo.InspectionProcessId;
                            is_Copied       = true;
                        }
                    }
                }
                else if (string.Equals(mode, CommonConstants.MODE_UPDATE))
                {
                    inVo.InspectionItemId = updateData.InspectionItemId;

                    string message = string.Format(Properties.Resources.mmci00037, "Inspection Item", InspectionItemName_txt.Text);
                    StartProgress(message);

                    ValueObjectList <ValueObject> inVoList     = new ValueObjectList <ValueObject>();
                    InspectionFormatVo            passformatVo = FormFormatVo(updateData.InspectionItemId);
                    if (passformatVo == null || passformatVo.InspectionFormatId == 0)
                    {
                        return;
                    }

                    inVoList.add(passformatVo);
                    inVoList.add(null);
                    inVoList.add(inVo);
                    inVoList.add(null);
                    inVoList.add(null);
                    inVoList.add(null);
                    inVoList.add(null);

                    InspectionReturnVo outVo = null;

                    try
                    {
                        outVo = (InspectionReturnVo)base.InvokeCbm(new UpdateAllInspectionFunctionMasterMntCbm(), inVoList, false);
                    }
                    catch (Framework.ApplicationException exception)
                    {
                        popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                        logger.Error(exception.GetMessageData());
                        return;
                    }
                    finally
                    {
                        CompleteProgress();
                    }
                    if (outVo != null && outVo.AffectedCount > 0)
                    {
                        IntSuccess      = outVo.InspectionItemId;
                        ReturnProcessId = outVo.InspectionProcessId;
                    }

                    //InspectionItemVo outVo = (InspectionItemVo)base.InvokeCbm(new UpdateInspectionItemMasterMntCbm(), inVo, false);
                }

                if (IntSuccess > 0)
                {
                    this.Close();
                }
            }
        }
        public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InspectionFormatVo            inVo     = new InspectionFormatVo();
            ValueObjectList <ValueObject> inListVo = (ValueObjectList <ValueObject>)vo;
            InspectionReturnVo            outVo    = null;

            if (inListVo == null && inListVo.GetList() == null && inListVo.GetList().Count == 0)
            {
                return(null);
            }

            InspectionFormatVo  updateFormatVo  = (InspectionFormatVo)inListVo.GetList()[0];
            InspectionProcessVo updateprocessVo = (InspectionProcessVo)inListVo.GetList()[1];
            InspectionItemVo    updateitemVo    = (InspectionItemVo)inListVo.GetList()[2];
            InspectionItemSelectionDatatypeValueVo updateSelectionDataTypeValueVo = (InspectionItemSelectionDatatypeValueVo)inListVo.GetList()[3];
            InspectionSpecificationVo   updateSpecificationVo         = (InspectionSpecificationVo)inListVo.GetList()[4];
            InspectionTestInstructionVo updateTestInstructionVo       = (InspectionTestInstructionVo)inListVo.GetList()[5];
            InspectionTestInstructionVo updateTestInstructionDetailVo = (InspectionTestInstructionVo)inListVo.GetList()[6];

            outVo = new InspectionReturnVo();

            if (updateprocessVo != null && updateprocessVo.DeleteFlag)
            {
                InspectionProcessVo inspectionProcessVo = new InspectionProcessVo();
                //delete inspectionprocess
                inspectionProcessVo = (InspectionProcessVo)deleteInspectionProcessMasterMntCbm.Execute(trxContext, updateprocessVo);

                InspectionItemVo InItemVo = new InspectionItemVo();
                InItemVo.InspectionProcessId = updateprocessVo.InspectionProcessId;

                //get inspection item id
                ValueObjectList <InspectionItemVo> InspectionItemVo = (ValueObjectList <InspectionItemVo>)getInspectionItemMasterCbm.Execute(trxContext, InItemVo);

                if (InspectionItemVo == null || InspectionItemVo.GetList() == null || InspectionItemVo.GetList().Count == 0)
                {
                    outVo.AffectedCount      = inspectionProcessVo.AffectedCount;
                    outVo.InspectionFormatId = updateFormatVo.InspectionFormatIdCopy;
                    return(outVo);
                }

                foreach (InspectionItemVo getitemVo in InspectionItemVo.GetList())
                {
                    InspectionItemSelectionDatatypeValueVo deleteInspectionItemSelectionDatatypeValueVo = new InspectionItemSelectionDatatypeValueVo();
                    deleteInspectionItemSelectionDatatypeValueVo.InspectionItemId = getitemVo.InspectionItemId;

                    //delete inspectionitemselectionvalue
                    UpdateResultVo inspectionItemSelectionDatatypeValueVo = (UpdateResultVo)deleteInspectionItemSelectionDatatypeValueCbm.Execute(trxContext, deleteInspectionItemSelectionDatatypeValueVo);

                    InspectionSpecificationVo deleteSpecInVo = new InspectionSpecificationVo();
                    deleteSpecInVo.InspectionItemId = getitemVo.InspectionItemId;

                    //delete inspectionspecification
                    InspectionSpecificationVo inspectionSpecificationVo = (InspectionSpecificationVo)deleteInspectionSpecificationMasterMntCbm.Execute(trxContext, deleteSpecInVo);

                    InspectionTestInstructionVo inTestVo = new InspectionTestInstructionVo();
                    inTestVo.InspectionItemId = getitemVo.InspectionItemId;

                    //get inspectiontestinstruction id
                    ValueObjectList <InspectionTestInstructionVo> inspectionTestInstructionVo = (ValueObjectList <InspectionTestInstructionVo>)getInspectionTestInstructionMasterMntCbm.Execute(trxContext, inTestVo);
                    if (inspectionTestInstructionVo != null && inspectionTestInstructionVo.GetList() != null && inspectionTestInstructionVo.GetList().Count > 0)
                    {
                        //delete inspectiontestinstruction
                        InspectionTestInstructionVo deleteInspectionTestInstructionVo = (InspectionTestInstructionVo)deleteInspectionTestInstructionMasterMntNewCbm.Execute(trxContext, inspectionTestInstructionVo.GetList()[0]);
                    }

                    //delete inspectionitem
                    InspectionItemVo deleteinspectionItemVo = (InspectionItemVo)deleteInspectionItemMasterMntCbm.Execute(trxContext, getitemVo);
                }

                outVo.AffectedCount      = inspectionProcessVo.AffectedCount;
                outVo.InspectionFormatId = updateFormatVo.InspectionFormatIdCopy;
                return(outVo);
            }
            else if (updateitemVo != null && updateitemVo.DeleteFlag)
            {
                InspectionItemSelectionDatatypeValueVo deleteInspectionItemSelectionDatatypeValueVo = new InspectionItemSelectionDatatypeValueVo();
                deleteInspectionItemSelectionDatatypeValueVo.InspectionItemId = updateitemVo.InspectionItemId;

                //delete inspectionitemselectionvalue
                UpdateResultVo inspectionItemSelectionDatatypeValueVo = (UpdateResultVo)deleteInspectionItemSelectionDatatypeValueCbm.Execute(trxContext, deleteInspectionItemSelectionDatatypeValueVo);

                InspectionSpecificationVo deleteSpecInVo = new InspectionSpecificationVo();
                deleteSpecInVo.InspectionItemId = updateitemVo.InspectionItemId;

                //delete inspectionspecification
                InspectionSpecificationVo inspectionSpecificationVo = (InspectionSpecificationVo)deleteInspectionSpecificationMasterMntCbm.Execute(trxContext, deleteSpecInVo);

                InspectionTestInstructionVo inTestVo = new InspectionTestInstructionVo();
                inTestVo.InspectionItemId = updateitemVo.InspectionItemId;

                //get inspectiontestinstruction id
                ValueObjectList <InspectionTestInstructionVo> inspectionTestInstructionVo = (ValueObjectList <InspectionTestInstructionVo>)getInspectionTestInstructionMasterMntCbm.Execute(trxContext, inTestVo);
                if (inspectionTestInstructionVo != null && inspectionTestInstructionVo.GetList() != null && inspectionTestInstructionVo.GetList().Count > 0)
                {
                    //delete inspectiontestinstruction
                    InspectionTestInstructionVo deleteInspectionTestInstructionVo = (InspectionTestInstructionVo)deleteInspectionTestInstructionMasterMntNewCbm.Execute(trxContext, inspectionTestInstructionVo.GetList()[0]);
                }

                //delete inspectionitem
                InspectionItemVo deleteinspectionItemVo = (InspectionItemVo)deleteInspectionItemMasterMntCbm.Execute(trxContext, updateitemVo);

                outVo.AffectedCount       = deleteinspectionItemVo.AffectedCount;
                outVo.InspectionProcessId = updateitemVo.InspectionProcessId;
                return(outVo);
            }
            else if (updateSelectionDataTypeValueVo != null && updateSelectionDataTypeValueVo.DeleteFlag)
            {
                //delete inspectionitemselectionvalue
                UpdateResultVo inspectionItemSelectionDatatypeValueVo = (UpdateResultVo)deleteInspectionItemSelectionDatatypeValueCbm.Execute(trxContext, updateSelectionDataTypeValueVo);

                outVo.AffectedCount    = inspectionItemSelectionDatatypeValueVo.AffectedCount;
                outVo.InspectionItemId = updateSelectionDataTypeValueVo.InspectionItemId;
                return(outVo);
            }
            else if (updateSpecificationVo != null && updateSpecificationVo.DeleteFlag)
            {
                //delete inspectionspecification
                InspectionSpecificationVo deleteinspectionSpecificationVo = (InspectionSpecificationVo)deleteInspectionSpecificationMasterMntCbm.Execute(trxContext, updateSpecificationVo);


                outVo.AffectedCount    = deleteinspectionSpecificationVo.AffectedCount;
                outVo.InspectionItemId = updateSpecificationVo.InspectionItemId;
                return(outVo);
            }
            else if (updateTestInstructionVo != null && updateTestInstructionVo.DeleteFlag)
            {
                //delete inspectiontestinstruction
                InspectionTestInstructionVo deleteinspectionTestInstructionVo = (InspectionTestInstructionVo)deleteInspectionTestInstructionMasterMntNewCbm.Execute(trxContext, updateTestInstructionVo);

                outVo.AffectedCount               = deleteinspectionTestInstructionVo.AffectedCount;
                outVo.InspectionItemId            = updateTestInstructionVo.InspectionItemId;
                outVo.InspectionTestInstructionId = updateTestInstructionVo.InspectionTestInstructionId;
                return(outVo);
            }
            else if (updateTestInstructionDetailVo != null && updateTestInstructionDetailVo.DeleteFlag)
            {
                //delete inspectiontestinstructiondetail
                InspectionTestInstructionVo deleteInspectionTestInstructionDetailVo = (InspectionTestInstructionVo)deleteInspectionTestInstructionDetailMasterMntCbm.Execute(trxContext, updateTestInstructionDetailVo);

                outVo.AffectedCount = deleteInspectionTestInstructionDetailVo.AffectedCount;
                outVo.InspectionTestInstructionId = updateTestInstructionDetailVo.InspectionTestInstructionId;
                return(outVo);
            }

            return(outVo);
        }
        /// <summary>
        /// delete the selected record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Delete_btn_Click(object sender, EventArgs e)
        {
            int selectedrowindex = InspectionSelectionValue_dgv.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = InspectionSelectionValue_dgv.Rows[selectedrowindex];

            messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, selectedRow.Cells["colInspectionItemSelectionValueText"].Value.ToString());
            // Logger.Info(messageData);
            DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text);

            if (dialogResult == DialogResult.OK)
            {
                InspectionItemSelectionDatatypeValueVo inVo = new InspectionItemSelectionDatatypeValueVo();

                inVo.InspectionItemSelectionDatatypeValueId = Convert.ToInt32(selectedRow.Cells["colInspectionItemSelectionDatatypeValueId"].Value.ToString());
                inVo.DeleteFlag = true;
                if (inspectionItemdata != null)
                {
                    inVo.InspectionItemId = inspectionItemdata.InspectionItemId;
                }
                else
                {
                    inVo.InspectionItemId = InspectionItemId;
                }

                //UpdateInspectionItemSelectionDatatypeValueVo = inVo;
                //this.Close();


                try
                {
                    UpdateResultVo deleteVo = null;

                    if (inspectionItemdata == null)
                    {
                        deleteVo = (UpdateResultVo)base.InvokeCbm(new DeleteInspectionItemSelectionDatatypeValueCbm(), inVo, false);
                        if (deleteVo == null)
                        {
                            return;
                        }
                        IntSuccess = deleteVo.AffectedCount;

                        if (deleteVo.AffectedCount > 0)
                        {
                            this.messageData = new MessageData("mmci00003", Properties.Resources.mmci00003, null);
                            logger.Info(this.messageData);
                            popUpMessage.Information(this.messageData, Text);
                        }
                        else if (deleteVo.AffectedCount == 0)
                        {
                            messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null);
                            logger.Info(messageData);
                            popUpMessage.Information(messageData, Text);
                        }

                        GridBind();
                    }
                    else
                    {
                        string message = string.Format(Properties.Resources.mmci00038, "Inspection Item Selection Datatype Value", selectedRow.Cells["colInspectionItemSelectionValueText"].Value.ToString());
                        StartProgress(message);

                        ValueObjectList <ValueObject> inVoList     = new ValueObjectList <ValueObject>();
                        InspectionFormatVo            passformatVo = FormFormatVo(inspectionItemdata.InspectionItemId);
                        if (passformatVo == null || passformatVo.InspectionFormatId == 0)
                        {
                            return;
                        }

                        inVoList.add(passformatVo);
                        inVoList.add(null);
                        inVoList.add(null);
                        inVoList.add(inVo);
                        inVoList.add(null);
                        inVoList.add(null);
                        inVoList.add(null);

                        InspectionReturnVo outVo = null;

                        try
                        {
                            outVo = (InspectionReturnVo)base.InvokeCbm(new UpdateAllInspectionFunctionMasterMntCbm(), inVoList, false);
                        }
                        catch (Framework.ApplicationException exception)
                        {
                            popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                            logger.Error(exception.GetMessageData());
                            return;
                        }
                        finally
                        {
                            CompleteProgress();
                        }
                        if (outVo != null && outVo.AffectedCount > 0)
                        {
                            IntSuccess       = outVo.AffectedCount;
                            InspectionItemId = outVo.InspectionItemId;
                            inspectionItemdata.InspectionItemId = outVo.InspectionItemId;

                            InspectionFormatProcessBuzzLogic getprocessid = new InspectionFormatProcessBuzzLogic();
                            InspectionReturnVo invo = new InspectionReturnVo();
                            invo.InspectionItemId = outVo.InspectionItemId;
                            InspectionReturnVo getInspectionVo = getprocessid.RefreshAllFormGrid(invo);
                            if (getInspectionVo != null && getInspectionVo.InspectionProcessId > 0)
                            {
                                InspectionProcessId = getInspectionVo.InspectionProcessId;
                            }

                            this.messageData = new MessageData("mmci00003", Properties.Resources.mmci00003, null);
                            logger.Info(this.messageData);
                            popUpMessage.Information(this.messageData, Text);

                            GridBind();
                        }
                        else
                        {
                            messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null);
                            logger.Info(messageData);
                            popUpMessage.Information(messageData, Text);
                        }
                    }
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    logger.Error(exception.GetMessageData());
                }

                //string message = string.Format(Properties.Resources.mmci00038, "Inspection Selection DataType Value", selectedRow.Cells["colInspectionItemSelectionValueText"].Value.ToString());
                //StartProgress(message);

                //ValueObjectList<ValueObject> inVoList = new ValueObjectList<ValueObject>();
                //InspectionFormatVo passformatVo = FormFormatVo(inspectionItemdata.InspectionItemId);
                //if (passformatVo == null || passformatVo.InspectionFormatId == 0) return;

                //inVoList.add(passformatVo);
                //inVoList.add(null);
                //inVoList.add(null);
                //inVoList.add(inVo);
                //inVoList.add(null);
                //inVoList.add(null);
                //inVoList.add(null);

                //UpdateResultVo outVo = (UpdateResultVo)base.InvokeCbm(new UpdateAllInspectionFunctionMasterMntCbm(), inVoList, false);

                //CompleteProgress();
                //if (outVo == null) { return; }

                //try
                //{
                //    UpdateResultVo outVo = (UpdateResultVo)base.InvokeCbm(new DeleteInspectionItemSelectionDatatypeValueCbm(), inVo, false);

                //    if (outVo.AffectedCount > 0)
                //    {
                //        this.messageData = new MessageData("mmci00003", Properties.Resources.mmci00003, null);
                //        logger.Info(this.messageData);
                //        popUpMessage.Information(this.messageData, Text);
                //    }
                //    else if (outVo.AffectedCount == 0)
                //    {
                //        messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null);
                //        logger.Info(messageData);
                //        popUpMessage.Information(messageData, Text);
                //    }
                //    GridBind();
                //}
                //catch (Framework.ApplicationException exception)
                //{
                //    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                //    logger.Error(exception.GetMessageData());
                //}
            }
            else if (dialogResult == DialogResult.Cancel)
            {
                //do something else
            }
        }
        /// <summary>
        /// inserts new record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Ok_btn_Click(object sender, EventArgs e)
        {
            InspectionItemSelectionDatatypeValueVo inVo = new InspectionItemSelectionDatatypeValueVo();
            var sch = StringCheckHelper.GetInstance();

            if (CheckMandatory() == true)
            {
                inVo.InspectionItemSelectionDatatypeValueText = SelectionDatatypeValueText_txt.Text.Trim();

                inVo.DisplayOrder = Convert.ToInt32(InspectionItemDisplayOrder_txt.Text);

                if (InspectionItem_cmb.SelectedValue != null && InspectionItem_cmb.SelectedIndex >= 0)
                {
                    inVo.InspectionItemId = Convert.ToInt32(InspectionItem_cmb.SelectedValue.ToString());
                }

                if (updateData != null)
                {
                    inVo.InspectionItemId = updateData.InspectionItemId;
                }

                if (mode.Equals(CommonConstants.MODE_UPDATE))
                {
                    inVo.InspectionItemSelectionDatatypeValueId = updateData.InspectionItemSelectionDatatypeValueId;
                }

                inVo.Mode = mode;

                try
                {
                    if (string.Equals(mode, CommonConstants.MODE_ADD) || string.Equals(mode, CommonConstants.MODE_SELECT))
                    {
                        InspectionItemSelectionDatatypeValueVo checkVo = DuplicateCheck(inVo);
                        if (checkVo != null && checkVo.AffectedCount > 0)
                        {
                            messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, SelectionDatatypeValueText_lbl.Text + " : " + SelectionDatatypeValueText_txt.Text);
                            popUpMessage.Information(messageData, Text);

                            return;
                        }

                        InspectionItemSelectionDatatypeValueVo checkDisplayVo = DuplicateDisplayCheck(inVo);
                        if (checkDisplayVo != null && checkDisplayVo.AffectedCount > 0)
                        {
                            messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, InspectionItemDisplayOrder_lbl.Text + " : " + InspectionItemDisplayOrder_txt.Text);
                            logger.Info(messageData);
                            popUpMessage.Information(messageData, Text);
                            InspectionItemDisplayOrder_txt.Focus();
                            return;
                        }

                        inVo.InspectionItemSelectionDatatypeValueCode = InspectionItemCode
                                                                        + GlobalMasterDataTypeEnum.CODE_SEPARATOR.GetValue()
                                                                        + GlobalMasterDataTypeEnum.SELECTION_VALUE_CODE.GetValue() + GlobalMasterDataTypeEnum.CODE_SEPARATOR.GetValue() + RunningNumber;

                        UpdateResultVo outVo = (UpdateResultVo)base.InvokeCbm(new AddInspectionItemSelectionDatatypeValueCbm(), inVo, false);

                        IntSuccess = outVo.AffectedCount;
                    }
                    else if (mode.Equals(CommonConstants.MODE_UPDATE))
                    {
                        if (SelectionDatatypeValueText_txt.Text == updateData.InspectionItemSelectionDatatypeValueText && updateData.DisplayOrder == Convert.ToInt32(InspectionItemDisplayOrder_txt.Text))
                        {
                            return;
                        }
                        if (updateData.InspectionItemSelectionDatatypeValueText != SelectionDatatypeValueText_txt.Text)
                        {
                            InspectionItemSelectionDatatypeValueVo checkVo = DuplicateCheck(inVo);
                            if (checkVo != null && checkVo.AffectedCount > 0)
                            {
                                messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, SelectionDatatypeValueText_lbl.Text + " : " + SelectionDatatypeValueText_txt.Text);
                                popUpMessage.Information(messageData, Text);

                                return;
                            }
                        }

                        if (updateData.DisplayOrder != Convert.ToInt32(InspectionItemDisplayOrder_txt.Text))
                        {
                            InspectionItemSelectionDatatypeValueVo checkDisplayVo = DuplicateDisplayCheck(inVo);
                            if (checkDisplayVo != null && checkDisplayVo.AffectedCount > 0)
                            {
                                messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, InspectionItemDisplayOrder_lbl.Text + " : " + InspectionItemDisplayOrder_txt.Text);
                                logger.Info(messageData);
                                popUpMessage.Information(messageData, Text);
                                InspectionItemDisplayOrder_txt.Focus();
                                return;
                            }
                        }

                        if (updateData == null)
                        {
                            UpdateResultVo outResultVo = (UpdateResultVo)base.InvokeCbm(new UpdateInspectionItemSelectionDatatypeValueCbm(), inVo, false);
                            if (outResultVo == null)
                            {
                                return;
                            }
                            IntSuccess = outResultVo.AffectedCount;
                        }
                        else
                        {
                            string message = string.Format(Properties.Resources.mmci00037, "Inspection Item Selection Datatype Value", SelectionDatatypeValueText_txt.Text);
                            StartProgress(message);

                            ValueObjectList <ValueObject> inVoList     = new ValueObjectList <ValueObject>();
                            InspectionFormatVo            passformatVo = FormFormatVo(updateData.InspectionItemId);
                            if (passformatVo == null || passformatVo.InspectionFormatId == 0)
                            {
                                return;
                            }

                            inVoList.add(passformatVo);
                            inVoList.add(null);
                            inVoList.add(null);
                            inVoList.add(inVo);
                            inVoList.add(null);
                            inVoList.add(null);
                            inVoList.add(null);

                            InspectionReturnVo outVo = null;

                            try
                            {
                                outVo = (InspectionReturnVo)base.InvokeCbm(new UpdateAllInspectionFunctionMasterMntCbm(), inVoList, false);
                            }
                            catch (Framework.ApplicationException exception)
                            {
                                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                                logger.Error(exception.GetMessageData());
                                return;
                            }
                            finally
                            {
                                CompleteProgress();
                            }
                            if (outVo != null && outVo.AffectedCount > 0)
                            {
                                IntSuccess       = outVo.AffectedCount;
                                InspectionItemId = outVo.InspectionItemId;

                                InspectionFormatProcessBuzzLogic getprocessid = new InspectionFormatProcessBuzzLogic();
                                InspectionReturnVo invo = new InspectionReturnVo();
                                invo.InspectionItemId = outVo.InspectionItemId;
                                InspectionReturnVo getInspectionVo = getprocessid.RefreshAllFormGrid(invo);
                                if (getInspectionVo != null && getInspectionVo.InspectionProcessId > 0)
                                {
                                    InspectionProcessId = getInspectionVo.InspectionProcessId;
                                }
                            }
                        }
                        //UpdateInspectionItemSelectionDatatypeValueVo = new InspectionItemSelectionDatatypeValueVo();

                        //UpdateInspectionItemSelectionDatatypeValueVo = inVo;
                        //this.Close();
                    }
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    logger.Error(exception.GetMessageData());
                    return;
                }

                if ((IntSuccess > 0))
                {
                    //messageData = new MessageData("mmci00001", Properties.Resources.mmci00001, null);
                    //logger.Info(messageData);
                    //popUpMessage.Information(messageData, Text);
                    this.Close();
                }
            }
        }
        public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            ValueObjectList <ValueObjectList <ValueObject> > inVo = (ValueObjectList <ValueObjectList <ValueObject> >)vo;

            if (inVo == null || inVo.GetList() == null || inVo.GetList().Count == 0)
            {
                return(outVo);
            }

            ValueObjectList <ValueObject> updateSelectionValueListVo = new ValueObjectList <ValueObject>();
            UpdateResultVo returnitemSelectionInsertedVo             = null;

            updateSelectionValueListVo = inVo.GetList()[inVo.GetList().Count - 1];
            if (updateSelectionValueListVo != null && updateSelectionValueListVo.GetList() != null && updateSelectionValueListVo.GetList().Count > 0)
            {
                UpdateSelectionValueVo = new InspectionItemSelectionDatatypeValueVo();
                UpdateSelectionValueVo = (InspectionItemSelectionDatatypeValueVo)updateSelectionValueListVo.GetList()[0];
            }

            inVo.GetList().RemoveAt(inVo.GetList().Count - 1);

            //get inspection Selection Value list for the above fetched itemlist
            inspectionSelectionValueListInVo = (ValueObjectList <InspectionItemSelectionDatatypeValueVo>)getInspectionSelectionDataTypeListCbm.Execute(trxContext, inVo);
            if (inspectionSelectionValueListInVo == null || inspectionSelectionValueListInVo.GetList() == null || inspectionSelectionValueListInVo.GetList().Count == 0)
            {
                return(outVo);
            }

            if (UpdateSelectionValueVo != null && UpdateSelectionValueVo.InspectionItemSelectionDatatypeValueId > 0)
            {
                if (UpdateSelectionValueVo.DeleteFlag)
                {
                    inspectionSelectionValueListInVo.GetList().Remove(inspectionSelectionValueListInVo.GetList().Single(v => v.InspectionItemSelectionDatatypeValueId == UpdateSelectionValueVo.InspectionItemSelectionDatatypeValueId));
                }
                else
                {
                    foreach (InspectionItemSelectionDatatypeValueVo ItemVo in inspectionSelectionValueListInVo.GetList().Where(v => v.InspectionItemSelectionDatatypeValueId == UpdateSelectionValueVo.InspectionItemSelectionDatatypeValueId))
                    {
                        ItemVo.InspectionItemSelectionDatatypeValueText = UpdateSelectionValueVo.InspectionItemSelectionDatatypeValueText;
                        ItemVo.DisplayOrder = UpdateSelectionValueVo.DisplayOrder;
                    }
                }
            }

            int returnProcessId = 0;

            foreach (ValueObjectList <ValueObject> getitemVo in inVo.GetList())
            {
                InspectionItemVo OldInsProcessVo = (InspectionItemVo)getitemVo.GetList()[0];
                InspectionItemVo NewInsProcessVo = (InspectionItemVo)getitemVo.GetList()[1];

                int ItemSelectionCount = 1;
                foreach (InspectionItemSelectionDatatypeValueVo itemVo in inspectionSelectionValueListInVo.GetList().Where(v => v.InspectionItemId == OldInsProcessVo.InspectionItemId).Distinct())
                {
                    itemVo.InspectionItemId = NewInsProcessVo.InspectionItemId;
                    itemVo.InspectionItemSelectionDatatypeValueCode = NewInsProcessVo.InspectionItemCode +
                                                                      GlobalMasterDataTypeEnum.CODE_SEPARATOR.GetValue() +
                                                                      GlobalMasterDataTypeEnum.SELECTION_VALUE_CODE.GetValue() +
                                                                      GlobalMasterDataTypeEnum.CODE_SEPARATOR.GetValue() + ItemSelectionCount;
                    ItemSelectionCount += 1;
                }

                if (UpdateSelectionValueVo != null)
                {
                    if (UpdateSelectionValueVo.InspectionItemId == OldInsProcessVo.InspectionItemId)
                    {
                        UpdateSelectionValueVo.InspectionItemId = NewInsProcessVo.InspectionItemId; returnProcessId = NewInsProcessVo.InspectionProcessId;
                    }
                }
            }

            returnitemSelectionInsertedVo = (UpdateResultVo)addInspectionItemSelectionDatatypeValueCopyCbm.Execute(trxContext, inspectionSelectionValueListInVo);

            if (UpdateSelectionValueVo != null)
            {
                if (outVo == null)
                {
                    outVo = new InspectionReturnVo();
                }
                outVo.InspectionItemId    = UpdateSelectionValueVo.InspectionItemId;
                outVo.InspectionProcessId = returnProcessId;
            }

            return(outVo);
        }
        public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InspectionReturnVo outVo       = new InspectionReturnVo();
            InspectionReturnVo copyChildVo = null;

            ValueObjectList <ValueObject> inListVo = (ValueObjectList <ValueObject>)vo;

            if (inListVo == null || inListVo.GetList() == null || inListVo.GetList().Count == 0)
            {
                return(outVo);
            }

            InspectionItemVo updateitemVo = (InspectionItemVo)inListVo.GetList()[2];
            InspectionItemSelectionDatatypeValueVo updateSelectionDataTypeValueVo = (InspectionItemSelectionDatatypeValueVo)inListVo.GetList()[3];

            copyInspectionFormatMasterMntCbm = new CopyInspectionFormatMasterMntCbm();

            outVo = (InspectionReturnVo)copyInspectionFormatMasterMntCbm.Execute(trxContext, vo);

            updateitemVo.InspectionItemId = outVo.InspectionItemId;
            //copyChildItemsExist(trxContext, updateitemVo);

            InspectionItemVo childInVo = new InspectionItemVo();

            childInVo.ParentInspectionItemId = updateitemVo.InspectionItemIdCopy;

            ValueObjectList <InspectionItemVo> childOutVo = (ValueObjectList <InspectionItemVo>)getInspectionItemChildCbm.Execute(trxContext, childInVo);

            if (childOutVo != null && childOutVo.GetList() != null && childOutVo.GetList().Count > 0)
            {
                int RunningNumber     = 1;
                InspectionItemVo inVo = new InspectionItemVo();
                //inVo.ParentInspectionItemId = updateitemVo.InspectionItemId;
                inVo.InspectionProcessId = updateitemVo.InspectionProcessId;

                InspectionItemVo getRunningNoVo = (InspectionItemVo)getInspectionItemSeqCbm.Execute(trxContext, inVo);
                if (getRunningNoVo != null && getRunningNoVo.InspectionItemCode != null)
                {
                    string strTemp;
                    strTemp = getRunningNoVo.InspectionItemCode;
                    if (strTemp.LastIndexOf(GlobalMasterDataTypeEnum.CODE_SEPARATOR.GetValue()) > 0)
                    {
                        strTemp = strTemp.Substring(strTemp.LastIndexOf(GlobalMasterDataTypeEnum.CODE_SEPARATOR.GetValue()) + 1);
                        if (strTemp.All(Char.IsDigit))
                        {
                            RunningNumber = Convert.ToInt32(strTemp) + 1;
                        }
                    }
                }

                int displyOrd = 0;
                foreach (InspectionItemVo itmVo in childOutVo.GetList())
                {
                    displyOrd += 1;
                    itmVo.ParentInspectionItemId = updateitemVo.InspectionItemId;
                    itmVo.InspectionItemIdCopy   = itmVo.InspectionItemId;
                    itmVo.InspectionProcessCode  = updateitemVo.InspectionProcessCode;
                    itmVo.DisplayOrder           = displyOrd;

                    itmVo.InspectionItemCode = updateitemVo.InspectionProcessCode + GlobalMasterDataTypeEnum.CODE_SEPARATOR.GetValue() +
                                               GlobalMasterDataTypeEnum.ITEM_CODE.GetValue() + GlobalMasterDataTypeEnum.CODE_SEPARATOR.GetValue() + RunningNumber;

                    inListVo.GetList()[2] = itmVo;

                    copyInspectionFormatMasterMntCbm = new CopyInspectionFormatMasterMntCbm();
                    copyChildVo    = (InspectionReturnVo)copyInspectionFormatMasterMntCbm.Execute(trxContext, inListVo);
                    RunningNumber += 1;
                }
            }

            if (copyChildVo != null)
            {
                return(copyChildVo);
            }
            return(outVo);
        }
예제 #23
0
        public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            ValueObjectList <ValueObject> inListVo = (ValueObjectList <ValueObject>)vo;
            InspectionReturnVo            outVo    = null;

            if (inListVo == null && inListVo.GetList() == null && inListVo.GetList().Count < 7)
            {
                return(outVo);
            }
            InspectionFormatVo  updateFormatVo  = (InspectionFormatVo)inListVo.GetList()[0];
            InspectionProcessVo updateprocessVo = (InspectionProcessVo)inListVo.GetList()[1];
            InspectionItemVo    updateitemVo    = (InspectionItemVo)inListVo.GetList()[2];
            InspectionItemSelectionDatatypeValueVo updateSelectionDataTypeValueVo = (InspectionItemSelectionDatatypeValueVo)inListVo.GetList()[3];
            InspectionSpecificationVo   updateSpecificationVo         = (InspectionSpecificationVo)inListVo.GetList()[4];
            InspectionTestInstructionVo updateTestInstructionVo       = (InspectionTestInstructionVo)inListVo.GetList()[5];
            InspectionTestInstructionVo updateTestInstructionDetailVo = (InspectionTestInstructionVo)inListVo.GetList()[6];

            //Initialize Vo for Get the new inserted Result
            ValueObjectList <ValueObjectList <ValueObject> > inspectionProcessListInVo = null;
            ValueObjectList <ValueObjectList <ValueObject> > inspectionItemListInVo    = null;

            // Only For Process Copy
            if (updateprocessVo != null && updateprocessVo.InspectionProcessIdCopy > 0)
            {
                //Insert inspection process master data
                inspectionProcessListInVo = (ValueObjectList <ValueObjectList <ValueObject> >)copyInspectionProcessFromProcessMasterMntCbm.Execute(trxContext, updateprocessVo);
                if (inspectionProcessListInVo != null)
                {
                    outVo = new InspectionReturnVo();
                    outVo.InspectionFormatId = updateprocessVo.InspectionFormatId;

                    foreach (ValueObjectList <ValueObject> getProcessVo in inspectionProcessListInVo.GetList())
                    {
                        outVo.InspectionProcessId = ((InspectionProcessVo)getProcessVo.GetList()[1]).InspectionProcessId;
                        outVo.AffectedCount       = ((InspectionProcessVo)getProcessVo.GetList()[1]).InspectionProcessId;
                    }
                }
            }
            else if (updateitemVo != null && updateitemVo.InspectionItemIdCopy > 0)  // Only For Item Copy
            {
                //Insert inspection item master data
                inspectionItemListInVo = (ValueObjectList <ValueObjectList <ValueObject> >)copyInspectionItemFromItemMasterMntCbm.Execute(trxContext, updateitemVo);
                if (inspectionItemListInVo != null)
                {
                    outVo = new InspectionReturnVo();
                    outVo.InspectionProcessId = updateitemVo.InspectionProcessId;

                    foreach (ValueObjectList <ValueObject> getItemVo in inspectionItemListInVo.GetList())
                    {
                        outVo.InspectionItemId = ((InspectionItemVo)getItemVo.GetList()[1]).InspectionItemId;
                        outVo.AffectedCount    = ((InspectionItemVo)getItemVo.GetList()[1]).InspectionItemId;
                    }
                }
            }
            else //Format Copy ,update, delete
            {
                //add inspectionformat based on the copied format
                InspectionFormatVo inspectionFormatVo = (InspectionFormatVo)addInspectionFormatAndItemLineFormatCbm.Execute(trxContext, updateFormatVo);

                //if inspectionformat data is null return null
                if (inspectionFormatVo == null)
                {
                    return(outVo);
                }

                outVo = new InspectionReturnVo();
                outVo.AffectedCount      = 1;
                outVo.InspectionFormatId = inspectionFormatVo.InspectionFormatId;

                //To get the Process Details based on the Copied format id
                inspectionFormatVo.InspectionFormatIdCopy = updateFormatVo.InspectionFormatIdCopy;

                // To pass the parameter to get and update the Inspection Process
                ValueObjectList <ValueObject> inVo = new ValueObjectList <ValueObject>();
                inVo.add(inspectionFormatVo);
                inVo.add(updateprocessVo);

                //Insert inspection process master data
                inspectionProcessListInVo = (ValueObjectList <ValueObjectList <ValueObject> >)copyInspectionProcessMasterMntCbm.Execute(trxContext, inVo);
            }

            if (inspectionItemListInVo == null)
            {
                if (inspectionProcessListInVo == null || inspectionProcessListInVo.GetList() == null || inspectionProcessListInVo.GetList().Count == 0)
                {
                    return(outVo);
                }

                if (outVo == null)
                {
                    outVo = new InspectionReturnVo();
                    outVo.AffectedCount = 1;
                }

                if (updateprocessVo != null && updateprocessVo.InspectionProcessIdCopy == 0)
                {
                    InspectionProcessVo returnProcessVo = (InspectionProcessVo)inspectionProcessListInVo.GetList()[inspectionProcessListInVo.GetList().Count - 1].GetList()[0];
                    if (returnProcessVo != null)
                    {
                        outVo.InspectionFormatId  = returnProcessVo.InspectionFormatId;
                        outVo.InspectionProcessId = returnProcessVo.InspectionProcessId;
                    }

                    //To Remove the ReturnVo
                    inspectionProcessListInVo.GetList().RemoveAt(inspectionProcessListInVo.GetList().Count - 1);
                }

                // To pass the parameter to get and update the Inspection Item
                ValueObjectList <ValueObject> updateitemVoList = new ValueObjectList <ValueObject>();
                updateitemVoList.add(updateitemVo);
                inspectionProcessListInVo.add(updateitemVoList);

                //Insert inspection Item master data
                inspectionItemListInVo = (ValueObjectList <ValueObjectList <ValueObject> >)copyInspectionItemMasterMntCbm.Execute(trxContext, inspectionProcessListInVo);

                if (inspectionItemListInVo == null || inspectionItemListInVo.GetList() == null || inspectionItemListInVo.GetList().Count == 0)
                {
                    return(outVo);
                }

                if (updateitemVo != null)
                {
                    InspectionItemVo returnItemVo = (InspectionItemVo)inspectionItemListInVo.GetList()[inspectionItemListInVo.GetList().Count - 1].GetList()[0];
                    if (returnItemVo != null)
                    {
                        outVo.InspectionProcessId = returnItemVo.InspectionProcessId;
                        outVo.InspectionItemId    = returnItemVo.InspectionItemId;
                    }

                    //To Remove the ReturnVo
                    inspectionItemListInVo.GetList().RemoveAt(inspectionItemListInVo.GetList().Count - 1);
                }

                // To pass the parameter to get and update the Inspection Selection Value
                ValueObjectList <ValueObject> updateSelectionValueVoList = new ValueObjectList <ValueObject>();
                updateSelectionValueVoList.add(updateSelectionDataTypeValueVo);
                inspectionItemListInVo.add(updateSelectionValueVoList);

                //Insert inspection Item Selection DataType Value master data
                InspectionReturnVo returnSelectionVo = (InspectionReturnVo)copyInspectionSelectionDataTypeMasterMntCbm.Execute(trxContext, inspectionItemListInVo);
                if (updateSelectionDataTypeValueVo != null && returnSelectionVo != null)
                {
                    outVo.InspectionItemId = returnSelectionVo.InspectionItemId;
                }
            }

            // To pass the parameter to get and update the Inspection Specification
            ValueObjectList <ValueObject> updateSpecificationVoList = new ValueObjectList <ValueObject>();

            updateSpecificationVoList.add(updateSpecificationVo);
            inspectionItemListInVo.add(updateSpecificationVoList);

            //Insert inspection Specification master data
            InspectionReturnVo returnSpecVo = (InspectionReturnVo)copyInspectionSpecificationMasterMntCbm.Execute(trxContext, inspectionItemListInVo);

            if (updateSpecificationVo != null && returnSpecVo != null)
            {
                outVo.InspectionItemId = returnSpecVo.InspectionItemId;
            }

            // To pass the parameter to get and update the Inspection Test Instruction
            ValueObjectList <ValueObject> updateTestInstVoList = new ValueObjectList <ValueObject>();

            updateTestInstVoList.add(updateTestInstructionVo);
            inspectionItemListInVo.add(updateTestInstVoList);


            //Insert inspection Test Instruction master data
            ValueObjectList <ValueObjectList <ValueObject> > inspectionTestInstructionOutVo = (ValueObjectList <ValueObjectList <ValueObject> >)copyInspectionTestInstructionMasterMntCbm.Execute(trxContext, inspectionItemListInVo);

            if (inspectionTestInstructionOutVo == null || inspectionTestInstructionOutVo.GetList() == null || inspectionTestInstructionOutVo.GetList().Count == 0)
            {
                return(outVo);
            }

            if (updateTestInstructionVo != null)
            {
                InspectionTestInstructionVo returnTestInstVo = (InspectionTestInstructionVo)inspectionTestInstructionOutVo.GetList()[inspectionTestInstructionOutVo.GetList().Count - 1].GetList()[0];
                if (returnTestInstVo != null)
                {
                    outVo.InspectionItemId = returnTestInstVo.InspectionItemId;
                }

                //To Remove the ReturnVo
                inspectionTestInstructionOutVo.GetList().RemoveAt(inspectionTestInstructionOutVo.GetList().Count - 1);
            }

            // To pass the parameter to get and update the Insepection Test Instruction Details
            ValueObjectList <ValueObject> updateTestInstDetailVoList = new ValueObjectList <ValueObject>();

            updateTestInstDetailVoList.add(updateTestInstructionDetailVo);
            inspectionTestInstructionOutVo.add(updateTestInstDetailVoList);

            //Insert inspection Test Instruction detail master data
            InspectionReturnVo returndetailVo = (InspectionReturnVo)copyInspectionTestInstructionDetailMasterMntCbm.Execute(trxContext, inspectionTestInstructionOutVo);

            if (updateTestInstructionDetailVo != null && returndetailVo != null)
            {
                outVo.InspectionTestInstructionId = returndetailVo.InspectionTestInstructionId;
            }

            return(outVo);
        }