using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WMS.Frm.Base;
using WMS.Model.Base;
using WMS.Common;
using WMS.Base.WebService;
using WMS.Ctrl;
using WMS.Frm;
namespace WMS.FrmBaseData
{
public partial class FrmInterCity : FormBase
{
///
/// 城际运输MODEL
///
InterCityModel intercityModel = new InterCityModel();
///
/// 城际运输数据源
///
List SourceList = new List();
///
/// 业务类型
///
int workflag;//0 增加 1 修改 2 删除 ;
public FrmInterCity()
{
InitializeComponent();
}
private void FrmInterCity_Load(object sender, EventArgs e)
{
panelControl1.Enabled = false;
frmButtonItem["Save"].Enabled = false;
FrmSelectModle = new InterCityModel();
bindlookupEdit();
bindGrid();
GCInterCity_Click(null,null);
}
///
/// 通用查询
///
///
public override void LoadListData(DataTable table)
{
SourceList = ConvertHelper.ConvertToList(table);
GCInterCity.DataSource = SourceList;
GVInterCity.RefreshData();
}
///
/// 绑定下拉框
///
private void bindlookupEdit()
{
try
{
string strAddressAreaModel = Newtonsoft.Json.JsonConvert.SerializeObject(new AddressAreaModel());
string strlistAddressAreaModel = WebLockConfig.Instance.WebAddressArea.GetAddressArea(strAddressAreaModel);
List list = Newtonsoft.Json.JsonConvert.DeserializeObject>(strlistAddressAreaModel);
TLEPSTR.Properties.DataSource = list;
TLEPSTR.Properties.DisplayMember = "Add_name";
TLEPSTR.Properties.ValueMember = "Add_id";
TLEPEDD.Properties.DataSource = list;
TLEPEDD.Properties.DisplayMember = "Add_name";
TLEPEDD.Properties.ValueMember = "Add_id";
}
catch (Exception)
{
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
}
}
///
/// 绑定grid
///
private void bindGrid()
{
try
{
string strInterCityeModel = Newtonsoft.Json.JsonConvert.SerializeObject(new InterCityModel());
string Source = WebLockConfig.Instance.WebInterCity.execInterCityGetList(strInterCityeModel);
SourceList = Newtonsoft.Json.JsonConvert.DeserializeObject>(Source);
}
catch (Exception)
{
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
}
GCInterCity.DataSource = SourceList;
if (SourceList.Count > 0)
{
GVInterCity.FocusedRowHandle = 0;
}
GVInterCity.RefreshData();
GVInterCity.ExpandAllGroups();
}
#region 以下是继承的按钮事件
///
/// 新增按钮
///
public void Add()
{
frmButtonItem["Save"].Enabled = true;
panelControl1.Enabled = true;
workflag = 0;
BSTab.DataSource = new InterCityModel();
}
///
/// 保存按钮
///
public void Save()
{
FrmOperator(workflag);
}
///
/// 删除按钮
///
public void Del()
{
workflag = 2;
if (SystemCommon.ShowMessageBoxResult("确定此城际距离数据:" + GVInterCity.GetFocusedRowCellValue("CITY_START").ToString() + "-" +
GVInterCity.GetFocusedRowCellValue("CITY_EDD").ToString()) == System.Windows.Forms.DialogResult.Yes)
{
Save();
}
}
///
/// 修改按钮
///
public void Edit()
{
frmButtonItem["Save"].Enabled = true;
workflag = 1;
panelControl1.Enabled = true;
}
///
/// 刷新按钮
///
public void RefreshDataButton()
{
bindGrid();
frmButtonItem["Save"].Enabled = false;
panelControl1.Enabled = false;
}
///
/// 确定按钮
///
public void ConfrimDataButton() { }
///
/// 查询按钮
///
public void Seach()
{
FrmSelect frm = new FrmSelect(this.FrmSelectModle);
if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.LoadListData(frm.SelectData);
}
}
///
/// 导出按钮
///
public void ExportDataButton() { }
///
/// 打印按钮
///
public void PrintDataButton()
{
}
///
/// 备注
///
protected new void NoteDataButton(FormBase fBase) { }
///
/// 审核
///
public void AuditDataButton() { }
///
/// 反审核
///
public void ReturnAuditDataButton() { }
#endregion
#region 操作(增、改、删)
///
/// 操作(增、改、删)
///
/// 0 新增 1修改 2删除 3停用 4启用/param>
private void FrmOperator(int flag)
{
BSTab.EndEdit();
string errtxt = string.Empty;
try
{
intercityModel = BSTab.DataSource as InterCityModel;
if (string.IsNullOrEmpty(intercityModel.CITY_EDD) || string.IsNullOrEmpty(intercityModel.CITY_START))
{
SystemCommon.ShowInfoMessageBox("请选择起止城市!");
return;
}
intercityModel.CREATE_TYPE = "0";
if (string.IsNullOrEmpty(intercityModel.ID))
{
intercityModel.ID = Guid.NewGuid().ToString();
}
if (flag == 0)
{
string strintercityAddModel = Newtonsoft.Json.JsonConvert.SerializeObject(intercityModel);
errtxt = WebLockConfig.Instance.WebInterCity.execInterCityAdd(strintercityAddModel);
}
else if (flag == 1)
{
string strintercityUpModel = Newtonsoft.Json.JsonConvert.SerializeObject(intercityModel);
errtxt = WebLockConfig.Instance.WebInterCity.execInterCityUp(strintercityUpModel);
}
else if (flag == 2)
{
errtxt = WebLockConfig.Instance.WebInterCity.execInterCityDel(intercityModel.ID);
}
if (!string.IsNullOrEmpty(errtxt))
{
SystemCommon.ShowErrorMessageBox(errtxt);
}
else
{
SystemCommon.ShowInfoMessageBox("操作成功!");
bindGrid();
frmButtonItem["Save"].Enabled = false;
panelControl1.Enabled = false;
}
}
catch (Exception e)
{
SystemCommon.ShowInfoMessageBox("请规范操作!" + Environment.NewLine + e.Message);
}
}
#endregion
private void GCInterCity_Click(object sender, EventArgs e)
{
if (GVInterCity.FocusedRowHandle < 0)
{
return;
}
intercityModel = GVInterCity.GetRow(GVInterCity.FocusedRowHandle) as InterCityModel;
BSTab.DataSource = intercityModel;
}
private void GVInterCity_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
{
if (e.Value == null || e.Value == DBNull.Value)
{
return;
}
if (e.Column.FieldName == "STATUS")
{
switch (e.Value.ToString().Trim())
{
case "0":
e.DisplayText = "停用";
break;
case "1":
e.DisplayText = "启用";
break;
}
}
}
}
}