private void frmRoute_Activated(object sender, EventArgs e) { frmMain.Instance.ShowStatusText("正在数据...."); modelSetting = ModelSettingHelper.SelectByID(1); if (modelSetting.IsNull() || modelSetting.ModelID.IsNull()) return; txtModelName.Text = modelSetting.ModelName; txtPassword.Text = modelSetting.MPassword; txtUserName.Text = modelSetting.UserName; frmMain.Instance.ShowStatusText("数据加载完成!"); }
private void mnuEdit_Click(object sender, EventArgs e) { ModelSetting info = new ModelSetting(); info.ModelName = txtModelName.Text; info.UserName = txtUserName.Text; info.MPassword = txtPassword.Text; if (modelSetting.IsNull() || modelSetting.ModelID.IsNull()) { info.ModelID = 1; ModelSettingHelper.Insert(info); } else { info.ModelID = modelSetting.ModelID; ModelSettingHelper.Update(info); } ModelSettingHelper.ClearCacheAll(); MessageBox.Show("保存数据成功!", " 系统提示"); this.Close(); }
public ModelController() { setting = ModelSettingHelper.SelectByID(1); }
/// <summary> /// ����������Ӽ�¼ /// </summary> /// <param name="modelSetting">��������ʵ����</param> /// <param name="delCache">��ӳɹ��������CACHE key��֧������</param> /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param> /// <returns>����Ƿ�ɹ�</returns> public static bool Insert(ModelSetting modelSetting, string dbkey = "", string[] delCache = null) { int obj = new SQL().Database(dbkey).Insert(ModelSetting._) .ValueP(ModelSetting._ModelID, modelSetting.ModelID) .ValueP(ModelSetting._ModelName, modelSetting.ModelName) .ValueP(ModelSetting._UserName, modelSetting.UserName) .ValueP(ModelSetting._MPassword, modelSetting.MPassword) .ToExec(); if (delCache.IsNull()) return obj == 1; Cache2.Remove("TH.Mailer.ModelSettingCache_", delCache); return obj == 1; }
/// <summary> /// ���������Ķ�����¼ /// </summary> /// <param name="modelIDList">�������ӱ���б���á�,���ŷָ�</param> /// <param name="modelSetting">��������ʵ����</param> /// <returns>���Ƿ�ɹ�</returns> public static bool UpdateByIDList(IEnumerable<int> modelIDList, ModelSetting modelSetting, string dbkey) { return UpdateByIDList(modelIDList, modelSetting, dbkey, null, null); }
/// <summary> /// ���������Ķ�����¼ /// </summary> /// <param name="modelIDList">�������ӱ���б���á�,���ŷָ�</param> /// <param name="modelSetting">��������ʵ����</param> /// <param name="where">��ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param> /// <param name="delCache">�ijɹ��������CACHE key��֧������</param> /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param> /// <returns>���Ƿ�ɹ�</returns> public static bool UpdateByIDList(IEnumerable<int> modelIDList, ModelSetting modelSetting, string dbkey = "", Where where = null, string[] delCache = null) { int value = new SQL().Database(dbkey).Update(ModelSetting._) .SetP(ModelSetting._ModelName, modelSetting.ModelName) .SetP(ModelSetting._UserName, modelSetting.UserName) .SetP(ModelSetting._MPassword, modelSetting.MPassword) .Where(new Where() .And(ModelSetting._ModelID, "(" + modelIDList .Join(",") + ")", Operator.In) ).Where(where).ToExec(); if (value <= 0) return false; if (delCache.IsNull()) return true; Cache2.Remove("TH.Mailer.ModelSettingCache_", delCache); return true; }
/// <summary> /// ���������ļ�¼ /// </summary> /// <param name="modelSetting">��������ʵ����</param> /// <returns>���Ƿ�ɹ�</returns> public static bool Update(ModelSetting modelSetting, string dbkey) { return Update(modelSetting, dbkey, null, null); }
/// <summary> /// ���������ļ�¼ /// </summary> /// <param name="modelSetting">��������ʵ����</param> /// <param name="where">��ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param> /// <param name="delCache">�ijɹ��������CACHE key��֧������</param> /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param> /// <returns>���Ƿ�ɹ�</returns> public static bool Update(ModelSetting modelSetting, string dbkey = "", Where where = null, string[] delCache = null) { if (modelSetting.ModelID.IsNull()) return false; int value = new SQL().Database(dbkey).Update(ModelSetting._) .SetP(ModelSetting._ModelName, modelSetting.ModelName) .SetP(ModelSetting._UserName, modelSetting.UserName) .SetP(ModelSetting._MPassword, modelSetting.MPassword) .Where(new Where() .AndP(ModelSetting._ModelID, modelSetting.ModelID, Operator.Equal, true) ).Where(where).ToExec(); if (value <= 0) return false; if (delCache.IsNull()) return true; Cache2.Remove("TH.Mailer.ModelSettingCache_", delCache); return true; }
/// <summary> /// ����������Ӽ�¼ /// </summary> /// <param name="modelSetting">��������ʵ����</param> /// <returns>����Ƿ�ɹ�</returns> public static bool Insert(ModelSetting modelSetting, string dbkey) { return Insert(modelSetting, dbkey, null); }