Ejemplo n.º 1
0
        /// <summary>
        /// passing update data to update form
        /// </summary>
        private void BindUpdateCastingMachineFurnaceData()
        {
            int selectedrowindex = CastingMachineFurnaceDetails_dgv.SelectedCells[0].RowIndex;

            CastingMachineFurnaceVo castFurVo = (CastingMachineFurnaceVo)CastingMachineFurnaceDetails_dgv.Rows[selectedrowindex].DataBoundItem;

            AddCastingMachineFurnaceForm newAddForm = new AddCastingMachineFurnaceForm(CommonConstants.MODE_UPDATE, castFurVo);

            newAddForm.ShowDialog(this);

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

                GridBind(FormConditionVo());
            }
            else if (newAddForm.IntSuccess == 0)
            {
                messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);
                GridBind(FormConditionVo());
            }
        }
        /// <summary>
        /// Creates seacrh condition as per user inputs
        /// </summary>
        /// <returns>search condition</returns>
        private StringBuilder FormCondition(CastingMachineFurnaceVo inVo)
        {
            StringBuilder searchCondition = new StringBuilder();

            searchCondition.Append(" where cmf.factory_cd = :faccd ");

            if (inVo.CastingMachineFurnaceCode != null)
            {
                searchCondition.Append(" and UPPER(cmf.casting_machine_furnace_cd) like UPPER(:castfurcode)");
            }

            if (inVo.CastingMachineFurnaceName != null)
            {
                searchCondition.Append(" and UPPER(cmf.casting_machine_furnace_name) like UPPER(:castfurname)");
            }

            if (inVo.EquipmentId > 0)
            {
                searchCondition.Append(" and cmf.equipment_id = :eqpid");
            }

            searchCondition.Append(" order by cmf.casting_machine_furnace_cd");

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

            CastingMachineFurnaceVo outVo = new CastingMachineFurnaceVo();

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Delete from m_casting_machine_furnace");
            sqlQuery.Append(" where ");
            sqlQuery.Append(" casting_machine_furnace_id = :castfurid ");
            sqlQuery.Append(" and factory_cd = :faccd ;");

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

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

            sqlParameter.AddParameterInteger("castfurid", inVo.CastingMachineFurnaceId);
            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);

            outVo.AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter);

            return(outVo);
        }
Ejemplo n.º 4
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            CastingMachineFurnaceVo inVo = (CastingMachineFurnaceVo)arg;

            CastingMachineFurnaceVo outVo = new CastingMachineFurnaceVo();

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Update m_casting_machine_furnace");
            sqlQuery.Append(" set ");
            sqlQuery.Append(" casting_machine_furnace_name = ");
            sqlQuery.Append(" :castfurname, ");
            sqlQuery.Append(" equipment_id = ");
            sqlQuery.Append(" :eqpid,");
            sqlQuery.Append(" factory_cd = ");
            sqlQuery.Append(" :factcode");
            sqlQuery.Append(" where");
            sqlQuery.Append(" casting_machine_furnace_id = ");
            sqlQuery.Append(" :castfurid");

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

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

            sqlParameter.AddParameterInteger("castfurid", inVo.CastingMachineFurnaceId);
            sqlParameter.AddParameterString("castfurname", inVo.CastingMachineFurnaceName);
            sqlParameter.AddParameterInteger("eqpid", inVo.EquipmentId);
            sqlParameter.AddParameterString("factcode", inVo.FactoryCode);

            outVo.AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter);

            return(outVo);
        }
Ejemplo n.º 5
0
        /// <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 = CastingMachineFurnaceDetails_dgv.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = CastingMachineFurnaceDetails_dgv.Rows[selectedrowindex];

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

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

                inVo.CastingMachineFurnaceId   = Convert.ToInt32(selectedRow.Cells["colCastingMachineFurnaceId"].Value.ToString());
                inVo.CastingMachineFurnaceCode = selectedRow.Cells["colCastingMachineFurnaceCode"].Value.ToString();
                try
                {
                    CastingMachineFurnaceVo tableCount = CheckFurnaceRelationCbm(inVo);
                    if (tableCount.AffectedCount > 0)
                    {
                        messageData = new MessageData("mmce00007", Properties.Resources.mmce00007, CastingMachine.ToString());
                        popUpMessage.Information(messageData, Text);
                        return;
                    }

                    CastingMachineFurnaceVo outVo = (CastingMachineFurnaceVo)base.InvokeCbm(new DeleteCastingMachineFurnaceMasterMntCbm(), inVo, false);

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

                        GridBind(FormConditionVo());
                    }
                    else if (outVo.AffectedCount == 0)
                    {
                        messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null);
                        logger.Info(messageData);
                        popUpMessage.Information(messageData, Text);
                        GridBind(FormConditionVo());
                    }
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    logger.Error(exception.GetMessageData());
                }
            }
            else if (dialogResult == DialogResult.Cancel)
            {
                //do something else
            }
        }
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="pmode"></param>
        /// <param name="userItem"></param>
        public AddCastingMachineFurnaceForm(string pmode, CastingMachineFurnaceVo userItem = null)
        {
            InitializeComponent();

            mode       = pmode;
            updateData = userItem;
            if (string.Equals(mode, CommonConstants.MODE_UPDATE))
            {
                this.Text = UpdateText_lbl.Text;
            }
        }
        /// <summary>
        /// Loads selected data from data grid
        /// </summary>
        /// <param name="dgvCastingMachineFurnace"></param>
        private void LoadCastingMachineFurnaceData(CastingMachineFurnaceVo dgvCastingMachineFurnace)
        {
            if (dgvCastingMachineFurnace != null)
            {
                //this.CastingMachineFurnaceId_lbl.Text = dgvCastingMachineFurnace.Cells["colCastingMachineFurnaceId"].Value.ToString();

                this.CastingMachineFurnaceCode_txt.Text = dgvCastingMachineFurnace.CastingMachineFurnaceCode;

                this.CastingMachineFurnaceName_txt.Text = dgvCastingMachineFurnace.CastingMachineFurnaceName;

                this.Equipment_cmb.SelectedValue = dgvCastingMachineFurnace.EquipmentId.ToString();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// To idenctify the relation ship with tables
        /// </summary>
        private CastingMachineFurnaceVo CheckFurnaceRelationCbm(CastingMachineFurnaceVo inVo)
        {
            CastingMachineFurnaceVo outVo = new CastingMachineFurnaceVo();

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

            return(outVo);
        }
Ejemplo n.º 9
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            CastingMachineFurnaceVo inVo = (CastingMachineFurnaceVo)arg;

            CastingMachineFurnaceVo outVo = new CastingMachineFurnaceVo();


            StringBuilder sqlQuery = new StringBuilder();

            //create SQL
            sqlQuery.Append(" select Count(cmf.casting_machine_furnace_cd) as CastFurCode from m_casting_machine_furnace as cmf");
            sqlQuery.Append(" inner join m_casting_machine as cm on ");
            sqlQuery.Append(" cmf.casting_machine_furnace_id = cm.casting_machine_furnace_id ");
            sqlQuery.Append(" where cmf.factory_cd = :faccd ");
            if (inVo.CastingMachineFurnaceCode != null)
            {
                sqlQuery.Append(" and UPPER(casting_machine_furnace_cd) = UPPER(:castfurcode)");
            }

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

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

            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);
            if (inVo.CastingMachineFurnaceCode != null)
            {
                sqlParameter.AddParameterString("castfurcode", inVo.CastingMachineFurnaceCode);
            }

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

            outVo.AffectedCount = 0;

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

            dataReader.Close();

            return(outVo);
        }
        /// <summary>
        /// Loads equipment details to datatable
        /// </summary>
        private void FormDatatableFromVo()
        {
            equipmentDatatable = new DataTable();
            equipmentDatatable.Columns.Add("Id");
            equipmentDatatable.Columns.Add("Name");

            try
            {
                EquipmentVo equipmentOutVo = (EquipmentVo)base.InvokeCbm(new GetEquipmentMasterMntCbm(), new EquipmentVo(), false);

                foreach (EquipmentVo fac in equipmentOutVo.EquipmentListVo)
                {
                    equipmentDatatable.Rows.Add(fac.EquipmentId, fac.EquipmentName);
                }
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
                return;
            }


            //CastingMachineFurnaceDatatable

            castingMachineFurnaceDatatable = new DataTable();
            castingMachineFurnaceDatatable.Columns.Add("Id");
            castingMachineFurnaceDatatable.Columns.Add("Name");

            try
            {
                CastingMachineFurnaceVo castingMachineFurnaceOutVo =
                    (CastingMachineFurnaceVo)base.InvokeCbm(new GetCastingMachineFurnaceMasterMntCbm(), new CastingMachineFurnaceVo(), false);

                foreach (CastingMachineFurnaceVo castfur in castingMachineFurnaceOutVo.CastingMachineFurnaceListVo)
                {
                    castingMachineFurnaceDatatable.Rows.Add(castfur.CastingMachineFurnaceId, castfur.CastingMachineFurnaceName);
                }
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            CastingMachineFurnaceVo inVo = (CastingMachineFurnaceVo)arg;

            CastingMachineFurnaceVo outVo = new CastingMachineFurnaceVo();

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Insert into m_casting_machine_furnace");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" casting_machine_furnace_cd,");
            sqlQuery.Append(" casting_machine_furnace_name,");
            sqlQuery.Append(" equipment_id,");
            sqlQuery.Append(" registration_user_cd,");
            sqlQuery.Append(" registration_date_time,");
            sqlQuery.Append(" factory_cd");
            sqlQuery.Append(" ) ");
            sqlQuery.Append("VALUES	");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" :castfurcode,");
            sqlQuery.Append(" :castfurname,");
            sqlQuery.Append(" :eqpid,");
            sqlQuery.Append(" :regusercode,");
            sqlQuery.Append(" now(),");
            sqlQuery.Append(" :factcode");
            sqlQuery.Append(" ); ");

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

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

            sqlParameter.AddParameterString("castfurcode", inVo.CastingMachineFurnaceCode);
            sqlParameter.AddParameterString("castfurname", inVo.CastingMachineFurnaceName);
            sqlParameter.AddParameterInteger("eqpid", inVo.EquipmentId);
            sqlParameter.AddParameterString("regusercode", inVo.RegistrationUserCode);
            //sqlParameter.AddParameterDateTime("regdt", inVo.RegistrationDateTime);
            sqlParameter.AddParameterString("factcode", inVo.FactoryCode);

            outVo.AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter);

            return(outVo);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates seacrh condition as per user inputs
        /// </summary>
        /// <returns>search condition</returns>
        private CastingMachineFurnaceVo FormConditionVo()
        {
            CastingMachineFurnaceVo inVo = new CastingMachineFurnaceVo();

            if (CastingMachineFurnaceCode_txt.Text != string.Empty)
            {
                inVo.CastingMachineFurnaceCode = CastingMachineFurnaceCode_txt.Text;
            }

            if (CastingMachineFurnaceName_txt.Text != string.Empty)
            {
                inVo.CastingMachineFurnaceName = CastingMachineFurnaceName_txt.Text;
            }

            if (EquipmentId_cmb.SelectedIndex > -1)
            {
                inVo.EquipmentId = Convert.ToInt32(EquipmentId_cmb.SelectedValue.ToString());
            }

            return(inVo);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Fills all user records to gridview control
        /// </summary>
        private void GridBind(CastingMachineFurnaceVo conditionInVo)
        {
            CastingMachineFurnaceDetails_dgv.DataSource = null;

            try
            {
                CastingMachineFurnaceVo outVo = (CastingMachineFurnaceVo)base.InvokeCbm(new GetCastingMachineFurnaceMasterMntCbm(), conditionInVo, false);

                BindingList <List <CastingMachineFurnaceVo> > userBind = new BindingList <List <CastingMachineFurnaceVo> >();

                CastingMachineFurnaceDetails_dgv.AutoGenerateColumns = false;

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

                if (bindingSource1 != null && bindingSource1.Count > 0)
                {
                    CastingMachineFurnaceDetails_dgv.DataSource = bindingSource1;
                }
                else
                {
                    messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null); //"casting machine furnace"
                    logger.Info(messageData);
                    popUpMessage.Information(messageData, Text);
                }

                CastingMachineFurnaceDetails_dgv.ClearSelection();

                Update_btn.Enabled = false;

                Delete_btn.Enabled = false;
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            CastingMachineFurnaceVo inVo = (CastingMachineFurnaceVo)arg;

            CastingMachineFurnaceVo outVo = new CastingMachineFurnaceVo();

            StringBuilder sqlQuery = new StringBuilder();

            //create SQL
            sqlQuery.Append("select");
            sqlQuery.Append(" cmf.casting_machine_furnace_id,");
            sqlQuery.Append(" cmf.casting_machine_furnace_cd,");
            sqlQuery.Append(" cmf.casting_machine_furnace_name,");
            sqlQuery.Append(" cmf.equipment_id,");
            sqlQuery.Append(" eqp.equipment_name");
            sqlQuery.Append(" from m_casting_machine_furnace cmf");
            sqlQuery.Append(" inner join m_equipment eqp on cmf.equipment_id = eqp.equipment_id");

            sqlQuery.Append(FormCondition(inVo));

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

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

            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);
            if (inVo.CastingMachineFurnaceCode != null)
            {
                sqlParameter.AddParameterString("castfurcode", inVo.CastingMachineFurnaceCode + "%");
            }

            if (inVo.CastingMachineFurnaceName != null)
            {
                sqlParameter.AddParameterString("castfurname", inVo.CastingMachineFurnaceName + "%");
            }

            if (inVo.EquipmentId > 0)
            {
                sqlParameter.AddParameterInteger("eqpid", inVo.EquipmentId);
            }

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

            while (dataReader.Read())
            {
                CastingMachineFurnaceVo currOutVo = new CastingMachineFurnaceVo
                {
                    CastingMachineFurnaceId   = Convert.ToInt32(dataReader["casting_machine_furnace_id"].ToString()),
                    CastingMachineFurnaceCode = dataReader["casting_machine_furnace_cd"].ToString(),
                    CastingMachineFurnaceName = dataReader["casting_machine_furnace_name"].ToString(),
                    EquipmentId   = Convert.ToInt32(dataReader["equipment_id"].ToString()),
                    EquipmentName = dataReader["equipment_name"].ToString()
                };

                outVo.CastingMachineFurnaceListVo.Add(currOutVo);
            }

            dataReader.Close();

            return(outVo);
        }
        /// <summary>
        /// inserts new record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Ok_btn_Click(object sender, EventArgs e)
        {
            CastingMachineFurnaceVo inVo = new CastingMachineFurnaceVo();
            var sch = StringCheckHelper.GetInstance();

            if (CheckMandatory() == true)
            {
                if (string.IsNullOrEmpty(CastingMachineFurnaceCode_txt.Text) || string.IsNullOrEmpty(CastingMachineFurnaceName_txt.Text))
                {
                    messageData = new MessageData("mmce00003", Properties.Resources.mmce00003);
                    logger.Info(messageData);
                    popUpMessage.ConfirmationOkCancel(messageData, Text);

                    if (string.IsNullOrEmpty(CastingMachineFurnaceCode_txt.Text))
                    {
                        CastingMachineFurnaceCode_txt.Focus();
                    }
                    else if (string.IsNullOrEmpty(CastingMachineFurnaceName_txt.Text))
                    {
                        CastingMachineFurnaceName_txt.Focus();
                    }
                    return;
                }
                inVo.CastingMachineFurnaceCode = CastingMachineFurnaceCode_txt.Text.Trim();

                inVo.CastingMachineFurnaceName = CastingMachineFurnaceName_txt.Text.Trim();

                inVo.EquipmentId = Convert.ToInt32(Equipment_cmb.SelectedValue.ToString());

                inVo.RegistrationUserCode = UserData.GetUserData().UserCode;

                //inVo.RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

                inVo.FactoryCode = UserData.GetUserData().FactoryCode;

                if (string.Equals(mode, CommonConstants.MODE_ADD))
                {
                    CastingMachineFurnaceVo checkVo = DuplicateCheck(inVo);

                    if (checkVo != null && checkVo.AffectedCount > 0)
                    {
                        messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, CastingMachineFurnaceCode_lbl.Text + " : " + CastingMachineFurnaceCode_txt.Text);
                        logger.Info(messageData);
                        popUpMessage.ConfirmationOkCancel(messageData, Text);

                        return;
                    }
                }

                try
                {
                    if (string.Equals(mode, CommonConstants.MODE_ADD))
                    {
                        CastingMachineFurnaceVo outVo = (CastingMachineFurnaceVo)base.InvokeCbm(new AddCastingMachineFurnaceMasterMntCbm(), inVo, false);

                        IntSuccess = outVo.AffectedCount;
                    }
                    else if (mode.Equals(CommonConstants.MODE_UPDATE))
                    {
                        inVo.CastingMachineFurnaceId = updateData.CastingMachineFurnaceId;

                        CastingMachineFurnaceVo outVo = (CastingMachineFurnaceVo)base.InvokeCbm(new UpdateCastingMachineFurnaceMasterMntCbm(), inVo, false);

                        IntSuccess = outVo.AffectedCount;
                    }
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    logger.Error(exception.GetMessageData());
                    return;
                }

                if ((IntSuccess > 0) || (IntSuccess == 0))
                {
                    this.Close();
                }
            }
        }