using DevExpress.ClipboardSource.SpreadsheetML;
using DevExpress.XtraEditors;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Gs.DevApp.UserControl;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Media.Animation;
namespace Gs.DevApp.DevFrm
{
///
/// 模具台账
///
public partial class YS_mjtz : DevExpress.XtraEditors.XtraForm
{
string _webServiceName = "YS_mjtz/";
List _filterList = new List();
public YS_mjtz()
{
InitializeComponent();
this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;//查询事件
this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick;//新增事件
this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick;//修改事件
this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick;
this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1;
this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick;
toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick;
this.toolBarMenu1.getXmlConfig();
Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, this, "checkStatus", "", (value) =>
{
Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
}, tips);
Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) =>
{
getModel(value);
}, (value) =>
{
getPageList(this.pageBar1.CurrentPage);
}, lbGuid);
getPageList(1);
pageBar1.PagerEvent += PageBar1_PagerEvent;
}
private async void GridView1_ColumnFilterChanged(object sender, EventArgs e)
{
_filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1);
await Task.Delay(100);
getPageList(1);
}
///
/// 分页事件
///
///
///
private void PageBar1_PagerEvent(int curPage, int pageSize)
{
getPageList(curPage);
}
///
/// 查询事件
///
///
///
private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
{
gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
gridView1.ActiveFilter.Clear();
gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
var frm = new ShowFilter(gridView1.Columns, _filterList, this.GetType().FullName);
frm.UpdateParent += Frm_UpdateParent;
frm.ShowDialog();
}
///
/// 查询回调
///
///
///
private void Frm_UpdateParent(object sender, UpdateParentEventArgs e)
{
_filterList = e.FilterList;
getPageList(1);
}
///
/// 审核事件
///
///
///
private void ToolBarMenu1_btnChkClick(object sender, EventArgs e)
{
_toolCk(1);
}
///
/// 反审核
///
///
///
///
private void ToolBarMenu1_btnFChkClick(object sender, EventArgs e)
{
_toolCk(0);
}
///
/// 取消事件
///
///
///
private void ToolBarMenu1_btnEscClick(object sender, EventArgs e)
{
Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 1);
}
///
/// 删除事件
///
///
///
private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e)
{
string rowGuid = "", rowName = "";
(rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_Guid, gridView1);
//(rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_Guid, gridView1, "hourlyType");
if (string.IsNullOrEmpty(rowGuid))
{
ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
return;
}
if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定删除吗?"))
return;
List lst = new List();
lst.Add(rowGuid);
var _obj = new
{
guid = rowGuid,
mxGuid = Guid.Empty.ToString(),
};
try
{
string strJson = UtilityHelper.HttpPost("", _webServiceName + "DeleteModel", JsonConvert.SerializeObject(_obj));
ReturnModel _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
if (_rtn.rtnCode > 0)
{
if (xtraTabControl1.SelectedTabPageIndex == 0)
{ }
else
Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 2);
getPageList(this.pageBar1.CurrentPage);
}
ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
}
catch (Exception ex)
{
ToolBox.MsgHelper.Warning("提示:" + ex.Message);
}
}
///
/// 刷新事件
///
///
///
private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
{
if (xtraTabControl1.SelectedTabPageIndex == 1)
getModel(lbGuid.Text.Trim());
else
{
getPageList(this.pageBar1.CurrentPage);
}
}
///
/// 新增事件
///
///
///
private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
{
lbGuid.Text = "";
Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 4);
UtilityHelper.CleanValueByControl(this.layoutMx1.Controls, true);
getPageList(this.pageBar1.CurrentPage);
}
private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
{
string rowGuid, rowName;
(rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,lbGuid, txt_Guid, gridView1);
if (string.IsNullOrEmpty(rowGuid))
{
MsgHelper.Warning("请先选择你要操作的行!");
return;
}
Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 3);
getModel(rowGuid);
getPageList(this.pageBar1.CurrentPage);
}
///
/// 保存事件
///
///
///
private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
{
toolBarMenu1.isSetBtn = false;
string mjbm = txt_mjbm.Text.Trim();//模具编码
string mjmc = txt_mjmc.Text.Trim();//模具名称
string bz = txt_bz.Text.Trim();//备注
string mjgg = txt_mjgg.Text.Trim();//模具规格
string mjzt = txt_mjzt.Text.Trim();//模具状态
string khmsl = txt_khmsl.Text.Trim();//开合模数量
try
{
var _obj = new
{
guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
mjbm = mjbm,
mjmc = mjmc,
bz = bz,
mjgg = mjgg,
mjzt = mjzt,
khmsl = khmsl
};
string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj));
ReturnModel _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
if (_rtn.rtnCode > 0)
{
lbGuid.Text = _rtn.rtnData.outGuid;
toolBarMenu1.isSetBtn = true;
UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false);
toolBarMenu1.currentAction = "";
Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 6);
}
}
catch (Exception ex)
{
ToolBox.MsgHelper.Warning("提示:" + ex.Message);
}
}
///
///
///
/// 第几页
/// 每页几条
private void getPageList(int curPage)
{
gcMain1.DataSource = null; var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "", "", "", _sbSqlWhere.ToString());
var json = JsonConvert.SerializeObject(pgq);
try
{
var strReturn = UtilityHelper.HttpPost("",
_webServiceName + "GetListPage", json);
var dd = UtilityHelper.ReturnToTablePage(strReturn);
if (dd.rtnCode > 0)
{
DataTable dt = dd.rtnData.list;
gcMain1.BindingContext = new BindingContext();
gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
if (dt.Rows.Count > 0)
{
gcMain1.DataSource = dt;
gcMain1.ForceInitialize();
gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
}
else
UtilityHelper.SetDefaultTable(gcMain1, gridView1);
gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
pageBar1.TotalPages = dd.rtnData.pages;//总页
pageBar1.CurrentPage = curPage;//当前页
pageBar1.RecordCount = dd.rtnData.total;//总记录数
}
else
{
ToolBox.MsgHelper.ShowError("提示:" + dd.rtnMsg);
}
}
catch (Exception ex)
{
MsgHelper.ShowError("提示:" + ex.Message);
}
}
///
/// 子表查询
///
/// 主键
/// 是否可编辑
/// 选项卡序号
private void getModel(string strGuid)
{
bool isEdit = false;
if (toolBarMenu1.currentAction == "add") return;
if (toolBarMenu1.currentAction == "edit") isEdit = true;
if (string.IsNullOrEmpty(strGuid))
{
ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
return;
}
var _obj = new
{
guid = strGuid,//主建
};
try
{
string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj));
ReturnModel _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
if (_rtn.rtnCode > 0)
{
dynamic dy = _rtn.rtnData;
lbGuid.Text = strGuid;
UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit);
}
else
ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
}
catch (Exception ex)
{
ToolBox.MsgHelper.Warning("提示:" + ex.Message);
}
}
///
/// 工具条事件
///
///
private void _toolCk(int _inFieldValue)
{
string strMsg = "";
switch (_inFieldValue)
{
case 1:
strMsg = "审核";
break;
case 0:
strMsg = "反审核";
break;
}
;
toolBarMenu1.guidKey = "";
string rowGuid, rowName;
(rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_Guid, gridView1);
//(rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_SalaryType, gridView1, "hourlyType");
if (string.IsNullOrEmpty(rowGuid))
{
MsgHelper.Warning("请先选择你要操作的行!");
return;
}
if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定" + strMsg + "吗?"))
return;
var _obj = new
{
guid = rowGuid,
ckValue = _inFieldValue,
parameter = "YS_mjtz,check_Date,check_Status,check_user"
};
try
{
var strJson = UtilityHelper.HttpPost("", "General/GeneralCheck",
JsonConvert.SerializeObject(_obj));
var _rtn = UtilityHelper.ReturnToDynamic(strJson);
if (_rtn.rtnCode > 0)
{
MsgHelper.ShowInformation(_rtn.rtnData.outMsg.ToString());
if (xtraTabControl1.SelectedTabPageIndex == 1)
{
getModel(lbGuid.Text.Trim());
}
int rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], rowGuid);
gridView1.FocusedRowHandle = rowHandle;
UtilityHelper.SetCheckIco(gridView1, "checkStatus", "checkUser", "checkDate", picCheckBox, this, _inFieldValue.ToString());
}
else
MsgHelper.ShowError(_rtn.rtnData.outMsg.ToString());
}
catch (Exception ex)
{
MsgHelper.ShowError("提示:" + ex.Message);
}
}
}
}