Esempio n. 1
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            ValueObjectList <AssetMaster2019Vo> voList = new ValueObjectList <AssetMaster2019Vo>();
            StringBuilder sql = new StringBuilder();
            //CREATE SQL ADAPTER AND PARAMETER LIST
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());
            DbParameterList  sqlParameter      = sqlCommandAdapter.CreateParameterList();

            sql.Append("select distinct asset_life from m_asset order by asset_life");
            sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());
            sql.Clear();
            //EXECUTE READER FROM COMMAND
            IDataReader datareader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            while (datareader.Read())
            {
                AssetMaster2019Vo outVo = new AssetMaster2019Vo
                {
                    asset_life = datareader["asset_life"].ToString(),
                };
                voList.add(outVo);
            }
            datareader.Close();
            return(voList);
        }
Esempio n. 2
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            AssetMaster2019Vo inVo = (AssetMaster2019Vo)vo;
            StringBuilder     sql  = new StringBuilder();
            DataTable         dt   = new DataTable();
            //CREATE SQL ADAPTER AND PARAMETER LIST
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());
            DbParameterList  sqlParameter      = sqlCommandAdapter.CreateParameterList();

            sql.Append("SELECT asset_id, asset_cd, asset_no, asset_name, asset_serial, asset_model, asset_life, acquistion_cost, acquistion_date, asset_invoice, asset_po, asset_type, factory_cd, asset_supplier, label_status from m_asset where 1=1 ");
            if (!string.IsNullOrEmpty(inVo.asset_cd))
            {
                sql.Append("and asset_cd like '").Append(inVo.asset_cd).Append("%' ");
            }
            if (!string.IsNullOrEmpty(inVo.asset_no.ToString()))
            {
                sql.Append("and asset_no = '").Append(inVo.asset_cd.ToString()).Append("' ");
            }
            if (!string.IsNullOrEmpty(inVo.asset_name))
            {
                sql.Append("and asset_name like '").Append(inVo.asset_name).Append("%' ");
            }
            if (!string.IsNullOrEmpty(inVo.asset_type))
            {
                sql.Append("and asset_type like '").Append(inVo.asset_type).Append("%' ");
            }
            if (!string.IsNullOrEmpty(inVo.asset_life))
            {
                sql.Append("and asset_life like '").Append(inVo.asset_life).Append("%' ");
            }
            if (inVo.checkDateFrom)
            {
                sql.Append("and acquistion_date > '").Append(inVo.dateFrom.ToString("yyyy-MM-dd")).Append("' ");
            }
            if (inVo.checkDateTo)
            {
                sql.Append("and acquistion_date < '").Append(inVo.dateTo.ToString("yyyy-MM-dd")).Append("' ");
            }
            if (inVo.label_status.Length > 3)
            {
                sql.Append("and label_status in (").Append(inVo.label_status).Append(") ");
            }
            sql.Append("order by asset_cd");
            sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());
            sql.Clear();
            //EXECUTE READER FROM COMMAND
            IDataReader datareader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            dt.Load(datareader);
            datareader.Close();
            AssetMaster2019Vo outVo = new AssetMaster2019Vo
            {
                asset_data = dt
            };

            return(outVo);
        }
Esempio n. 3
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     AssetMaster2019Vo deleteVo = (AssetMaster2019Vo)DefaultCbmInvoker
                                  .Invoke(new AssetMaster2019Cbm(), new AssetMaster2019Vo()
     {
         asset_cd   = txtAssetCode.Text,
         asset_name = txtAssetName.Text,
         asset_type = cmbAssetType.Text,
         asset_life = cmbLife.Text,
     });
 }
Esempio n. 4
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            AssetInfoVo   inVo = (AssetInfoVo)vo;
            StringBuilder sql  = new StringBuilder();

            sql.Append(@"INSERT INTO m_asset(
            asset_no, asset_cd, asset_name, asset_model, asset_serial, asset_supplier, asset_invoice, asset_life, acquistion_date,
            acquistion_cost, asset_type, registration_user_cd, registration_date_time, factory_cd, label_status, asset_po)
            VALUES(:asset_no, :asset_cd, :asset_name, :asset_model, :asset_serial, :asset_supplier, 
            :asset_invoice, :asset_life, :acquistion_date, :acquistion_cost, :asset_type, :registration_user_cd, 
            :registration_date_time, :factory_cd, :label_status, :asset_po)");

            //CREATE SQL ADAPTER AND PARAMETER LIST
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());
            DbParameterList  sqlParameter      = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterInteger("asset_no", inVo.asset_no);
            sqlParameter.AddParameterString("asset_cd", inVo.asset_cd);
            sqlParameter.AddParameterString("asset_name", inVo.asset_name);
            sqlParameter.AddParameterString("asset_model", inVo.asset_model);
            sqlParameter.AddParameterString("asset_serial", inVo.asset_serial);
            sqlParameter.AddParameterString("asset_supplier", inVo.asset_supplier);
            sqlParameter.AddParameterString("asset_invoice", inVo.asset_invoice);
            sqlParameter.AddParameter("asset_life", inVo.asset_life);
            sqlParameter.AddParameterDateTime("acquistion_date", inVo.acquistion_date);
            sqlParameter.AddParameter("acquistion_cost", inVo.acquistion_cost);
            sqlParameter.AddParameterString("asset_type", inVo.asset_type);
            sqlParameter.AddParameterString("registration_user_cd", UserData.GetUserData().UserCode);
            sqlParameter.AddParameterDateTime("registration_date_time", DateTime.Now);
            sqlParameter.AddParameterString("factory_cd", UserData.GetUserData().FactoryCode);
            sqlParameter.AddParameterString("label_status", inVo.label_status);
            sqlParameter.AddParameterString("asset_po", inVo.asset_po);
            sql.Clear();

            //EXECUTE READER FROM COMMAND
            AssetMaster2019Vo outVo = new AssetMaster2019Vo
            {
                executeInt = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

            return(outVo);
        }
Esempio n. 5
0
 private void btnAddAsset_Click(object sender, EventArgs e)
 {
     try
     {
         int i = 0;
         foreach (AssetInfoVo inf in infoList)
         {
             AssetMaster2019Vo addAsset = (AssetMaster2019Vo)DefaultCbmInvoker.Invoke(new AddAssetCbm(), inf);
             i += addAsset.executeInt;
         }
         MessageBox.Show("Total " + i + " rows have been add!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "CAUTION", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     infoList.Clear();
     dgvAddAssetList.Rows.Clear();
     dgvAddAssetList.Refresh();
 }
Esempio n. 6
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            AssetInfoVo   inVo = (AssetInfoVo)vo;
            StringBuilder sql  = new StringBuilder();

            sql.Append("update m_asset set asset_cd=:asset_cd,asset_no=:asset_no,asset_name=:asset_name, asset_model=:asset_model, asset_invoice =:asset_invoice,  asset_serial =:asset_serial, asset_supplier=:asset_supplier,asset_life =:asset_life, acquistion_date=:acquistion_date, acquistion_cost=:acquistion_cost, asset_type=:asset_type, label_status=:label_status, asset_po = :asset_po");
            sql.Append(" where asset_cd =:asset_cd and asset_no = :asset_no");

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

            sql.Clear();

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

            sqlParameter.AddParameterInteger("asset_no", inVo.asset_no);
            sqlParameter.AddParameterString("asset_cd", inVo.asset_cd);
            sqlParameter.AddParameterString("asset_name", inVo.asset_name);
            sqlParameter.AddParameterString("asset_model", inVo.asset_model);
            sqlParameter.AddParameterString("asset_serial", inVo.asset_serial);
            sqlParameter.AddParameterString("asset_supplier", inVo.asset_supplier);
            sqlParameter.AddParameterString("asset_invoice", inVo.asset_invoice);
            sqlParameter.AddParameter("asset_life", inVo.asset_life);
            sqlParameter.AddParameterDateTime("acquistion_date", inVo.acquistion_date);
            sqlParameter.AddParameter("acquistion_cost", inVo.acquistion_cost);
            sqlParameter.AddParameterString("asset_type", inVo.asset_type);
            sqlParameter.AddParameterString("factory_cd", inVo.factory_cd);
            sqlParameter.AddParameterString("registration_user_cd", UserData.GetUserData().UserCode);
            sqlParameter.AddParameterString("label_status", inVo.label_status);
            sqlParameter.AddParameterString("asset_po", inVo.asset_po);

            //execute SQL
            AssetMaster2019Vo outVo = new AssetMaster2019Vo()
            {
                executeInt = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

            return(outVo);
        }
Esempio n. 7
0
        private void UpdateAssetEvent()
        {
            AssetMaster2019Vo updateVo = (AssetMaster2019Vo)DefaultCbmInvoker.Invoke(new UpdateAssetCbm(), new AssetInfoVo()
            {
                acquistion_cost = double.Parse(txtAcqCost.Text),
                acquistion_date = dtpAcqDate.Value,
                asset_cd        = txtAssetCode.Text,
                asset_invoice   = txtAssetInvoice.Text,
                asset_life      = (double)numLife.Value,
                asset_model     = txtAssetModel.Text,
                asset_name      = txtAssetName.Text,
                asset_no        = (int)numAssetNo.Value,
                asset_po        = txtAssetPO.Text,
                asset_serial    = txtAssetSerial.Text,
                asset_supplier  = txtSupplier.Text,
                asset_type      = cmbAssetType.Text,
                factory_cd      = txtFactory.Text,
                label_status    = label
            });

            MessageBox.Show("Update completed " + updateVo.executeInt + " rows data!!!");
        }
Esempio n. 8
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            AssetMaster2019Vo inVo = (AssetMaster2019Vo)vo;
            StringBuilder     sql  = new StringBuilder();
            //CREATE SQL ADAPTER AND PARAMETER LIST
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());
            DbParameterList  sqlParameter      = sqlCommandAdapter.CreateParameterList();

            sql.Append("DELETE from m_asset where 1=1 ");
            if (!string.IsNullOrEmpty(inVo.asset_cd))
            {
                sql.Append("and asset_cd = '").Append(inVo.asset_cd).Append("' ");
            }
            if (!string.IsNullOrEmpty(inVo.asset_name))
            {
                sql.Append("and asset_name = '").Append(inVo.asset_name).Append("' ");
            }
            if (!string.IsNullOrEmpty(inVo.asset_type))
            {
                sql.Append("and asset_type = '").Append(inVo.asset_type).Append("' ");
            }
            if (!string.IsNullOrEmpty(inVo.asset_life))
            {
                sql.Append("and asset_life = '").Append(inVo.asset_life).Append("' ");
            }
            //if (inVo.checkDateFrom)
            //    sql.Append("and acquistion_date > '").Append(inVo.dateFrom.ToString("yyyy-MM-dd")).Append("' ");
            //if (inVo.checkDateTo)
            //    sql.Append("and acquistion_date < '").Append(inVo.dateTo.ToString("yyyy-MM-dd")).Append("' ");
            //sql.Append("order by asset_cd");
            sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());
            sql.Clear();
            //EXECUTE READER FROM COMMAND
            int datareader = sqlCommandAdapter.ExecuteNonQuery(sqlParameter);

            return(inVo);
        }
Esempio n. 9
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtAssetCode.TextLength > 10)
            {
                string   str        = txtAssetCode.Text;
                string[] arrListStr = str.Split(',');
                txtAssetCode.Text = arrListStr[0];
            }
            vo.label_status = "'1'";
            if (chkPasted.Checked)
            {
                vo.label_status += ",'Pasted'";
            }
            if (chkNotPaste.Checked)
            {
                vo.label_status += ",'Not Paste'";
            }
            if (chkCantPaste.Checked)
            {
                vo.label_status += ",'Cant Paste'";
            }
            AssetMaster2019Vo searchVo = (AssetMaster2019Vo)DefaultCbmInvoker
                                         .Invoke(new AssetMaster2019Cbm(), new AssetMaster2019Vo()
            {
                asset_cd      = txtAssetCode.Text,
                asset_name    = txtAssetName.Text,
                asset_type    = cmbAssetType.Text,
                asset_life    = cmbLife.Text,
                checkDateFrom = dtpDateFrom.Checked,
                checkDateTo   = dtpDateTo.Checked,
                label_status  = vo.label_status
            });

            vo.asset_data = searchVo.asset_data;
            updateGrid();
        }
Esempio n. 10
0
 public AssetMaster2019Form()
 {
     InitializeComponent();
     vo     = new AssetMaster2019Vo();
     voInfo = new AssetInfoVo();
 }