private bool SaveDeviceDate(Models.DeviceData data) { Models.ProjectDetails ProjectDetail = data.ProjectDetail; if (SaveProjectDetails(ProjectDetail)) { /* * 读卡数据处理逻辑 */ return(dataBll.Create(data).ExcuteState); } return(false); }
private void button1_Click(object sender, EventArgs e) { //Task.Factory.StartNew(() => //{ if (yanzhengGroupText()) { Models.ProjectDetails details = detailsBLL.GetModel(this.comboBox4.SelectedValue.ToString()); //details.DeviceDataList = new List<Models.DeviceData>(); BLL.DeviceDataBLL DeviceDataBLL = new BLL.DeviceDataBLL(); List <string> list = new List <string>() { "A", "B", "C", "D", "E", "F", "G", "H", "I" }; int n = (this.GroupInfo.SelectedIndex + 1) * 3; bool ifSuccess = true; string CreateDataStr = DateTime.Now.ToString("yyyyMMddHHmmss"); string CreateDataStrGroup = ""; int m = this.GroupTextlist.Where(p => !string.IsNullOrWhiteSpace(p.Text)).Count(); int a = m / 3; int b = m % 3; //if (a == 0) //{ // DialogResult dr = MessageBox.Show("至少需要填写一组数据,是否继续","提示",MessageBoxButtons.OKCancel ); // if (dr != DialogResult.OK) // { // MoveToNextText(); // return; // } //} if (b != 0) { string messagestr = ""; if (this.GroupInfo.SelectedIndex == 0) { if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0) { messagestr += "第一组数据不完整,是否继续提交绑定\r\n\r\n"; } } else if (this.GroupInfo.SelectedIndex == 1) { if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0) { messagestr += "第一组数据不完整,是否继续提交绑定\r\n\r\n"; } if (textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox6.Text.Length == 0) { messagestr += "第二组数据不完整,是否继续提交绑定\r\n\r\n"; } } else if (this.GroupInfo.SelectedIndex == 2) { if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0) { messagestr += "第一组数据不完整,是否继续提交绑定\r\n\r\n"; } if (textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox6.Text.Length == 0) { messagestr += "第二组数据不完整,是否继续提交绑定\r\n\r\n"; } if (textBox7.Text.Length == 0 || textBox8.Text.Length == 0 || textBox9.Text.Length == 0) { messagestr += "第三组数据不完整,是否继续提交绑定\r\n\r\n"; } } DialogResult dr = MyDialogOption.show("提示", messagestr, "是,继续完成绑定", "否,返回补充完整"); // DialogResult dr = MessageBoxEx.Show("数据不完整,是否继续提交绑定", "提示", MessageBoxButtons.OKCancel, new string[] { "是,继续完成绑定", "否,返回补充完整" }); // DialogResult dr = MessageBox.Show("数据不完整,是否继续提交绑定?", "确认", MessageBoxButtons.OKCancel); if (dr != DialogResult.OK) { MoveToNextText(); return; } } for (int i = 0; i < n; i++) { if (list[i] == "A" || list[i] == "B" || list[i] == "C") { CreateDataStrGroup = CreateDataStr + "A"; } else if (list[i] == "D" || list[i] == "E" || list[i] == "F") { CreateDataStrGroup = CreateDataStr + "B"; } else { CreateDataStrGroup = CreateDataStr + "C"; } Models.DeviceData deviceData = new Models.DeviceData() { DataId = this.comboBox4.SelectedValue.ToString() + "_" + list[i] + "_" + Utils.getGUID(), DeviceValue = this.GroupTextlist[i].Text, GroupName = list[i], ProjectDetailId = this.comboBox4.SelectedValue.ToString(), Instar = this.Instar.SelectedItem.ToString(), YangSheng = this.yangsheng.SelectedItem.ToString(), SamplingDate = this.SamplingDate.Value.ToString("yyyy-MM-dd"), CreateDate = CreateDataStrGroup, IfUpload = 0, NotUploadReason = "网络" }; if (!Regex.IsMatch(deviceData.DeviceValue, "^\\d{15}$")) { continue; } //判断重复 if (DeviceDataBLL.GetModelByWhere(" DeviceValue='" + deviceData.DeviceValue + "'") != null) { MessageBox.Show("绑定数据库中已经存在[" + deviceData.DeviceValue + "]RFID编号请核实!"); return; } BLL.FunctionResult result = DeviceDataBLL.Create(deviceData); if (!result.ExcuteState) { ifSuccess = false; break; } this.DeviceDataTotal++; setProcess(); this.DetailsForUpload.Enqueue(deviceData); } if (ifSuccess) { details.DetailState = 1; this.Invoke(new EventHandler((aa, bb) => { MessageBox.Show("绑定数据完成!"); resetTextBox(); MoveToNextText(); })); } } //}); }