private void superGridControl2_CellMouseDown(object sender, GridCellMouseEventArgs e) { switch (superGridControl2.PrimaryGrid.Columns[e.GridCell.ColumnIndex].Name) { case "clmDelete": InfBalanceRecordDetail entity = commonDAO.SelfDber.Get <InfBalanceRecordDetail>(superGridControl2.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, superGridControl2.PrimaryGrid.Columns["clmId"].ColumnIndex).Value.ToString()); if (entity == null) { MessageBoxEx.Show("该记录已不存在,刷新重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBoxEx.Show("确定要删除该记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { commonDAO.SelfDber.Delete <InfBalanceRecordDetail>(entity.Id); CommonDAO.GetInstance().SaveAppletLog(eAppletLogLevel.Warn, "删除天平明细数据", string.Format("化验码:{0};坩埚号:{1};操作人:{2}", entity.AssayCode, entity.GGCode, SelfVars.LoginUser.UserName)); LoadBalanceDetailList(superGridControl2, this.CurrentAssay.Id); } catch (Exception ex) { MessageBoxEx.Show("删除失败:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } break; } }
private void superGridControl2_DataBindingComplete(object sender, GridDataBindingCompleteEventArgs e) { foreach (GridRow item in superGridControl2.PrimaryGrid.Rows) { InfBalanceRecordDetail entity = item.DataItem as InfBalanceRecordDetail; item.Cells["clmDetailStatus"].Value = entity.SyncFlag == 0 ? "未提交" : "已提交"; if (entity.SyncFlag == 1) { item.Cells["clmDetailCheck"].ReadOnly = true; } } }
/// <summary> /// 录入明细 /// </summary> /// <param name="weight"></param> /// <returns></returns> private bool JoinBalanceDetail(double weight) { if (string.IsNullOrEmpty(this.txtGGJ.Text)) { rTxtOutputer.Output("请填写坩埚架", eOutputType.Warn); return(false); } if (this.CurrentAssay == null) { rTxtOutputer.Output("请选中一条化验记录", eOutputType.Error); return(false); } string GGNo = "1"; if (commonDAO.SelfDber.Count <InfBalanceRecordDetail>("where GGJCode=:GGJCode and SyncFlag=0", new { BalanceRecordId = this.CurrentAssay.Id, GGJCode = this.txtGGJ.Text.Trim() }) >= 12) { rTxtOutputer.Output("坩埚架:" + this.txtGGJ.Text + "的坩埚已用完", eOutputType.Warn); return(false); } InfBalanceRecordDetail lastdetail = commonDAO.SelfDber.Entity <InfBalanceRecordDetail>("where GGJCode=:GGJCode and SyncFlag=0 order by to_number(GGCode) desc", new { BalanceRecordId = this.CurrentAssay.Id, GGJCode = this.txtGGJ.Text.Trim() }); if (lastdetail != null) { GGNo = (Convert.ToInt32(lastdetail.GGCode) + 1).ToString(); } InfBalanceRecordDetail detial = new InfBalanceRecordDetail(); detial.CreateUser = SelfVars.LoginUser.UserAccount; detial.OperUser = detial.CreateUser; detial.BalanceRecordId = this.CurrentAssay.Id; detial.Weight = weight; detial.AssayCode = this.CurrentAssay.AssayCode; detial.MachineCode = this.MachineCode; detial.GGCode = GGNo; detial.GGJCode = this.txtGGJ.Text.Trim(); detial.SyncFlag = 0; commonDAO.SelfDber.Insert(detial); LoadBalanceDetailList(superGridControl2, this.CurrentAssay.Id); return(true); }
private void btnSubmit_Click(object sender, EventArgs e) { List <InfBalanceRecordDetail> details = new List <InfBalanceRecordDetail>(); foreach (GridRow item in superGridControl2.PrimaryGrid.Rows) { InfBalanceRecordDetail entity = item.DataItem as InfBalanceRecordDetail; if (Convert.ToBoolean(item.Cells["clmDetailCheck"].Value)) { details.Add(entity); } } if (details.Count == 0) { MessageBoxEx.Show("请选择数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { int res = 0; SqlServerDapperDber sqlServerDapper = new SqlServerDapperDber(commonDAO.GetCommonAppletConfigString("开元天平接口数据连接字符串")); foreach (InfBalanceRecordDetail detail in details) { TPWeight weight = sqlServerDapper.Entity <TPWeight>("where S_NO=@S_NO and TP_Type=@TP_Type", new { S_NO = detail.TheBalanceRecord.AssayCode + "-" + detail.GGCode, TP_Type = detail.TheBalanceRecord.AssayType }); if (weight == null) { weight = new TPWeight(); weight.S_NO = detail.TheBalanceRecord.AssayCode + "-" + detail.GGCode; weight.TP_Type = detail.TheBalanceRecord.AssayType; weight.Weight = detail.Weight; weight.TP_NO = detail.TheBalanceRecord.MachineCode; weight.Stateop = 1; weight.SortNumber = detail.GGCode; weight.GG_NO = detail.GGCode; weight.Sample_NO = detail.TheBalanceRecord.AssayCode; weight.CreateTime = DateTime.Now; weight.Creator = detail.CreateUser; sqlServerDapper.Insert(weight); detail.SyncFlag = 1; commonDAO.SelfDber.Update(detail); res++; } else { if (MessageBoxEx.Show("该化验编码重量已提交,是否覆盖!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning) == DialogResult.OK) { weight.S_NO = detail.TheBalanceRecord.AssayCode + "-" + detail.GGCode; weight.TP_Type = detail.TheBalanceRecord.AssayType; weight.Weight = detail.Weight; weight.TP_NO = detail.TheBalanceRecord.MachineCode; weight.Stateop = 1; weight.GG_NO = detail.GGCode; weight.Sample_NO = detail.TheBalanceRecord.AssayCode; sqlServerDapper.Update(weight); res++; } } } MessageBoxEx.Show("成功提交" + res + "条数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); LoadBalanceDetailList(superGridControl2, this.CurrentAssay.Id); } catch (Exception ex) { MessageBoxEx.Show("提交失败:" + Environment.NewLine + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }