377 lines
12 KiB
C#
377 lines
12 KiB
C#
|
|
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.Frm;
|
|||
|
|
|
|||
|
|
namespace WMS.FrmBaseData
|
|||
|
|
{
|
|||
|
|
public partial class FrmCapacityType : FormBase
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 运力类型MODEL
|
|||
|
|
/// </summary>
|
|||
|
|
CapacityTypeModel capaTypeModel = new CapacityTypeModel();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 运力类型数据源
|
|||
|
|
/// </summary>
|
|||
|
|
List<CapacityTypeModel> SourceList = new List<CapacityTypeModel>();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 业务类型
|
|||
|
|
/// </summary>
|
|||
|
|
int workflag;//0 增加 1 修改 2 删除 ;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 初始化
|
|||
|
|
/// </summary>
|
|||
|
|
public FrmCapacityType()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 窗体加载
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void FrmCapacityType_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
//lue_Unit
|
|||
|
|
//单位下拉框
|
|||
|
|
//lue_Unit.Properties.NullText = "";
|
|||
|
|
//lue_Unit.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("VC_DICTIONARY_NAME", "单位"));
|
|||
|
|
//lue_Unit.Properties.ValueMember = "VC_CHAR_VALUE";
|
|||
|
|
//lue_Unit.Properties.DisplayMember = "VC_DICTIONARY_NAME";
|
|||
|
|
//string strResult = string.Empty;
|
|||
|
|
//try
|
|||
|
|
//{
|
|||
|
|
// strResult = WebLockConfig.Instance.Common.GetCustomCtrlData("t_sys_dictionary_tab", "VC_CHAR_VALUE", "VC_DICTIONARY_NAME", " VC_DICTIONARY_TYPE = 'vc_uom' and c_flag = '1'", "");
|
|||
|
|
//}
|
|||
|
|
//catch (Exception)
|
|||
|
|
//{
|
|||
|
|
// SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
//}
|
|||
|
|
//lue_Unit.Properties.DataSource = Newtonsoft.Json.JsonConvert.DeserializeObject<DataTable>(strResult);
|
|||
|
|
lue_Unit.LoadData();
|
|||
|
|
LEPCreateType.LoadData();
|
|||
|
|
bindGrid();
|
|||
|
|
panelControl1.Enabled = false;
|
|||
|
|
FrmSelectModle = new CapacityTypeModel();
|
|||
|
|
|
|||
|
|
GCCapacityType_Click(null, null);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 通用查询
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="table"></param>
|
|||
|
|
public override void LoadListData(DataTable table)
|
|||
|
|
{
|
|||
|
|
SourceList = ConvertHelper<CapacityTypeModel>.ConvertToList(table);
|
|||
|
|
GCCapacityType.DataSource = SourceList;
|
|||
|
|
GVCapacityType.RefreshData();
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定grid
|
|||
|
|
/// </summary>
|
|||
|
|
private void bindGrid()
|
|||
|
|
{
|
|||
|
|
string strCapacityTypeModel = Newtonsoft.Json.JsonConvert.SerializeObject(new CapacityTypeModel());
|
|||
|
|
string Source = WebLockConfig.Instance.WebCapacityType.execCapacityTypeGetList(strCapacityTypeModel);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
SourceList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<CapacityTypeModel>>(Source);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GCCapacityType.DataSource = SourceList;
|
|||
|
|
if (SourceList.Count > 0)
|
|||
|
|
{
|
|||
|
|
GVCapacityType.FocusedRowHandle = 0;
|
|||
|
|
}
|
|||
|
|
GVCapacityType.RefreshData();
|
|||
|
|
GVCapacityType.ExpandAllGroups();
|
|||
|
|
}
|
|||
|
|
#region 以下是继承的按钮事件
|
|||
|
|
/// <summary>
|
|||
|
|
/// 新增按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Add()
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Save"].Enabled = true;
|
|||
|
|
panelControl1.Enabled = true;
|
|||
|
|
workflag = 0;
|
|||
|
|
BSCapacityType.DataSource = new CapacityTypeModel();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Save()
|
|||
|
|
{
|
|||
|
|
FrmOperator(workflag);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Del()
|
|||
|
|
{
|
|||
|
|
workflag = 2;
|
|||
|
|
if (GVCapacityType.FocusedRowHandle < 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请选择要删除的运力类型!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (SystemCommon.ShowMessageBoxResult("确定删除运力类型:" + GVCapacityType.GetFocusedRowCellValue("TYPE_ID").ToString())
|
|||
|
|
== System.Windows.Forms.DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
Save();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 修改按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Edit()
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Save"].Enabled = true;
|
|||
|
|
workflag = 1;
|
|||
|
|
panelControl1.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 刷新按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Refresh()
|
|||
|
|
{
|
|||
|
|
bindGrid();
|
|||
|
|
frmButtonItem["Save"].Enabled = false;
|
|||
|
|
panelControl1.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 确定按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void ConfrimDataButton() { }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Search()
|
|||
|
|
{
|
|||
|
|
FrmSelect frm = new FrmSelect(this.FrmSelectModle);
|
|||
|
|
if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
this.LoadListData(frm.SelectData);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 导出按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Export()
|
|||
|
|
{
|
|||
|
|
SaveFileDialog fileDialog = new SaveFileDialog();
|
|||
|
|
fileDialog.Title = "导出Excel";
|
|||
|
|
fileDialog.Filter = "Excel文件(*.xls)|*.xls";
|
|||
|
|
DialogResult dialogResult = fileDialog.ShowDialog(this);
|
|||
|
|
if (dialogResult == DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
//DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
GCCapacityType.ExportToXls(fileDialog.FileName);
|
|||
|
|
DevExpress.XtraEditors.XtraMessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("导出失败:" + e.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 打印按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void PrintDataButton()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 备注
|
|||
|
|
/// </summary>
|
|||
|
|
protected new void NoteDataButton(FormBase fBase) { }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 导入
|
|||
|
|
/// </summary>
|
|||
|
|
public void Import()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 反审核
|
|||
|
|
/// </summary>
|
|||
|
|
public void ReturnAuditDataButton() { }
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 操作(增、改、删)
|
|||
|
|
/// <summary>
|
|||
|
|
/// 操作(增、改、删)
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="flag">0 新增 1修改 2删除 3停用 4启用/param>
|
|||
|
|
private void FrmOperator(int flag)
|
|||
|
|
{
|
|||
|
|
BSCapacityType.EndEdit();
|
|||
|
|
string errtxt = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
capaTypeModel = BSCapacityType.DataSource as CapacityTypeModel;
|
|||
|
|
if (string.IsNullOrEmpty(capaTypeModel.TYPE_ID))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("类型编号不能为空!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(capaTypeModel.TYPE_NAME))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("类型名称不能为空!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (flag == 0)
|
|||
|
|
{
|
|||
|
|
string strCapacityTypeAddModel = Newtonsoft.Json.JsonConvert.SerializeObject(capaTypeModel);
|
|||
|
|
errtxt = WebLockConfig.Instance.WebCapacityType.execCapacityTypeAdd(strCapacityTypeAddModel);
|
|||
|
|
}
|
|||
|
|
else if (flag == 1)
|
|||
|
|
{
|
|||
|
|
string strCapacityTypeUpModel = Newtonsoft.Json.JsonConvert.SerializeObject(capaTypeModel);
|
|||
|
|
errtxt = WebLockConfig.Instance.WebCapacityType.execCapacityTypeUp(strCapacityTypeUpModel);
|
|||
|
|
}
|
|||
|
|
else if (flag == 2)
|
|||
|
|
{
|
|||
|
|
errtxt = WebLockConfig.Instance.WebCapacityType.execCapacityTypeDel(capaTypeModel.TYPE_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
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 单击一行选定
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void GCCapacityType_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (GVCapacityType.FocusedRowHandle < 0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
capaTypeModel = GVCapacityType.GetRow(GVCapacityType.FocusedRowHandle) as CapacityTypeModel;
|
|||
|
|
BSCapacityType.DataSource = capaTypeModel;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void txtLong_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
CapacityTypeModel type = BSCapacityType.DataSource as CapacityTypeModel;
|
|||
|
|
type.TYPE_VOLUME = isnull(txtLong.Text) * isnull(txtWight.Text) * isnull(txtHigh.Text);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txtWight_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
CapacityTypeModel type = BSCapacityType.DataSource as CapacityTypeModel;
|
|||
|
|
type.TYPE_VOLUME = isnull(txtLong.Text) * isnull(txtWight.Text) * isnull(txtHigh.Text);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txtHigh_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
CapacityTypeModel type = BSCapacityType.DataSource as CapacityTypeModel;
|
|||
|
|
type.TYPE_VOLUME = isnull(txtLong.Text) * isnull(txtWight.Text) * isnull(txtHigh.Text);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private decimal isnull(string text)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
return string.IsNullOrEmpty(text) ? 0 : Convert.ToDecimal(text);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void GVCapacityType_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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txtTypeID_Leave(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(txtTypeID.Text))
|
|||
|
|
{
|
|||
|
|
CapacityTypeModel type = new CapacityTypeModel() { TYPE_ID = txtTypeID.Text };
|
|||
|
|
string strCapacityTypeModel = Newtonsoft.Json.JsonConvert.SerializeObject(type);
|
|||
|
|
string Source = WebLockConfig.Instance.WebCapacityType.execCapacityTypeGetList(strCapacityTypeModel);
|
|||
|
|
List<CapacityTypeModel> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<CapacityTypeModel>>(Source);
|
|||
|
|
|
|||
|
|
if (list.Count > 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("该运力类型编号已存在!");
|
|||
|
|
txtTypeID.Text = "";
|
|||
|
|
txtTypeID.Select();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|