public MaterialProfile_mlpf_Info DisplayRecord(IModelObject KeyObject) { MaterialProfile_mlpf_Info info = new MaterialProfile_mlpf_Info(); using (MainDBDataContext db = new MainDBDataContext()) { MaterialProfile_mlpf disTab = db.MaterialProfile_mlpf.SingleOrDefault(t => t.mlpf_MLPFID == ((KeyObject) as MaterialProfile_mlpf_Info).mlpf_MLPFID); if (disTab != null) { info = Common.General.CopyObjectValue<MaterialProfile_mlpf, MaterialProfile_mlpf_Info>(disTab); } } return info; }
public bool InsertRecord(MaterialProfile_mlpf_Info infoObject) { bool isSuccess = false; MaterialProfile_mlpf_Info info = new MaterialProfile_mlpf_Info(); info = infoObject; using (MainDBDataContext db = new MainDBDataContext()) { MaterialProfile_mlpf newTab = Common.General.CopyObjectValue<MaterialProfile_mlpf_Info, MaterialProfile_mlpf>(infoObject); db.MaterialProfile_mlpf.InsertOnSubmit(newTab); db.SubmitChanges(); isSuccess = true; } return isSuccess; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.ppgDataDictionary.Font = ControlSetting.ListFont; if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Insert) { this.TabText = "新增 - " + this.Text; this._tmpobjInfo = new MaterialProfile_mlpf_Info(); this.sysToolBar.BtnSave_IsUsed = true; this.sysToolBar.BtnSave_IsEnabled = true; } else if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Update) { this.TabText = "编辑 - " + this.Text; if (base.BaseParam != null) { MaterialProfile_mlpf_Info objInfo = this.BaseParam as MaterialProfile_mlpf_Info; this._tmpobjInfo = objInfo; } else { this.ShowWarningMessage("没有可用的记录。"); } this.sysToolBar.BtnSave_IsUsed = true; this.sysToolBar.BtnSave_IsEnabled = true; } else if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_ReaOnly) { this.TabText = "查看 - " + this.Text; if (base.BaseParam != null) { MaterialProfile_mlpf_Info objInfo = this.BaseParam as MaterialProfile_mlpf_Info; this._tmpobjInfo = objInfo; } else { this.ShowWarningMessage("没有可用的记录。"); } this.sysToolBar.BtnSave_IsUsed = false; } this.sysToolBar.BtnExit_IsEnabled = true; this.sysToolBar.BtnExit_IsUsed = true; BindPropertyGrid(); }
public bool DeleteRecord(IModelObject KeyObject) { bool isSuccess = false; MaterialProfile_mlpf_Info info = new MaterialProfile_mlpf_Info(); info = KeyObject as MaterialProfile_mlpf_Info; using (MainDBDataContext db = new MainDBDataContext()) { MaterialProfile_mlpf delTab = db.MaterialProfile_mlpf.SingleOrDefault(t => t.mlpf_MLPFID == info.mlpf_MLPFID); if (delTab != null) { //db.MaterialProfile_mlpf.DeleteOnSubmit(delTab); delTab.mlpf_lIsDeleted = true; db.SubmitChanges(); isSuccess = true; } } return isSuccess; }
public ReturnValueInfo Save_SQL(IModelObject itemEntity, DefineConstantValue.EditStateEnum EditMode) { ReturnValueInfo returnValue = new ReturnValueInfo(); MaterialProfile_mlpf_Info info = new MaterialProfile_mlpf_Info(); returnValue.messageText = ""; info = itemEntity as MaterialProfile_mlpf_Info; try { switch (EditMode) { case Common.DefineConstantValue.EditStateEnum.OE_Insert: bool isExist = false; isExist = _MaterialMasterSQL.IsExistRecord(info); if (!isExist) { returnValue.boolValue = _MaterialMasterSQL.InsertRecord(info); } else { returnValue.boolValue = false; returnValue.messageText = "數據重複!"; } break; case Common.DefineConstantValue.EditStateEnum.OE_Update: returnValue.boolValue = _MaterialMasterSQL.UpdateRecord(info); break; case Common.DefineConstantValue.EditStateEnum.OE_Delete: returnValue.boolValue = _MaterialMasterSQL.DeleteRecord(info); break; } } catch (Exception Ex) { throw Ex; } return returnValue; }
public bool UpdateRecord(MaterialProfile_mlpf_Info infoObject) { throw new NotImplementedException(); }
public bool UpdateRecord(MaterialProfile_mlpf_Info infoObject) { bool isSuccess = false; using (MainDBDataContext db = new MainDBDataContext()) { MaterialProfile_mlpf query = db.MaterialProfile_mlpf.SingleOrDefault(t => t.mlpf_MLPFID == infoObject.mlpf_MLPFID); if (query != null) { query.mlpf_cMaterialCode = infoObject.mlpf_cMaterialCode; query.mlpf_cMaterialType = infoObject.mlpf_cMaterialType; query.mlpf_cMaterialName = infoObject.mlpf_cMaterialName; query.mlpf_cDescription = infoObject.mlpf_cDescription; query.mlpf_lIsDeleted = infoObject.mlpf_lIsDeleted; query.mlpf_dUpdateTime = infoObject.mlpf_dUpdateTime; query.mlpf_cMaterialAbbreviation = infoObject.mlpf_cMaterialAbbreviation; query.mlpf_cMaterialBrand = infoObject.mlpf_cMaterialBrand; query.mlpf_cMaterialUnit = infoObject.mlpf_cMaterialUnit; query.mlpf_fMaterialWidth = infoObject.mlpf_fMaterialWidth; query.mlpf_fMaterialLength = infoObject.mlpf_fMaterialLength; query.mlpf_lSync = infoObject.mlpf_lSync; db.SubmitChanges(); isSuccess = true; } } return isSuccess; }
public List<MaterialProfile_mlpf_Info> SearchRecords(IModelObject searchCondition) { List<MaterialProfile_mlpf_Info> list = new List<MaterialProfile_mlpf_Info>(); MaterialProfile_mlpf_Info info = new MaterialProfile_mlpf_Info(); info = searchCondition as MaterialProfile_mlpf_Info; StringBuilder sqlString = new StringBuilder(); sqlString.AppendLine("SELECT TOP " + Common.DefineConstantValue.ListRecordMaxCount.ToString()); sqlString.AppendLine("*"); sqlString.AppendLine("FROM MaterialProfile_mlpf "); sqlString.AppendLine("WHERE 1=1 And mlpf_lIsDeleted=0"); if (info.mlpf_cMaterialType != "" && info.mlpf_cMaterialType != null) { sqlString.AppendLine("AND mlpf_cMaterialType=N'" + info.mlpf_cMaterialType + "'"); } if (info.mlpf_cMaterialCode != "" && info.mlpf_cMaterialCode != null) { sqlString.AppendLine("AND mlpf_cMaterialCode='" + info.mlpf_cMaterialCode + "'"); } if (info.mlpf_cMaterialName != "" && info.mlpf_cMaterialName != null) { sqlString.AppendLine("AND mlpf_cMaterialName=N'" + info.mlpf_cMaterialName + "'"); } if (info.mlpf_cDescription != "" && info.mlpf_cDescription != null) { sqlString.AppendLine("AND mlpf_cDescription=N'" + info.mlpf_cDescription + "'"); } if (info.mlpf_cMaterialBrand != "" && info.mlpf_cMaterialBrand != null) { sqlString.AppendLine("AND mlpf_cMaterialBrand=N'" + info.mlpf_cMaterialBrand + "'"); } if (info.mlpf_cMaterialAbbreviation != "" && info.mlpf_cMaterialAbbreviation != null) { sqlString.AppendLine("AND mlpf_cMaterialAbbreviation=N'" + info.mlpf_cMaterialAbbreviation + "'"); } IEnumerable<MaterialProfile_mlpf_Info> infos = null; using (MainDBDataContext db = new MainDBDataContext()) { infos = db.ExecuteQuery<MaterialProfile_mlpf_Info>(sqlString.ToString(), new object[] { }); if (infos != null) { list = infos.ToList<MaterialProfile_mlpf_Info>(); } } return list; }
/// <summary> /// 物料主檔 /// </summary> /// <returns></returns> public List<MaterialProfile_mlpf_Info> GetMaterialMaster() { try { List<MaterialProfile_mlpf_Info> list = new List<MaterialProfile_mlpf_Info>(); StringBuilder strSql = new StringBuilder(); strSql.AppendLine("select "); strSql.AppendLine("mlpf_MLPFID,mlpf_cMaterialCode,mType.cmt_cRemark as mlpf_cMaterialType,mlpf_cMaterialName,mlpf_cDescription,mlpf_lIsDeleted,mlpf_dUpdateTime,mlpf_cMaterialAbbreviation,mlpf_cMaterialBrand,mUnit.cmt_cRemark as mlpf_cMaterialUnit,mlpf_fMaterialWidth,mlpf_fMaterialLength,mlpf_lSync "); strSql.AppendLine("from MaterialProfile_mlpf "); strSql.AppendLine("left join CodeMaster_cmt as mUnit on mUnit.cmt_cKey1='" + DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE.Trim() + "' "); strSql.AppendLine("and mUnit.cmt_cKey2='" + DefineConstantValue.CodeMasterDefine.KEY2_MATERIALUNIT.Trim() + "' "); strSql.AppendLine("and mUnit.cmt_cValue=mlpf_cMaterialUnit "); strSql.AppendLine("left join CodeMaster_cmt as mType on mType.cmt_cKey1='" + DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE.Trim() + "' "); strSql.AppendLine("and mType.cmt_cKey2='" + DefineConstantValue.CodeMasterDefine.KEY2_MATERIALTYPE.Trim() + "' "); strSql.AppendLine("and mType.cmt_cValue=mlpf_cMaterialType "); strSql.AppendLine("where mlpf_lIsDeleted=0 "); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { MaterialProfile_mlpf_Info model = new MaterialProfile_mlpf_Info(); if (sdr["mlpf_MLPFID"] != null && sdr["mlpf_MLPFID"].ToString() != "") { model.mlpf_MLPFID = new Guid(sdr["mlpf_MLPFID"].ToString()); } if (sdr["mlpf_cMaterialCode"] != null && sdr["mlpf_cMaterialCode"].ToString() != "") { model.mlpf_cMaterialCode = sdr["mlpf_cMaterialCode"].ToString(); } if (sdr["mlpf_cMaterialType"] != null && sdr["mlpf_cMaterialType"].ToString() != "") { model.mlpf_cMaterialType = sdr["mlpf_cMaterialType"].ToString(); } if (sdr["mlpf_cMaterialName"] != null && sdr["mlpf_cMaterialName"].ToString() != "") { model.mlpf_cMaterialName = sdr["mlpf_cMaterialName"].ToString(); } if (sdr["mlpf_cDescription"] != null && sdr["mlpf_cDescription"].ToString() != "") { model.mlpf_cDescription = sdr["mlpf_cDescription"].ToString(); } if (sdr["mlpf_lIsDeleted"] != null && sdr["mlpf_lIsDeleted"].ToString() != "") { if ((sdr["mlpf_lIsDeleted"].ToString() == "1") || (sdr["mlpf_lIsDeleted"].ToString().ToLower() == "true")) { model.mlpf_lIsDeleted = true; } else { model.mlpf_lIsDeleted = false; } } if (sdr["mlpf_dUpdateTime"] != null && sdr["mlpf_dUpdateTime"].ToString() != "") { model.mlpf_dUpdateTime = DateTime.Parse(sdr["mlpf_dUpdateTime"].ToString()); } if (sdr["mlpf_cMaterialAbbreviation"] != null && sdr["mlpf_cMaterialAbbreviation"].ToString() != "") { model.mlpf_cMaterialAbbreviation = sdr["mlpf_cMaterialAbbreviation"].ToString(); } if (sdr["mlpf_cMaterialBrand"] != null && sdr["mlpf_cMaterialBrand"].ToString() != "") { model.mlpf_cMaterialBrand = sdr["mlpf_cMaterialBrand"].ToString(); } if (sdr["mlpf_cMaterialUnit"] != null && sdr["mlpf_cMaterialUnit"].ToString() != "") { model.mlpf_cMaterialUnit = sdr["mlpf_cMaterialUnit"].ToString(); } if (sdr["mlpf_fMaterialWidth"] != null && sdr["mlpf_fMaterialWidth"].ToString() != "") { model.mlpf_fMaterialWidth = decimal.Parse(sdr["mlpf_fMaterialWidth"].ToString()); } if (sdr["mlpf_fMaterialLength"] != null && sdr["mlpf_fMaterialLength"].ToString() != "") { model.mlpf_fMaterialLength = decimal.Parse(sdr["mlpf_fMaterialLength"].ToString()); } if (sdr["mlpf_lSync"] != null && sdr["mlpf_lSync"].ToString() != "") { if ((sdr["mlpf_lSync"].ToString() == "1") || (sdr["mlpf_lSync"].ToString().ToLower() == "true")) { model.mlpf_lSync = true; } else { model.mlpf_lSync = false; } } list.Add(model); } } return list; } catch (Exception ex) { throw ex; } }
private string GetMaterialMasterSQL(MaterialProfile_mlpf_Info model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.mlpf_MLPFID != null) { strSql1.Append("mlpf_MLPFID,"); strSql2.Append("'" + model.mlpf_MLPFID + "',"); } if (model.mlpf_cMaterialCode != null) { strSql1.Append("mlpf_cMaterialCode,"); strSql2.Append("'" + model.mlpf_cMaterialCode + "',"); } if (model.mlpf_cMaterialType != null) { strSql1.Append("mlpf_cMaterialType,"); strSql2.Append("'" + model.mlpf_cMaterialType + "',"); } if (model.mlpf_cMaterialName != null) { strSql1.Append("mlpf_cMaterialName,"); strSql2.Append("'" + model.mlpf_cMaterialName + "',"); } if (model.mlpf_cDescription != null) { strSql1.Append("mlpf_cDescription,"); strSql2.Append("'" + model.mlpf_cDescription + "',"); } if (model.mlpf_lIsDeleted != null) { strSql1.Append("mlpf_lIsDeleted,"); strSql2.Append("" + (model.mlpf_lIsDeleted ? 1 : 0) + ","); } if (model.mlpf_dUpdateTime != null) { strSql1.Append("mlpf_dUpdateTime,"); strSql2.Append("'" + model.mlpf_dUpdateTime.Value.ToString(this._sqlLiteDatetimeFormat) + "',"); } //if (model.mlpf_cMaterialAbbreviation != null) //{ strSql1.Append("mlpf_cMaterialAbbreviation,"); strSql2.Append("'" + (model.mlpf_cMaterialAbbreviation == null ? "" : model.mlpf_cMaterialAbbreviation) + "',"); //} //if (model.mlpf_cMaterialBrand != null) //{ strSql1.Append("mlpf_cMaterialBrand,"); strSql2.Append("'" + (model.mlpf_cMaterialBrand == null ? "" : model.mlpf_cMaterialBrand) + "',"); //} if (model.mlpf_cMaterialUnit != null) { strSql1.Append("mlpf_cMaterialUnit,"); strSql2.Append("'" + model.mlpf_cMaterialUnit + "',"); } if (model.mlpf_fMaterialWidth != null) { strSql1.Append("mlpf_fMaterialWidth,"); strSql2.Append("" + model.mlpf_fMaterialWidth + ","); } if (model.mlpf_fMaterialLength != null) { strSql1.Append("mlpf_fMaterialLength,"); strSql2.Append("" + model.mlpf_fMaterialLength + ","); } if (model.mlpf_lSync != null) { strSql1.Append("mlpf_lSync,"); strSql2.Append("" + (model.mlpf_lSync ? 1 : 0) + ","); } strSql.Append("insert into MaterialProfile_mlpf("); 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(); }
/// <summary> /// 物料主檔 /// </summary> /// <returns></returns> public List<MaterialProfile_mlpf_Info> GetMaterialMaster() { try { List<MaterialProfile_mlpf_Info> list = new List<MaterialProfile_mlpf_Info>(); StringBuilder strSql = new StringBuilder(); strSql.AppendLine("select "); strSql.AppendLine("mlpf_MLPFID,mlpf_cMaterialCode,mlpf_cMaterialType,mlpf_cMaterialName,mlpf_cDescription,mlpf_lIsDeleted,mlpf_dUpdateTime,mlpf_cMaterialAbbreviation,mlpf_cMaterialBrand,mlpf_cMaterialUnit,mlpf_fMaterialWidth,mlpf_fMaterialLength,mlpf_lSync "); strSql.AppendLine("from MaterialProfile_mlpf "); using (SQLiteDataReader sdr = DbHelperSQLite.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { MaterialProfile_mlpf_Info model = new MaterialProfile_mlpf_Info(); if (sdr["mlpf_MLPFID"] != null && sdr["mlpf_MLPFID"].ToString() != "") { model.mlpf_MLPFID = new Guid(sdr["mlpf_MLPFID"].ToString()); } if (sdr["mlpf_cMaterialCode"] != null && sdr["mlpf_cMaterialCode"].ToString() != "") { model.mlpf_cMaterialCode = sdr["mlpf_cMaterialCode"].ToString(); } if (sdr["mlpf_cMaterialType"] != null && sdr["mlpf_cMaterialType"].ToString() != "") { model.mlpf_cMaterialType = sdr["mlpf_cMaterialType"].ToString(); } if (sdr["mlpf_cMaterialName"] != null && sdr["mlpf_cMaterialName"].ToString() != "") { model.mlpf_cMaterialName = sdr["mlpf_cMaterialName"].ToString(); } if (sdr["mlpf_cDescription"] != null && sdr["mlpf_cDescription"].ToString() != "") { model.mlpf_cDescription = sdr["mlpf_cDescription"].ToString(); } if (sdr["mlpf_lIsDeleted"] != null && sdr["mlpf_lIsDeleted"].ToString() != "") { if ((sdr["mlpf_lIsDeleted"].ToString() == "1") || (sdr["mlpf_lIsDeleted"].ToString().ToLower() == "true")) { model.mlpf_lIsDeleted = true; } else { model.mlpf_lIsDeleted = false; } } if (sdr["mlpf_dUpdateTime"] != null && sdr["mlpf_dUpdateTime"].ToString() != "") { model.mlpf_dUpdateTime = DateTime.Parse(sdr["mlpf_dUpdateTime"].ToString()); } if (sdr["mlpf_cMaterialAbbreviation"] != null && sdr["mlpf_cMaterialAbbreviation"].ToString() != "") { model.mlpf_cMaterialAbbreviation = sdr["mlpf_cMaterialAbbreviation"].ToString(); } if (sdr["mlpf_cMaterialBrand"] != null && sdr["mlpf_cMaterialBrand"].ToString() != "") { model.mlpf_cMaterialBrand = sdr["mlpf_cMaterialBrand"].ToString(); } if (sdr["mlpf_cMaterialUnit"] != null && sdr["mlpf_cMaterialUnit"].ToString() != "") { model.mlpf_cMaterialUnit = sdr["mlpf_cMaterialUnit"].ToString(); } if (sdr["mlpf_fMaterialWidth"] != null && sdr["mlpf_fMaterialWidth"].ToString() != "") { model.mlpf_fMaterialWidth = decimal.Parse(sdr["mlpf_fMaterialWidth"].ToString()); } if (sdr["mlpf_fMaterialLength"] != null && sdr["mlpf_fMaterialLength"].ToString() != "") { model.mlpf_fMaterialLength = decimal.Parse(sdr["mlpf_fMaterialLength"].ToString()); } if (sdr["mlpf_lSync"] != null && sdr["mlpf_lSync"].ToString() != "") { if ((sdr["mlpf_lSync"].ToString() == "1") || (sdr["mlpf_lSync"].ToString().ToLower() == "true")) { model.mlpf_lSync = true; } else { model.mlpf_lSync = false; } } list.Add(model); } } return list; } catch { throw; } }