Exemple #1
0
        private List <ProductType> GetProductTypes()
        {
            List <ProductType> types = new List <ProductType>();

            try
            {
                string    sql = "select * from productTypes";
                DataTable dt  = RemoteCall.RESTQuery(_reqSession, sql);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ProductType type = new ProductType()
                    {
                        TypeId   = Convert.ToInt32(dt.Rows[i]["type_id"]),
                        TypeName = dt.Rows[i]["type_name"].ToString().Trim(),
                    };
                    types.Add(type);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }

            return(types);
        }
 public bool DelOrder(ExOrder objOrder)
 {
     try
     {
         string sql = $"delete from orders where order_no='{objOrder.OrderNo}'";
         RemoteCall.RESTQuery(_reqSession, sql);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public bool Exists(ExOrder objOrder)
        {
            string sql = $"select count(*) from orders where order_no='{objOrder.OrderNo}'";

            if (Convert.ToInt32(RemoteCall.RESTQuery(_reqSession, sql).Rows[0][0]) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 private void buttonQuery_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = RemoteCall.RESTQuery(_reqSession, this.textBoxSQL.Text);
         if ((dt != null) && (dt.Rows.Count >= 0))
         { //SQL 执行成功
             this.dataGridViewSql.DataSource = dt;
             listBoxSqlLog.Items.Add("Rows: " + dt.Rows.Count);
         }
     }
     catch (Exception err)
     {
         listBoxSqlLog.Items.Add(err.Message); //失败时,抛出错误信息
     }
 }