/// <summary>上传短消息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpload_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(cmbDevSN.Text)) { this.lblMsg.Visible = true; this.lblMsg.Text = "DevSN is Empty."; return; } if (null == _bll.Get(txtSmsID.Text.Trim())) { this.lblMsg.Visible = true; lblMsg.Text = "Please save first."; return; } if (string.IsNullOrEmpty(txtSmsID.Text)) { this.lblMsg.Visible = true; this.lblMsg.Text = "SmdID is Empty."; return; } if (string.IsNullOrEmpty(txtContent.Text)) { this.lblMsg.Visible = true; this.lblMsg.Text = "Content is Empty."; return; } lblMsg.Visible = false; DeviceCmdModel cmd = new DeviceCmdModel(); cmd.DevSN = cmbDevSN.Text; cmd.CommitTime = Tools.GetDateTimeNow(); string content = txtContent.Text.Trim(); string type = cmbType.SelectedValue.ToString(); string smsID = txtSmsID.Text.Trim(); int validTime = Tools.TryConvertToInt32(numValidTime.Value); string beginTime = dtpBeginTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); cmd.Content = string.Format(Commands.Command_UpdateSMS, content, type, smsID, validTime, beginTime); DeviceCmdBll cmdBll = new DeviceCmdBll(); if (type == "254") {//用户短消息 if (cmdBll.Add(cmd) >= 0) { string userID = txtUserID.Text.Trim(); cmd.Content = string.Format(Commands.Command_UpdateUserSMS, userID, smsID); } else { this.lblMsg.Visible = true; this.lblMsg.Text = "Operate fail."; return; } } this.lblMsg.Visible = true; if (cmdBll.Add(cmd) >= 0) { this.lblMsg.Text = "Operate successful."; } else { this.lblMsg.Text = "Operate fail."; } }