Ejemplo n.º 1
0
    private void LoadDefault()
    {
        var idStr = Request["id"];

        if (string.IsNullOrEmpty(idStr))
        {
            return;
        }

        if (int.TryParse(Request["id"], out id))
        {
            Row = tbl_troneItem.GetRowById(dBase, id);
        }

        if (Row == null)
        {
            form1.Controls.Clear();
            form1.InnerHtml = "<h1>ID无效!</h1>";
            return;
        }
        if (IsPostBack)
        {
            return;
        }
        ddlSpId.Items.SelectByValue(Row.sp_id.ToString());

        txttrone_num.Text      = Row.trone_num;
        txtorders.Text         = Row.orders;
        txttrone_name.Text     = Row.trone_name;
        txtPrice.Text          = Row.price.ToString("0.00");
        chkdymaic.Checked      = Row.is_dynamic;
        chkmatch_price.Checked = Row.match_price;
        this.chkstatus.Checked = Row.status == 0;
    }
Ejemplo n.º 2
0
    private string SaveData()
    {
        bool isNew = Row == null;

        if (isNew)
        {
            Row               = new tbl_troneItem();
            Row.sp_id         = int.Parse(ddlSpId.SelectedValue);
            Row.sp_api_url_id = int.Parse(ddlUrlId.SelectedValue);
        }



        Row.trone_num  = txttrone_num.Text;
        Row.orders     = txtorders.Text;
        Row.trone_name = txttrone_name.Text;
        Row.status     = chkstatus.Checked ? 0 : 1;

        Row.is_dynamic  = chkdymaic.Checked;
        Row.match_price = chkmatch_price.Checked;

        decimal fee;

        if (!decimal.TryParse(txtPrice.Text, out fee))
        {
            return("输入的价格无法识别");
        }
        Row.price = fee;
        if (string.IsNullOrEmpty(Row.trone_name))
        {
            return("业务名称不能为空");
        }
        if (string.IsNullOrEmpty(Row.trone_num))
        {
            return("通道号不能为空");
        }

        try
        {
            Row.SaveToDatabase(dBase);
        }
        catch (Exception ex)
        {
            return("保存出错\n" + ex.Message);
        }
        return(null);
    }