StableVersion4.3/HL_FristAidPlatform_Base/Form_SystemInfo.cs

171 lines
7.1 KiB
C#
Raw Permalink Normal View History

2024-03-11 09:47:34 +08:00
using DevExpress.XtraEditors;
using HL_FristAidPlatform_DTO;
using HL_FristAidPlatform_Public;
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
namespace HL_FristAidPlatform_Base
{
public partial class Form_SystemInfo : XtraForm
{
#region 变量
/// <summary>
/// 操作标识 1:新增 2:修改
/// </summary>
private int Flag;
#endregion
public Form_SystemInfo()
{
InitializeComponent();
}
/// <summary>
/// 加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form_Base_SystemInfo_Load(object sender, EventArgs e)
{
BindInfo();
}
/// <summary>
/// 绑定信息
/// </summary>
private void BindInfo()
{
try
{
DataTable ResultDT = DBHelpClass.Get("/api/base/T_Base_SystemInfo/GetList");
if (ResultDT != null && ResultDT.Rows.Count > 0)
{
this.txt_SystemName.Tag = ResultDT.Rows[0]["ID"].ToString();
this.txt_SystemName.Text = ResultDT.Rows[0]["SystemName"].ToString();
this.txt_SystemSummary.Tag = ResultDT.Rows[0]["GUID"].ToString();
this.txt_SystemSummary.Text = ResultDT.Rows[0]["SystemSummary"].ToString();
this.txt_SystemEdition.Tag = ResultDT.Rows[0]["CreationDate"].ToString();
this.txt_SystemEdition.Text = ResultDT.Rows[0]["SystemEdition"].ToString();
this.txt_CompanyName.Text = ResultDT.Rows[0]["CompanyName"].ToString();
this.txt_CompanyWebsite.Text = ResultDT.Rows[0]["CompanyWebsite"].ToString();
this.txt_ServiceTelephone.Text = ResultDT.Rows[0]["ServiceTelephone"].ToString();
this.txt_ServiceEmail.Text = ResultDT.Rows[0]["ServiceEmail"].ToString();
this.txt_Slogan.Text = ResultDT.Rows[0]["Slogan"].ToString();
this.txt_Copyright.Text = ResultDT.Rows[0]["Copyright"].ToString();
this.txt_CopyrightDescription.Text = ResultDT.Rows[0]["CopyrightDescription"].ToString();
PublicClass.EnabledControl(this.groupC_SystemInfo, true, false);
Flag = 2;//修改标识
}
else
{
PublicClass.EnabledControl(this.groupC_SystemInfo, false, false);
Flag = 1;
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定信息:\r\n" + ex);
}
}
/// <summary>
/// 修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Update_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
PublicClass.EnabledControl(this.groupC_SystemInfo, false, false);
Flag = 2;//修改标识
}
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Save_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
try
{
#region 保存
//系统名称不能为空
if (string.IsNullOrEmpty(this.txt_SystemName.Text.ToString().Trim()))
{
MessageBox.Show("系统名称不能为空,请填写!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txt_SystemName.Focus();
return;
}
//公司名称不能为空
if (string.IsNullOrEmpty(this.txt_CompanyName.Text.ToString().Trim()))
{
MessageBox.Show("公司名称不能为空,请填写!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txt_CompanyName.Focus();
return;
}
List<T_Base_SystemInfoDTO> list = new List<T_Base_SystemInfoDTO>();
T_Base_SystemInfoDTO model = new T_Base_SystemInfoDTO();
string Url = string.Empty;
if (Flag == 1)
{
Url = "api/base/T_Base_SystemInfo";
model.GUID = Guid.NewGuid().ToString();
model.CreationDate = Convert.ToDateTime(DateTime.Now.ToString(PublicClass.TimeToString));
}
else
{
Url = "api/base/T_Base_SystemInfo/Update";
model.ID = Convert.ToInt32(this.txt_SystemName.Tag.ToString());
model.GUID = this.txt_SystemSummary.Tag.ToString();
model.CreationDate = Convert.ToDateTime(this.txt_SystemEdition.Tag.ToString() == "" ? DateTime.Now.ToString(PublicClass.TimeToString) : this.txt_SystemEdition.Tag.ToString());
}
model.SystemName = this.txt_SystemName.Text.ToString().Trim();
model.SystemSummary = this.txt_SystemSummary.Text.ToString();
model.SystemEdition = this.txt_SystemEdition.Text.ToString().Trim();
model.CompanyName = this.txt_CompanyName.Text.ToString().Trim();
model.CompanyWebsite = this.txt_CompanyWebsite.Text.ToString().Trim();
model.ServiceTelephone = this.txt_ServiceTelephone.Text.ToString().Trim();
model.ServiceEmail = this.txt_ServiceEmail.Text.ToString().Trim();
model.Slogan = this.txt_Slogan.Text.ToString();
model.Copyright = this.txt_Copyright.Text.ToString();
model.CopyrightDescription = this.txt_CopyrightDescription.Text.ToString();
list.Add(model);
//初始化两个工厂
ClientFactory<T_Base_SystemInfoDTO> httpClient = new HttpClientFactory<T_Base_SystemInfoDTO>();
Client<T_Base_SystemInfoDTO> client = httpClient.VisitFactory();
//访问
ListEntity<T_Base_SystemInfoDTO> t = client.Post(Url, list);
if (t.Success)
{
XtraMessageBox.Show("保存系统信息成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
PublicClass.EnabledControl(this.groupC_SystemInfo, true, false);
}
else
{
XtraMessageBox.Show("保存失败,请稍后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
#endregion
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定信息:\r\n" + ex);
}
}
private void btn_Exit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
this.Close();
}
}
}