private void superGridControl1_CellMouseDown(object sender, GridCellMouseEventArgs e) { switch (superGridControl1.PrimaryGrid.Columns[e.GridCell.ColumnIndex].Name) { case "clmDelete": InfBalanceRecord entity = commonDAO.SelfDber.Get <InfBalanceRecord>(superGridControl1.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, superGridControl1.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.DeleteBySQL <InfBalanceRecordDetail>("where BalanceRecordId=:BalanceRecordId", new { BalanceRecordId = entity.Id }); commonDAO.SelfDber.Delete <InfBalanceRecord>(entity.Id); CommonDAO.GetInstance().SaveAppletLog(eAppletLogLevel.Warn, "删除天平数据", string.Format("化验码:{0};操作人:{1}", entity.AssayCode, SelfVars.LoginUser.UserName)); LoadBalanceList(superGridControl1); } catch (Exception ex) { MessageBoxEx.Show("该记录正在使用中,禁止删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } break; } }
/// <summary> /// 录入化验数据 /// </summary> /// <param name="assayCode"></param> /// <returns></returns> private bool JoinBalance(string assayCode) { InfBalanceRecord entity = commonDAO.SelfDber.Entity <InfBalanceRecord>("where AssayCode=:AssayCode and MachineCode=:MachineCode order by CreateDate desc", new { AssayCode = assayCode, MachineCode = this.MachineCode }); if (entity == null) { entity = new InfBalanceRecord(); entity.CreateUser = SelfVars.LoginUser.UserAccount; entity.OperUser = entity.CreateUser; entity.MachineCode = this.MachineCode; entity.AssayCode = assayCode; entity.AssayType = ((ComboBoxItem)cmbType.SelectedItem).Name; commonDAO.SelfDber.Insert(entity); } else { entity.OperDate = DateTime.Now; entity.OperUser = entity.CreateUser; entity.MachineCode = this.MachineCode; entity.AssayType = ((ComboBoxItem)cmbType.SelectedItem).Name; commonDAO.SelfDber.Update(entity); } LoadBalanceList(superGridControl1); this.CurrentAssay = entity; return(true); }
/// <summary> /// 录入化验数据 /// </summary> /// <param name="assayCode"></param> /// <returns></returns> private bool JoinBalance(string content) { string[] pars = content.Split('|'); if (pars.Length != 4) { return(false); } InfBalanceRecord entity = commonDAO.SelfDber.Entity <InfBalanceRecord>("where AssayCode=:AssayCode and MachineCode=:MachineCode and GGCode=:GGCode order by CreateDate desc", new { AssayCode = pars[1], MachineCode = pars[0], GGCode = pars[2] }); if (entity == null) { entity = new InfBalanceRecord(); entity.CreateUser = SelfVars.LoginUser.UserAccount; entity.OperUser = SelfVars.LoginUser.UserAccount; entity.MachineCode = pars[0]; entity.AssayCode = pars[1]; entity.GGCode = pars[2]; entity.Weight = Convert.ToDouble(pars[3]); commonDAO.SelfDber.Insert(entity); LoadBalanceList(superGridControl1); } this.txtInputAssayCode.Text = ""; LoadBalanceList(superGridControl1); return(true); }
private void superGridControl1_DataBindingComplete(object sender, GridDataBindingCompleteEventArgs e) { //第一次加载时选中第一条 foreach (GridRow item in superGridControl1.PrimaryGrid.Rows) { InfBalanceRecord entity = item.DataItem as InfBalanceRecord; } }
private void superGridControl1_Click(object sender, EventArgs e) { GridRow gridRow = (superGridControl1.ActiveRow as GridRow); InfBalanceRecord balanceRecord = gridRow.DataItem as InfBalanceRecord; if (!string.IsNullOrEmpty(balanceRecord.AssayCode)) { this.CurrentAssay = balanceRecord; } }
private void superGridControl1_DataBindingComplete(object sender, GridDataBindingCompleteEventArgs e) { //第一次加载时选中第一条 foreach (GridRow item in superGridControl1.PrimaryGrid.Rows) { InfBalanceRecord entity = item.DataItem as InfBalanceRecord; if (entity.Id == this.CurrentAssay.Id) { item.Cells["clmCheck"].Value = 1; } else { item.Cells["clmCheck"].Value = 0; } } }