/// <summary> /// 修改扭矩防错信息 /// </summary> /// <param name="id">序号</param> /// <param name="failSafe">扭矩防错</param> /// <param name="error">错误信息</param> /// <returns>添加成功返回True失败返回False</returns> public bool UpdateFailsafe(int id, ZPX_OfflineFailsafe failSafe, out string error) { error = ""; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from a in dataContxt.ZPX_OfflineFailsafe where a.ID == id select a; dataContxt.ZPX_OfflineFailsafe.DeleteAllOnSubmit(result); dataContxt.ZPX_OfflineFailsafe.InsertOnSubmit(failSafe); dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
private void 除toolStripButton_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 1) { if (MessageDialog.ShowEnquiryMessage("确定删除选中的信息吗?") == DialogResult.Yes) { ZPX_OfflineFailsafe failsafe = new ZPX_OfflineFailsafe(); failsafe.GoodsCode = txtGoodsCode.Text.Trim(); failsafe.GoodsName = txtGoodsName.Text.Trim(); failsafe.Spec = txtSpec.Text.Trim(); failsafe.Type = cmbType.Text; failsafe.ProductType = cmbProductType.Text; failsafe.Phase = dataGridView1.CurrentRow.Cells["阶段"].Value.ToString(); failsafe.SourceProductType = dataGridView1.CurrentRow.Cells["分装总成"].Value.ToString(); failsafe.PositionMessage = dataGridView1.CurrentRow.Cells["位置信息"].Value.ToString(); if (!m_offlineFailServer.DeleteFailSafe(failsafe.ProductType, failsafe.SourceProductType, failsafe.GoodsCode, failsafe.GoodsName, failsafe.Spec, failsafe.Phase, failsafe.PositionMessage, out m_error)) { MessageDialog.ShowPromptMessage(m_error); return; } m_sysLogServer.RecordLog <ZPX_OfflineFailsafe>(CE_OperatorMode.除, failsafe, failsafe); RefreshDataGridView(); } } else { MessageDialog.ShowPromptMessage("请选中一行数据再进行操作!"); } }
private void btnAdd_Click(object sender, EventArgs e) { if (!CheckControl()) { return; } ZPX_OfflineFailsafe failSafe = new ZPX_OfflineFailsafe(); failSafe.GoodsCode = txtGoodsCode.Text; failSafe.GoodsName = txtGoodsName.Text; failSafe.IsDistinguish = cbIsDistinguish.Checked; failSafe.Message = txtMessage.Text; failSafe.NumCount = (int)numNumCount.Value; if (cmbType.SelectedIndex == 0) { failSafe.Phase = cmbPhase.Text; failSafe.SourceProductType = ""; } else { failSafe.SourceProductType = cmbParentName.Text; failSafe.Phase = ""; } failSafe.PositionMessage = txtPositionMessage.Text; failSafe.ProductType = cmbProductType.Text; failSafe.Recorder = BasicInfo.LoginID; failSafe.RecordTime = ServerTime.Time; failSafe.Spec = txtSpec.Text; failSafe.Torque = (int)numTorque.Value; failSafe.Type = cmbType.Text; int orderNo = m_offlineFailServer.GetOrderNoMax(cmbType.Text, cmbProductType.Text, failSafe.SourceProductType, failSafe.Phase); failSafe.OrderNo = ++orderNo; if (!m_offlineFailServer.InsertFailsafe(failSafe, out m_error)) { MessageDialog.ShowPromptMessage(m_error); return; } MessageDialog.ShowPromptMessage("添加成功!"); m_sysLogServer.RecordLog <ZPX_OfflineFailsafe>(CE_OperatorMode.添加, failSafe, failSafe); RefreshDataGridView(); }
/// <summary> /// 添加扭矩防错信息 /// </summary> /// <param name="failSafe">扭矩防错</param> /// <param name="error">错误信息</param> /// <returns>添加成功返回True失败返回False</returns> public bool InsertFailsafe(ZPX_OfflineFailsafe failSafe, out string error) { error = ""; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from a in dataContxt.ZPX_OfflineFailsafe where a.ProductType == failSafe.ProductType && a.GoodsCode == failSafe.GoodsCode && a.GoodsName == a.GoodsName && a.Spec == failSafe.Spec && a.PositionMessage == failSafe.PositionMessage && a.SourceProductType == failSafe.SourceProductType && a.Phase == failSafe.Phase select a; if (result.Count() == 0) { dataContxt.ZPX_OfflineFailsafe.InsertOnSubmit(failSafe); } else { dataContxt.ZPX_OfflineFailsafe.DeleteAllOnSubmit(result); dataContxt.ZPX_OfflineFailsafe.InsertOnSubmit(failSafe); } dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 复制指定的产品型号信息到目标产品 /// </summary> /// <param name="surProductType">源产品类型</param> /// <param name="tarProductType">目标产品类型</param> /// <param name="phase">阶段</param> /// <param name="error">操作错误时返回的错误信息</param> /// <returns>复制成功返回True,复制失败返回False</returns> public bool CopyFailsafe(string surProductType, string tarProductType, string phase, out string error) { try { error = null; DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var source = from r in ctx.ZPX_OfflineFailsafe where r.ProductType == surProductType && (r.Phase == phase || r.SourceProductType == phase) select r; if (source.Count() == 0) { error = string.Format("{0} 的 {1} 阶段不存在扭矩防错零件信息,无法进行此操作", surProductType, phase); return(false); } var target = from r in ctx.ZPX_OfflineFailsafe where r.ProductType == tarProductType && (r.Phase == phase || r.SourceProductType == phase) select r; if (target.Count() > 0) { error = string.Format("{0} 的 {1} 阶段存在扭矩防错零件信息,无法进行此操作", tarProductType, phase); return(false); } string login = BasicInfo.LoginID; DateTime time = ServerTime.Time; foreach (var item in source) { ZPX_OfflineFailsafe targetFailsafe = new ZPX_OfflineFailsafe(); targetFailsafe.OrderNo = item.OrderNo; targetFailsafe.GoodsCode = item.GoodsCode; targetFailsafe.GoodsName = item.GoodsName; targetFailsafe.IsDistinguish = item.IsDistinguish; targetFailsafe.Message = item.Message; targetFailsafe.NumCount = item.NumCount; targetFailsafe.Phase = item.Phase; targetFailsafe.PositionMessage = item.PositionMessage; targetFailsafe.ProductType = tarProductType; targetFailsafe.Recorder = login; targetFailsafe.RecordTime = time; targetFailsafe.SourceProductType = item.SourceProductType; targetFailsafe.Spec = item.Spec; targetFailsafe.Torque = item.Torque; targetFailsafe.Type = item.Type; ctx.ZPX_OfflineFailsafe.InsertOnSubmit(targetFailsafe); } ctx.SubmitChanges(); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
private void 修改toolStripButton_Click(object sender, EventArgs e) { if (!CheckControl()) { return; } DataGridViewRow row = dataGridView1.CurrentRow; ZPX_OfflineFailsafe oldFailsafe = new ZPX_OfflineFailsafe(); oldFailsafe.GoodsCode = row.Cells["图号型号"].Value.ToString(); oldFailsafe.GoodsName = row.Cells["物品名称"].Value.ToString(); oldFailsafe.IsDistinguish = Convert.ToBoolean(row.Cells["是否手动判别"].Value); oldFailsafe.Message = row.Cells["提示"].Value.ToString(); oldFailsafe.NumCount = Convert.ToInt32(row.Cells["数量"].Value); oldFailsafe.PositionMessage = row.Cells["位置信息"].Value.ToString(); oldFailsafe.ProductType = row.Cells["产品型号"].Value.ToString(); oldFailsafe.Recorder = BasicInfo.LoginID; oldFailsafe.RecordTime = ServerTime.Time; oldFailsafe.Spec = row.Cells["规格"].Value.ToString(); oldFailsafe.Torque = Convert.ToInt32(row.Cells["扭矩大小"].Value); oldFailsafe.Type = row.Cells["返修类型"].Value.ToString(); oldFailsafe.Phase = row.Cells["阶段"].Value == DBNull.Value ? null : row.Cells["阶段"].Value.ToString(); oldFailsafe.SourceProductType = row.Cells["分装总成"].Value == DBNull.Value ? null : row.Cells["分装总成"].Value.ToString(); ZPX_OfflineFailsafe failSafe = new ZPX_OfflineFailsafe(); failSafe.GoodsCode = txtGoodsCode.Text; failSafe.GoodsName = txtGoodsName.Text; failSafe.IsDistinguish = cbIsDistinguish.Checked; failSafe.Message = txtMessage.Text; failSafe.NumCount = (int)numNumCount.Value; if (cmbType.SelectedIndex == 0) { failSafe.Phase = cmbPhase.Text; failSafe.SourceProductType = ""; } else { failSafe.SourceProductType = cmbParentName.Text; failSafe.Phase = ""; } failSafe.PositionMessage = txtPositionMessage.Text; failSafe.ProductType = cmbProductType.Text; failSafe.Recorder = BasicInfo.LoginID; failSafe.RecordTime = ServerTime.Time; failSafe.Spec = txtSpec.Text; failSafe.Torque = (int)numTorque.Value; failSafe.Type = cmbType.Text; failSafe.OrderNo = Convert.ToInt32(dataGridView1.CurrentRow.Cells["防错顺序"].Value); if (!m_offlineFailServer.UpdateFailsafe(Convert.ToInt32(dataGridView1.CurrentRow.Cells["序号"].Value), failSafe, out m_error)) { MessageDialog.ShowPromptMessage(m_error); return; } MessageDialog.ShowPromptMessage("修改成功!"); m_sysLogServer.RecordLog <ZPX_OfflineFailsafe>(CE_OperatorMode.修改, failSafe, oldFailsafe); RefreshDataGridView(); }