public bool UpdateRecord(MachinePrepareItem_mpit_Info infoObject) { bool isSuccess = false; try { using (MainDBDataContext db = new MainDBDataContext()) { //MachinePrepareItem_mpit query = db.MachinePrepareItem_mpit.SingleOrDefault(t => t.aod_RecordID == infoObject.aod_RecordID); MachinePrepareItem_mpit query = db.MachinePrepareItem_mpit.SingleOrDefault(t=>t.mpit_PIPFID ==infoObject.mpit_PIPFID ); if (query != null) { //query.aod_cName = infoObject.aod_cName; //query.aod_dOffDutyTime = infoObject.aod_dOffDutyTime; //query.aod_iShiftTypeID = infoObject.aod_iShiftTypeID; //query.aod_lIsAtive = infoObject.aod_lIsAtive; //query.aod_cLast = infoObject.aod_cLast; //query.aod_dLastDate = infoObject.aod_dLastDate; //Common.General.SetDataToLingQEntity<MachinePrepareItem_mpit>(query, infoObject); db.SubmitChanges(); isSuccess = true; } } } catch (Exception Ex) { throw Ex; } return isSuccess; }
public bool DeleteRecord(Model.IModel.IModelObject KeyObject) { bool isSuccess = false; MachinePrepareItem_mpit_Info info = new MachinePrepareItem_mpit_Info(); info = KeyObject as MachinePrepareItem_mpit_Info; try { using (MainDBDataContext db = new MainDBDataContext()) { //MachinePrepareItem_mpit delTab = db.MachinePrepareItem_mpit.SingleOrDefault(t => t.aod_iRecordID == info.aod_iRecordID && t.aod_lIsDeleted == false); //MachinePrepareItem_mpit delTab = db.MachinePrepareItem_mpit.SingleOrDefault(t => t.aod_RecordID == info.aod_RecordID && t.aod_lIsAtive == true); MachinePrepareItem_mpit delTab = db.MachinePrepareItem_mpit.SingleOrDefault(t => t.mpit_PIPFID == info.mpit_PIPFID ); if (delTab != null) { //delTab.aod_lIsDeleted = true; db.MachinePrepareItem_mpit.DeleteOnSubmit(delTab); //delTab.aod_lIsAtive = false; db.SubmitChanges(); isSuccess = true; } } } catch (Exception Ex) { throw Ex; } return isSuccess; }
public bool InsertRecord(MachinePrepareItem_mpit_Info infoObject) { bool isSuccess = false; try { using (MainDBDataContext db = new MainDBDataContext()) { MachinePrepareItem_mpit newTab = Common.General.CopyObjectValue<MachinePrepareItem_mpit_Info, MachinePrepareItem_mpit>(infoObject); db.MachinePrepareItem_mpit.InsertOnSubmit(newTab); db.SubmitChanges(); isSuccess = true; } } catch (Exception Ex) { throw Ex; } return isSuccess; }
public bool IsExistRecord(object KeyObject) { bool isExist = false; MachinePrepareItem_mpit_Info info = new MachinePrepareItem_mpit_Info(); info = KeyObject as MachinePrepareItem_mpit_Info; try { using (MainDBDataContext db = new MainDBDataContext()) { //MachinePrepareItem_mpit query = db.MachinePrepareItem_mpit.SingleOrDefault(t => t.aod_iRecordID == info.aod_iRecordID && t.aod_lIsDeleted == false); //MachinePrepareItem_mpit query = db.MachinePrepareItem_mpit.SingleOrDefault(t => t.aod_RecordID == info.aod_RecordID && t.aod_lIsAtive == true); MachinePrepareItem_mpit query = db.MachinePrepareItem_mpit.SingleOrDefault(t => t.mpit_PIPFID == info.mpit_PIPFID && t.mpit_lIsDeleted == true); if (query != null) { isExist = true; } } } catch (Exception Ex) { throw Ex; } return isExist; }
private void btnSave_Click(object sender, EventArgs e) { string readyIDList = ""; string machineIDList = ""; if (tabControl1.SelectedTab == tabPage1) { //if (lvMachineMain.SelectedItems.Count > 0) //{ //int DCMPID = int.Parse(lvMachineMain.SelectedItems[0].SubItems[0].Text.ToString()); //int iMachineType = int.Parse(lvMachineMain.SelectedItems[0].SubItems[4].Text.ToString()); //獲取選中的準備項 List<MachinePrepareItem_mpit_Info> ReaderList = new List<MachinePrepareItem_mpit_Info>(); for (int i = 0; i < lvReadySelect.Items.Count; i++) { //readyIDList = readyIDList + lvReadySelect.Items[i].SubItems[0].Text.ToString() + ","; MachinePrepareItem_mpit_Info insertItem = new MachinePrepareItem_mpit_Info(); insertItem.mpit_cDCMPID = recordDCMPID; insertItem.mpit_PIPFID = new Guid(lvReadySelect.Items[i].SubItems[0].Text.ToString()); insertItem.mpit_lIsDeleted = false; insertItem.mpit_dUpdateTime = DateTime.Now; ReaderList.Add(insertItem); } _MachineReadyPlanBL.SavePPByMachie(recordDCMPID, ReaderList); btnSave.Enabled = false; //if (readyIDList != "") //{ // readyIDList = readyIDList.Remove(readyIDList.LastIndexOf(","), 1); //} ////保存準備項 SAVE ////bool a = manager.HasSelectReadyInsert(recordDCMPID, readyIDList); //btnSave.Enabled = false; //} //else { // MessageBox.Show("請選擇機器項!"); // //tabControl1.SelectedTab = tabPage1; // btnSave.Enabled = false; //} } if (tabControl1.SelectedTab == tabPage2) { //if (lvReadyMain.SelectedItems.Count > 0) //{ //int PIPFID = int.Parse(lvReadyMain.SelectedItems[0].SubItems[0].Text.ToString()); // int iMachineType = int.Parse(lvReadyMain.SelectedItems[0].SubItems[4].Text.ToString()); //獲取選中的準備項 List<MachinePrepareItem_mpit_Info> machinelist = new List<MachinePrepareItem_mpit_Info>(); for (int i = 0; i < lvMachineSelect.Items.Count; i++) { //machineIDList = machineIDList + lvMachineSelect.Items[i].SubItems[0].Text.ToString() + ","; MachinePrepareItem_mpit_Info insertItem = new MachinePrepareItem_mpit_Info(); insertItem.mpit_cDCMPID = lvMachineSelect.Items[i].SubItems[0].Text.ToString(); ; insertItem.mpit_PIPFID = recordPIPFID; insertItem.mpit_lIsDeleted = false; insertItem.mpit_dUpdateTime = DateTime.Now; machinelist.Add(insertItem); } _MachineReadyPlanBL.SavePPByPPID(recordPIPFID, machinelist); btnSave.Enabled = false; //if (machineIDList != "") //{ // machineIDList = machineIDList.Remove(machineIDList.LastIndexOf(","), 1); //} ////保存準備項 //bool a = manager.HasSelectMachineInsert(recordPIPFID, machineIDList); //btnSave.Enabled = false; //} //else //{ // MessageBox.Show("請選擇準備項!"); // //tabControl1.SelectedTab = tabPage2; // btnSave.Enabled = false; //} } }
public MachinePrepareItem_mpit_Info DisplayRecord(Model.IModel.IModelObject KeyObject) { MachinePrepareItem_mpit_Info info = new MachinePrepareItem_mpit_Info(); info = KeyObject as MachinePrepareItem_mpit_Info; try { using (MainDBDataContext db = new MainDBDataContext()) { //MachinePrepareItem_mpit disTab = db.MachinePrepareItem_mpit.SingleOrDefault(t => t.aod_iRecordID == info.aod_iRecordID && t.aod_lIsDeleted == false); MachinePrepareItem_mpit disTab = db.MachinePrepareItem_mpit.SingleOrDefault(t => t.mpit_PIPFID == info.mpit_PIPFID ); if (disTab != null) { info = Common.General.CopyObjectValue<MachinePrepareItem_mpit, MachinePrepareItem_mpit_Info>(disTab); } } } catch (Exception Ex) { throw Ex; } return info; }
/// <summary> /// 機台準備項 /// </summary> public List<MachinePrepareItem_mpit_Info> GetMachinePrepareItemMapping(string machineID) { try { List<MachinePrepareItem_mpit_Info> list = new List<MachinePrepareItem_mpit_Info>(); StringBuilder strSql = new StringBuilder(); strSql.AppendLine("select"); strSql.AppendLine("mpit_MPITID,mpit_PIPFID,mpit_cDCMPID,mpit_lIsDeleted,mpit_dUpdateTime "); strSql.AppendLine("from MachinePrepareItem_mpit "); strSql.AppendLine("where mpit_cDCMPID='" + machineID.Trim() + "' "); strSql.AppendLine("and mpit_lIsDeleted=0" ); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { MachinePrepareItem_mpit_Info model = new MachinePrepareItem_mpit_Info(); if (sdr["mpit_MPITID"] != null && sdr["mpit_MPITID"].ToString() != "") { model.mpit_MPITID = new Guid(sdr["mpit_MPITID"].ToString()); } if (sdr["mpit_PIPFID"] != null && sdr["mpit_PIPFID"].ToString() != "") { model.mpit_PIPFID = new Guid(sdr["mpit_PIPFID"].ToString()); } if (sdr["mpit_cDCMPID"] != null && sdr["mpit_cDCMPID"].ToString() != "") { model.mpit_cDCMPID = sdr["mpit_cDCMPID"].ToString(); } if (sdr["mpit_lIsDeleted"] != null && sdr["mpit_lIsDeleted"].ToString() != "") { if ((sdr["mpit_lIsDeleted"].ToString() == "1") || (sdr["mpit_lIsDeleted"].ToString().ToLower() == "true")) { model.mpit_lIsDeleted = true; } else { model.mpit_lIsDeleted = false; } } if (sdr["mpit_dUpdateTime"] != null && sdr["mpit_dUpdateTime"].ToString() != "") { model.mpit_dUpdateTime = DateTime.Parse(sdr["mpit_dUpdateTime"].ToString()); } list.Add(model); } } return list; } catch (Exception ex) { throw ex; } }
bool IMachineReadyPlanBL.SavePPByMachie(string Machine, List<MachinePrepareItem_mpit_Info> PPList) { //throw new NotImplementedException(); bool returnValue = true; if (PPList == null) return true; if (Machine.Trim().Length == 0) return true; try { _MachineReadyPlanDA.DeleteListByMachie(Machine); //List<MachinePrepareItem_mpit_Info> hadSelet = _MachineReadyPlanDA.GetPrepareProjectsByMachine(Machine); foreach (MachinePrepareItem_mpit_Info item in PPList) { MachinePrepareItem_mpit_Info insertItem = new MachinePrepareItem_mpit_Info(); insertItem.mpit_cDCMPID = Machine; insertItem.mpit_PIPFID = item.mpit_PIPFID; insertItem.mpit_lIsDeleted = false; insertItem.mpit_dUpdateTime = DateTime.Now; insertItem.mpit_MPITID = Guid.NewGuid(); returnValue = _MachineReadyPlanDA.InsertRecord(insertItem); } } catch (Exception Ex) { throw Ex; } return returnValue; }
public bool SavePPByPPID(Guid PProject, List<MachinePrepareItem_mpit_Info> MCList) { //throw new NotImplementedException(); //throw new NotImplementedException(); bool returnValue = true; if (MCList == null) return true; if (PProject==Guid.Empty ) return true; try { _MachineReadyPlanDA.DeleteListByPPID(PProject); //List<MachinePrepareItem_mpit_Info> hadSelet = _MachineReadyPlanDA.GetPrepareProjectsByMachine(Machine); foreach (MachinePrepareItem_mpit_Info item in MCList) { MachinePrepareItem_mpit_Info insertItem = new MachinePrepareItem_mpit_Info(); insertItem.mpit_cDCMPID = item.mpit_cDCMPID; insertItem.mpit_PIPFID = PProject; insertItem.mpit_lIsDeleted = false; insertItem.mpit_dUpdateTime = DateTime.Now; insertItem.mpit_MPITID = Guid.NewGuid(); returnValue = _MachineReadyPlanDA.InsertRecord(insertItem); } } catch (Exception Ex) { throw Ex; } return returnValue; }
public Model.General.ReturnValueInfo Save(Model.IModel.IModelObject itemEntity, Common.DefineConstantValue.EditStateEnum EditMode) { Model.General.ReturnValueInfo returnValue = new Model.General.ReturnValueInfo(); MachinePrepareItem_mpit_Info info = new MachinePrepareItem_mpit_Info(); returnValue.messageText = ""; info = itemEntity as MachinePrepareItem_mpit_Info; try { switch (EditMode) { case Common.DefineConstantValue.EditStateEnum.OE_Insert: bool isExist = false; info.mpit_MPITID = Guid.NewGuid(); returnValue.boolValue = _MachineReadyPlanDA.InsertRecord(info); //isExist = _MachineReadyPlanDA.IsExistRecord(info); //if (!isExist) //{ // returnValue.boolValue = _MachineReadyPlanDA.InsertRecord(info); //} //else //{ // returnValue.boolValue = false; // returnValue.messageText = "數據重複!"; //} break; case Common.DefineConstantValue.EditStateEnum.OE_Update: returnValue.boolValue = _MachineReadyPlanDA.UpdateRecord(info); break; case Common.DefineConstantValue.EditStateEnum.OE_Delete: returnValue.boolValue = _MachineReadyPlanDA.DeleteRecord(info); break; } } catch (Exception Ex) { throw Ex; } return returnValue; }
private string GetMachinePrepareItemSQL(MachinePrepareItem_mpit_Info model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.mpit_MPITID != null) { strSql1.Append("mpit_MPITID,"); strSql2.Append("'" + model.mpit_MPITID + "',"); } if (model.mpit_PIPFID != null) { strSql1.Append("mpit_PIPFID,"); strSql2.Append("'" + model.mpit_PIPFID + "',"); } if (model.mpit_cDCMPID != null) { strSql1.Append("mpit_cDCMPID,"); strSql2.Append("'" + model.mpit_cDCMPID + "',"); } if (model.mpit_lIsDeleted != null) { strSql1.Append("mpit_lIsDeleted,"); strSql2.Append("" + (model.mpit_lIsDeleted ? 1 : 0) + ","); } if (model.mpit_dUpdateTime != null) { strSql1.Append("mpit_dUpdateTime,"); strSql2.Append("'" + model.mpit_dUpdateTime.Value.ToString(this._sqlLiteDatetimeFormat) + "',"); } strSql.Append("insert into MachinePrepareItem_mpit("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); return strSql.ToString(); }