private void DeleteProject() { DataGridViewSelectedRowCollection dvrc = dgv_projects.SelectedRows; foreach (DataGridViewRow dvr in dvrc) { int id = (int)dvr.Cells[0].Value; Project pro = ProjectManager.Load(id); if (pro == null) { GlobalTool.LogError("ProjectManageForm.mi_delete_Click", "删除工程出现错误,请检查您的网络连接,或者向管理员寻求帮助!", true); continue; } else { if (pro.OwnerId != User.CurrentUser.Id) { MessageBox.Show("该工程不为您所有,您无法删除", "警告", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { bool res = ProjectManager.Delete(id); if (!res) { GlobalTool.LogError("ProjectManageForm.ProjectManager.Delete", "删除工程出现错误,请检查您的网络连接,或者向管理员寻求帮助!", true); } } } } RefreshData(); }
public void RefreshDataView() { if (dt == null) { dgv_projects.DataSource = null; return; } DataView dv = new DataView(dt); string filter = ""; //DateTime dstart= new DateTime(dtp_start.Value.Year, dtp_start.Value.Month, dtp_start.Value.Day, 0, 0, 0); //DateTime dend = dstart.AddMonths(1); DateTime dstart = dtp_start.Value.Date; DateTime dend = dtp_end.Value.Date; double start = GlobalTool.ConvertDateTimeInt(dstart); double end = GlobalTool.ConvertDateTimeInt(dend); filter = "time>=" + start.ToString() + " and time<=" + end.ToString(); if (cb_share.Checked) { filter += " and 共享=1"; } if (cb_self.Checked) { filter += " or 所有者=\'" + User.CurrentUser.Name + "\'"; } dv.RowFilter = filter; dgv_projects.DataSource = dv; dgv_projects.Columns.Clear(); dgv_projects.Columns.Add("编号", "编号"); dgv_projects.Columns[0].DataPropertyName = "编号"; dgv_projects.Columns.Add("名称", "名称"); dgv_projects.Columns[0].Width = 30; dgv_projects.Columns[1].DataPropertyName = "名称"; dgv_projects.Columns[1].Width = 100; dgv_projects.Columns.Add("所有者", "所有者"); dgv_projects.Columns[2].DataPropertyName = "所有者"; dgv_projects.Columns[2].Width = 100; dgv_projects.Columns.Add("计算类型", "计算类型"); dgv_projects.Columns[3].DataPropertyName = "计算类型"; dgv_projects.Columns[3].Width = 80; dgv_projects.Columns.Add("几何类型", "计算类型"); dgv_projects.Columns[4].DataPropertyName = "几何类型"; dgv_projects.Columns[4].Width = 80; dgv_projects.Columns.Add("时间", "时间"); dgv_projects.Columns[5].DataPropertyName = "时间"; dgv_projects.Columns[5].Width = 100; DataGridViewCheckBoxColumn dgvcbc = new DataGridViewCheckBoxColumn(false); dgvcbc.HeaderText = "共享"; dgv_projects.Columns.Add(dgvcbc); dgv_projects.Columns[6].DataPropertyName = "共享"; dgv_projects.Columns[6].Width = 30; }
private void ListToDataTableK2C(DataTable dt, List <RefValue> list) { dt.Clear(); foreach (RefValue r in list) { DataRow dr = dt.NewRow(); dr[0] = GlobalTool.K2C(r.r); dr[1] = r.v; dt.Rows.Add(dr); } dt.AcceptChanges(); }
private void DataTableToListC2K(DataTable dt, List <RefValue> list) { list.Clear(); foreach (DataRow dr in dt.Rows) { if (dr[0].ToString() == "" || dr[1].ToString() == "") { continue; } RefValue r = new RefValue(GlobalTool.C2K((double)dr[0]), (double)dr[1]); list.Add(r); } }
public static string ReadRememberPassword() { string encPassword = GlobalTool.ReadRegKeyValue("lastuser", "password"); if (encPassword == null) { return(null); } else { return(NetCryptoHelper.DecryptDes(encPassword, NetCryptoHelper.DesKey, NetCryptoHelper.DesIv)); } }
public static Project Default() { Project p = new Project(); p.Name = "新建计算"; p.Mode = CalculationMode.Temperature; p.Schema = GeometrySchema.Plate; p.HotfaceTemperature = GlobalTool.C2K(1600.0); p.ColdfaceBoundary = new Class1Boundary(373.15); p.SizeLorH = 1.0; p.SizeRorW = 1.0; p.TemperatureSolverControlParameter = SolverControlParameter.Default; return(p); }
public void RefreshData() { dt = ProjectManager.Search(tb_keyword.Text); if (dt == null) { GlobalTool.LogError("ProjectLoadForm.RefreshData", "检索工程数据出现错误,请检查您的网络连接,或者向管理员寻求帮助!", true); return; } dt.Columns["id"].ColumnName = "编号"; dt.Columns["name"].ColumnName = "名称"; dt.Columns["owner"].ColumnName = "所有者"; dt.Columns["mode_"].ColumnName = "计算类型"; dt.Columns["type_"].ColumnName = "几何类型"; dt.Columns["share"].ColumnName = "共享"; dt.Columns["remark"].ColumnName = "备注"; dt.Columns["time_"].ColumnName = "时间"; RefreshDataView(); }
private void LoadProject() { if (LoadEvent != null) { DataGridViewSelectedRowCollection dvrc = dgv_projects.SelectedRows; DataGridViewRow dvr = dvrc[0]; int id = (int)dvr.Cells[0].Value; Project pro = ProjectManager.Load(id); if (pro == null) { GlobalTool.LogError("ProjectManageForm.mi_load_Click", "读取工程出现错误,请检查您的网络连接,或者向管理员寻求帮助!", true); return; } else { LoadEvent(pro); } } }
public static void WriteRememberName(string name) { GlobalTool.WriteRegKeyValue("lastuser", "name", name); }
public static void DeleteRememberName() { GlobalTool.DeleteRegKeyValue("lastuser", "name"); }
public static void DeleteRememberPassword() { GlobalTool.DeleteRegKeyValue("lastuser", "password"); }
public static string ReadRememberName() { return(GlobalTool.ReadRegKeyValue("lastuser", "name")); }
public static void WriteRememberPassword(string password) { string encPassword = NetCryptoHelper.EncryptDes(password, NetCryptoHelper.DesKey, NetCryptoHelper.DesIv); GlobalTool.WriteRegKeyValue("lastuser", "password", encPassword); }