Example #1
0
        private void GetData()
        {
            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();

            if (!isNew)
            {
                CdbcConnection con = UtilCommon.getConnection();

                string cmdQuery = "SELECT P.PRODUCT_CODE "
                                  + "     , P.PRODUCT_NAME "
                                  + "     , P.PRODUCT_PRICE "
                                  + "     , P.CURRENCY_CODE "
                                  + "     , P.PRODUCT_SUMMARY "
                                  + "     , P.CATEGORY_CODE "
                                  + "     , P.PRODUCT_IMAGE "
                                  + "     , P.RELEASE_DATE "
                                  + "  FROM PRODUCTS P "
                                  + " WHERE P.PRODUCT_CODE = :PRODUCT_CODE ";

                CdbcCommand cmd = new CdbcCommand(cmdQuery);

                cmd.Connection  = con;
                cmd.CommandType = CommandType.Text;

                CdbcParameter para = new CdbcParameter(":PRODUCT_CODE", Cdbc.Common.Data.Type.CdbcOracleDbType.Varchar2);
                para.Value = ProductCode;
                cmd.Parameters.Add(para);

                DataSetProducts dsProduct = new DataSetProducts();
                CdbcDataAdapter myDa      = new CdbcDataAdapter(cmd);
                try
                {
                    myDa.Fill(dsProduct, dsProduct.PRODUCTS.TableName);
                    if (dsProduct.Tables.Count > 0 && dsProduct.Tables[0].Rows.Count > 0)
                    {
                        DataSetProducts.PRODUCTSRow dr = (DataSetProducts.PRODUCTSRow)dsProduct.PRODUCTS.Rows[0];
                        txtProductName.Text      = UtilCommon.NvlStr(dr.PRODUCT_NAME);
                        txtPrice.Text            = UtilCommon.NvlStr(dr.PRODUCT_PRICE);
                        cbCurrency.SelectedValue = UtilCommon.NvlStr(dr.CURRENCY_CODE);
                        txtSummary.Text          = UtilCommon.NvlStr(dr.PRODUCT_SUMMARY);
                        cbCategory.SelectedValue = UtilCommon.NvlStr(dr.CATEGORY_CODE);
                        dtReleaseDate.Value      = dr.RELEASE_DATE;
                        pictureBox1.Image        = UtilCommon.ByteArrayToImage(dr.PRODUCT_IMAGE);
                    }
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.Message,
                                    "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error)
                    ;
                }
            }
            sw.Stop();
            this.Text = $"{sw.ElapsedMilliseconds} ms";
        }