public ActionResult Create(ViewMachine machine) { var machines = new Machine { MachineID = machine.MachineID, SerialNumber = machine.SerialNumber, Brand = machine.Brand, Model = machine.Model, Year = machine.Year, Capacity = machine.Capacity, Status = "Available", PM = machine.PM, Calibration = machine.Calibration, CalibrationDate = machine.CalibrationDate, PMDate = machine.PMDate, Remark = machine.Remark, CreatedDate = DateTime.Now, CreatedBy = User.Identity.Name }; if (ModelState.IsValid) { db.Machines.Add(machines); db.SaveChanges(); return(RedirectToAction("Details/" + machines.Id)); } return(View(machine)); }
public ActionResult Edit(ViewMachine machine) { var machines = new Machine { Id = machine.Id, MachineID = machine.MachineID, SerialNumber = machine.SerialNumber, Brand = machine.Brand, Model = machine.Model, Year = machine.Year, Capacity = machine.Capacity, Status = machine.Status, PM = machine.PM, Calibration = machine.Calibration, CalibrationDate = machine.CalibrationDate, PMDate = machine.PMDate, Remark = machine.Remark, UpdatedBy = User.Identity.Name, UpdatedDate = DateTime.Now }; if (ModelState.IsValid) { db.Entry(machines).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details/" + machines.Id)); } return(View(machines)); }
/// <summary> /// 设置对象值 /// </summary> /// <param name="matchMachine"></param> public void SetMatchMachine(RC_MatchMachine matchMachine) { try { if (matchMachine == null) { m_cutRow = this.ViewMachine.FocusedRowHandle; if (m_cutRow < 0) { return; } DataRow dw = ViewMachine.GetDataRow(m_cutRow); int MatchMachineID = int.Parse(dw["MatchMachineID"].ToString()); matchMachine = MatchMachineBLL.GetModel(MatchMachineID); if (matchMachine == null) { return; } } this.txt_MachineID.Text = matchMachine.MatchMachineID.ToString(); this.txt_MachineName.Text = matchMachine.MatchMachineName; foreach (object item in this.ddl_BourseType.Properties.Items) { if (((UComboItem)item).ValueIndex == matchMachine.BourseTypeID) { this.ddl_BourseType.SelectedItem = item; break; } } foreach (object item in this.ddl_Center.Properties.Items) { if (((UComboItem)item).ValueIndex == matchMachine.MatchCenterID) { this.ddl_Center.SelectedItem = item; break; } } } catch (Exception ex) { string errCode = "GL-2022"; string errMsg = "设置对象值失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); throw; } }
private void btn_AssignCode_Click(object sender, EventArgs e) { if (this.ViewMachine != null && this.ViewMachine.FocusedRowHandle >= 0) { m_cutRow = this.ViewMachine.FocusedRowHandle; DataRow dw = ViewMachine.GetDataRow(m_cutRow); int MatchMachineID = int.Parse(dw["MatchMachineID"].ToString()); MatchMachine = MatchMachineBLL.GetModel(MatchMachineID); CodeAssign code = new CodeAssign(); code.MatchMachine = MatchMachine; code.ShowDialog(); } else { ShowMessageBox.ShowInformation("请选中记录行!"); } }
/// <summary> /// 表格单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gridCenter_Click(object sender, EventArgs e) { DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hi = this.ViewMachine.CalcHitInfo(((Control)sender).PointToClient(Control.MousePosition)); if (this.ViewMachine != null && this.ViewMachine.FocusedRowHandle >= 0 && hi.RowHandle >= 0) { m_cutRow = this.ViewMachine.FocusedRowHandle; DataRow dw = ViewMachine.GetDataRow(m_cutRow); int MatchMachineID = int.Parse(dw["MatchMachineID"].ToString()); MatchMachine = MatchMachineBLL.GetModel(MatchMachineID); SetMatchMachine(MatchMachine); } //else //{ // ShowMessageBox.ShowInformation("请选中记录行"); //} }
/// <summary> /// 删除按纽事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Del_Click(object sender, EventArgs e) { try { if (ShowMessageBox.ShowQuestion("确认删除吗?") == DialogResult.No) { return; } if (this.ViewMachine != null && this.ViewMachine.FocusedRowHandle >= 0) { m_cutRow = this.ViewMachine.FocusedRowHandle; //MachineUpdate(m_cutRow); DataRow dw = ViewMachine.GetDataRow(m_cutRow); int MatchMachineID = int.Parse(dw["MatchMachineID"].ToString()); if (MatchMachineBLL.Delete(MatchMachineID)) { ShowMessageBox.ShowInformation("删除成功!"); Init(); } else { ShowMessageBox.ShowInformation("删除失败!"); } } else { ShowMessageBox.ShowInformation("请选中记录行!"); } } catch (Exception ex) { ShowMessageBox.ShowInformation("删除失败!"); string errCode = "GL-2020"; string errMsg = "删除失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); } }