コード例 #1
0
        protected void RadCmbCourierHdr_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            string strConnString = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;

            Console.WriteLine(strConnString);
            RadCmbCostHdr.Enabled = true;
            RadCmbCostHdr.ClearSelection();
            RadCmbCostHdr.EmptyMessage = "Select...";
            MySqlConnection conn = new MySqlConnection(strConnString);

            try
            {
                Console.WriteLine("Connecting to MySQL...");
                conn.Open();
                string sql = "SELECT COST_CODE, COST_DESC FROM COURIER_COST_DATA WHERE COURIER_CODE = '" + e.Value + "' ORDER BY COST_DESC ASC";

                daCountry = new MySqlDataAdapter(sql, conn);
                MySqlCommandBuilder cb = new MySqlCommandBuilder(daCountry);
                dsCountry = new DataSet();
                daCountry.Fill(dsCountry, "CUST_DATA");
                RadCmbCostHdr.DataSource = dsCountry;
                RadCmbCostHdr.DataBind();
            }
            catch (Exception ex)
            {
                //ShowMessage("Error: " + ex.Message);
            }

            conn.Close();
            Console.WriteLine("Done.");
        }
コード例 #2
0
        private void setFieldForm(DataTable dt)
        {
            string strConnString = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;

            Console.WriteLine(strConnString);
            MySqlConnection conn = new MySqlConnection(strConnString);

            RadCmbCustHdr.Filter    = RadComboBoxFilter.Contains;
            RadCmbOnlineShop.Filter = RadComboBoxFilter.Contains;
            RadCmbCourierHdr.Filter = RadComboBoxFilter.Contains;
            RadCmbCostHdr.Filter    = RadComboBoxFilter.Contains;
            try
            {
                Console.WriteLine("Connecting to MySQL...");
                conn.Open();
                string sql = "SELECT CUST_CODE, CUST_NAME FROM CUST_DATA ORDER BY CUST_NAME ASC";

                daCountry = new MySqlDataAdapter(sql, conn);
                MySqlCommandBuilder cb = new MySqlCommandBuilder(daCountry);
                dsCountry = new DataSet();
                daCountry.Fill(dsCountry, "CUST_DATA");
                RadCmbCustHdr.DataSource = dsCountry;
                RadCmbCustHdr.DataBind();


                string sql2       = "SELECT COURIER_CODE, COURIER_DETAIL FROM COURIER_DATA ORDER BY COURIER_DETAIL ASC";
                var    courieradp = new MySqlDataAdapter(sql2, conn);
                var    courierdt  = new DataSet();
                courieradp.Fill(courierdt, "COURIER_DATA");
                RadCmbCourierHdr.DataSource = courierdt;
                RadCmbCourierHdr.DataBind();

                string sql3    = "SELECT COST_CODE, COST_DESC FROM COURIER_COST_DATA ORDER BY COST_DESC ASC";
                var    costadp = new MySqlDataAdapter(sql3, conn);
                var    costdt  = new DataSet();
                costadp.Fill(costdt, "COURIER_COST_DATA");
                RadCmbCostHdr.DataSource = costdt;
                RadCmbCostHdr.DataBind();

                string sql4      = "SELECT OLSHOP_CODE, OLSHOP_NAME FROM MT_OLSHOP ORDER BY OLSHOP_NAME ASC";
                var    olshopadp = new MySqlDataAdapter(sql4, conn);
                var    olshopdt  = new DataSet();
                olshopadp.Fill(olshopdt, "MT_OLSHOP");
                RadCmbOnlineShop.DataSource = olshopdt;
                RadCmbOnlineShop.DataBind();

                //MySqlCommand cmd = new MySqlCommand(sql, conn);
                //MySqlDataReader rdr = cmd.ExecuteReader();

                /* conn.Open();
                 *
                 * string sql = "INSERT INTO Country (Name, HeadOfState, Continent) VALUES ('Disneyland','Mickey Mouse', 'North America')";
                 * MySqlCommand cmd = new MySqlCommand(sql, conn);
                 * cmd.ExecuteNonQuery();*/
                /*while (rdr.Read())
                 * {
                 *  Console.WriteLine(rdr[0] + " -- " + rdr[1]);
                 * }
                 * rdr.Close();*/
            }
            catch (Exception ex)
            {
                //ShowMessage("Error: " + ex.Message);
            }

            conn.Close();
            Console.WriteLine("Done.");
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    transcode.Text   = TransDt.Rows[0]["TRANS_CODE"].ToString();
                    transdetail.Text = TransDt.Rows[0]["TRANS_DETAIL"].ToString();
                    if (TransDt.Rows[0]["TRANS_DATE"] != null)
                    {
                        transdate.SelectedDate = Convert.ToDateTime(TransDt.Rows[0]["TRANS_DATE"].ToString());
                    }
                    else
                    {
                        transdate.Clear();
                    }
                    if (TransDt.Rows[0]["TRANS_TOTAL"] != null)
                    {
                        total.Text = TransDt.Rows[0]["TRANS_TOTAL"].ToString();
                    }
                    else
                    {
                        total.Text = "0";
                    }
                    if (TransDt.Rows[0]["CUST_CODE"] != null)
                    {
                        RadCmbCustHdr.SelectedValue = TransDt.Rows[0]["CUST_CODE"].ToString();
                    }
                    else
                    {
                        RadCmbCustHdr.ClearSelection();
                        RadCmbCustHdr.EmptyMessage = "Select...";
                    }
                    if (TransDt.Rows[0]["OLSHOP_CODE"] != null)
                    {
                        RadCmbOnlineShop.SelectedValue = TransDt.Rows[0]["OLSHOP_CODE"].ToString();
                    }
                    else
                    {
                        RadCmbOnlineShop.ClearSelection();
                        RadCmbOnlineShop.EmptyMessage = "Select...";
                    }
                    if (TransDt.Rows[0]["COURIER_CODE"] != null)
                    {
                        RadCmbCourierHdr.SelectedValue = TransDt.Rows[0]["COURIER_CODE"].ToString();
                    }
                    else
                    {
                        RadCmbCourierHdr.ClearSelection();
                        RadCmbCourierHdr.EmptyMessage = "Select...";
                    }
                    if (TransDt.Rows[0]["COST_CODE"] != null)
                    {
                        RadCmbCostHdr.SelectedValue = TransDt.Rows[0]["COST_CODE"].ToString();
                    }
                    else
                    {
                        RadCmbCostHdr.ClearSelection();
                        RadCmbCostHdr.EmptyMessage = "Select...";
                    }
                    if (TransDt.Rows[0]["PACKED_STATUS"] != null)
                    {
                        PackedStat.SetSelectedToggleStateByValue(TransDt.Rows[0]["PACKED_STATUS"].ToString());
                    }
                    else
                    {
                        PackedStat.Checked = false;
                    }
                    if (TransDt.Rows[0]["SENT_STATUS"] != null)
                    {
                        SentStat.SetSelectedToggleStateByValue(TransDt.Rows[0]["SENT_STATUS"].ToString());
                    }
                    else
                    {
                        SentStat.Checked = false;
                    }
                    if (TransDt.Rows[0]["TRANS_STATUS"] != null)
                    {
                        PaymentStat.SetSelectedToggleStateByValue(TransDt.Rows[0]["TRANS_STATUS"].ToString());
                    }
                    else
                    {
                        PaymentStat.Checked = false;
                    }
                    if (TransDt.Rows[0]["REMARKS"] != null)
                    {
                        Remarks.Text = TransDt.Rows[0]["REMARKS"].ToString();
                    }
                    else
                    {
                        Remarks.Text = "";
                    }
                }
                else
                {
                    transcode.Text   = "";
                    transdetail.Text = "";
                    transdate.Clear();
                    total.Text = "";
                    RadCmbOnlineShop.ClearSelection();
                    RadCmbOnlineShop.EmptyMessage = "Select...";
                    RadCmbCustHdr.ClearSelection();
                    RadCmbCustHdr.EmptyMessage = "Select...";
                    RadCmbCourierHdr.ClearSelection();
                    RadCmbCourierHdr.EmptyMessage = "Select...";
                    RadCmbCostHdr.ClearSelection();
                    RadCmbCostHdr.EmptyMessage = "Select...";
                    PackedStat.Checked         = false;
                    SentStat.Checked           = false;
                    PaymentStat.Checked        = false;
                    Remarks.Text = "";
                }
            }
            else
            {
                transcode.Text   = "";
                transdetail.Text = "";
                transdate.Clear();
                total.Text = "";
                RadCmbOnlineShop.ClearSelection();
                RadCmbOnlineShop.EmptyMessage = "Select...";
                RadCmbCustHdr.ClearSelection();
                RadCmbCustHdr.EmptyMessage = "Select...";
                RadCmbCourierHdr.ClearSelection();
                RadCmbCourierHdr.EmptyMessage = "Select...";
                RadCmbCostHdr.ClearSelection();
                RadCmbCostHdr.EmptyMessage = "Select...";
                PackedStat.Checked         = false;
                SentStat.Checked           = false;
                PaymentStat.Checked        = false;
                Remarks.Text = "";
            }
        }