|
using Newtonsoft.Json;
|
using sunui.forms;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Drawing;
|
using System.Threading;
|
using System.Windows.Forms;
|
using WMS.EnumDefine;
|
using WMS.UI.WORK;
|
using WMS.Untils;
|
using WMS.yunneiWCS;
|
using WZ.Useful.Commons;
|
|
namespace WMS.UI.Basic
|
{
|
public partial class FormPlaceSetting : Form
|
{
|
/// <summary>搜索的库位名称
|
///
|
/// </summary>
|
string positionNames = "";
|
/// <summary>是否锁定
|
///
|
/// </summary>
|
int islocks = 0;
|
/// <summary>是否有货
|
///
|
/// </summary>
|
int isfrees = 0;
|
/// <summary>每页数量
|
///
|
/// </summary>
|
int pagesize = 10;//
|
public FormPlaceSetting()
|
{
|
InitializeComponent();
|
dataGridView1.AutoGenerateColumns = false;
|
FormHelper.DataGridViewSelfAdaptionWidth(this.dataGridView1);
|
}
|
private void findData(paging paga, string positionName, int islock, int isfree)
|
{
|
try
|
{
|
var aa = toolStripComboBox1.SelectedItem;
|
var res = FLogin.wcsWcf.findPosition(paga, positionName, islock, isfree);
|
if (res.status == 200)
|
{
|
|
this.dataGridView1.DataSource = res.date;
|
this.toolStripLabel5.Text = "/" + res.total;
|
if (res.total == 1)
|
{
|
toolStripLabel2.Enabled = false;
|
toolStripTextBox1.Enabled = false;
|
toolStripLabel1.Enabled = false;
|
toolStripLabel4.Enabled = false;
|
toolStripLabel3.Enabled = false;
|
}
|
else
|
{
|
toolStripLabel3.Enabled = true;
|
toolStripLabel2.Enabled = true;
|
toolStripTextBox1.Enabled = true;
|
toolStripLabel4.Enabled =paga.pagenum==1?false: true;
|
|
}
|
}
|
else
|
{
|
MessageBox.Show("获取失败");
|
}
|
}
|
catch (Exception ex)
|
{
|
WZ.Useful.Commons.LogTextHelper.WriteLine("FormPlaceSetting", "findData", ex.ToString());
|
}
|
|
}
|
|
private void FormPlaceSetting_Load(object sender, EventArgs e)
|
{
|
paging paga = new paging();
|
paga.pagenum = 1;
|
paga.pagesize = 10;
|
findData(paga, "", 0, 0);
|
toolStripTextBox1.Text = "1";
|
toolStripLabel1.Enabled = false;
|
}
|
|
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
{
|
DataGridView dgv = (DataGridView)sender;
|
|
try
|
{
|
switch (dgv.Columns[e.ColumnIndex].Name)
|
{
|
|
case "isLock":
|
|
if ((bool)e.Value == true)
|
{
|
e.CellStyle.BackColor = Color.FromArgb(139, 58, 58);
|
}
|
|
e.Value = (bool)e.Value == true ? "锁定" : "未锁定";
|
break;
|
case "isfree":
|
if ((bool)e.Value == true)
|
{
|
e.CellStyle.BackColor = Color.FromArgb(69, 139, 116);
|
}
|
e.Value = (bool)e.Value == true ? "有货" : "无货";
|
|
break;
|
case "enable":
|
if ((bool)e.Value != true)
|
{
|
e.CellStyle.BackColor = Color.FromArgb(24, 116, 205);
|
}
|
e.Value = (bool)e.Value == true ? "可用" : "不可用";
|
break;
|
case "positionTpye":
|
|
e.Value =Enum.GetName(typeof(PositionType), e.Value); //PositionType
|
break;
|
default:
|
break;
|
}
|
}
|
catch (Exception )
|
{
|
|
}
|
|
|
}
|
|
/// <summary>查找
|
///
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnFind_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
|
islocks = comboBoxIsLock.SelectedIndex;
|
isfrees = comboBoxIsFree.SelectedIndex;
|
positionNames = textBoxPositionName.Text.Trim();
|
pagesize = (toolStripComboBox1.SelectedIndex + 1) * 10;
|
paging paga = new paging();
|
paga.pagenum = 1;
|
paga.pagesize = pagesize;
|
findData(paga, positionNames, islocks, isfrees);
|
toolStripTextBox1.Text = "1";
|
toolStripLabel1.Enabled = false;//上一页
|
toolStripLabel4.Enabled = false;//第一页
|
toolStripLabel2.Enabled = true;//下一页
|
toolStripLabel3.Enabled = true;//最后一页
|
}
|
catch (Exception)
|
{
|
|
}
|
}
|
/// <summary>复位
|
///
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnReset_Click(object sender, EventArgs e)
|
{
|
positionNames = textBoxPositionName.Text = "";
|
islocks = comboBoxIsLock.SelectedIndex = 0;
|
isfrees = comboBoxIsFree.SelectedIndex = 0;
|
paging paga = new paging();
|
paga.pagenum = 1;
|
paga.pagesize = 10;
|
findData(paga, positionNames, islocks, isfrees);
|
toolStripTextBox1.Text = "1";
|
}
|
/// <summary>分页回车键
|
///
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void toolStripTextBox1_KeyDown(object sender, KeyEventArgs e)
|
{
|
try
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
int numPapg = 0;
|
int.TryParse(toolStripTextBox1.Text.Trim(), out numPapg);
|
int sizetatol = 0;
|
int a = this.toolStripLabel5.Text.Trim().Length;
|
string size = this.toolStripLabel5.Text.Trim().Substring(1, a - 1);
|
int.TryParse(size, out sizetatol);
|
|
if (numPapg > 0 && numPapg <= sizetatol)
|
{
|
string Name = textBoxPositionName.Text.Trim();
|
paging paga = new paging();
|
paga.pagenum = numPapg;
|
paga.pagesize = pagesize;
|
findData(paga, positionNames, islocks, isfrees);
|
|
}
|
else
|
{
|
toolStripTextBox1.Text = "1";
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "请输入数字,并大于1且不大于总页数");
|
ms.Show();
|
}
|
}
|
}
|
catch (Exception)
|
{
|
|
}
|
}
|
/// <summary>下一页
|
///
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void toolStripLabel2_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
|
int numPapg = 0;
|
int.TryParse(toolStripTextBox1.Text.Trim(), out numPapg);
|
numPapg++;
|
toolStripTextBox1.Text = numPapg.ToString();
|
int sizetatol = 0;
|
int a = this.toolStripLabel5.Text.Trim().Length;
|
string size = this.toolStripLabel5.Text.Trim().Substring(1, a - 1);
|
int.TryParse(size, out sizetatol);
|
toolStripLabel4.Enabled = true;
|
if (numPapg <= sizetatol)
|
{
|
|
paging paga = new paging();
|
paga.pagenum = numPapg;
|
paga.pagesize = pagesize;
|
findData(paga, positionNames, islocks, isfrees);
|
toolStripLabel1.Enabled = true;
|
if (numPapg == sizetatol)
|
{
|
toolStripLabel2.Enabled = false;
|
}
|
}
|
else
|
{
|
toolStripTextBox1.Text = "1";
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "请输入数字,并大于1且不大于总页数");
|
ms.Show();
|
}
|
|
}
|
catch (Exception)
|
{
|
|
}
|
}
|
/// <summary>上一页
|
///
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void toolStripLabel1_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
|
int numPapg = 0;
|
int.TryParse(toolStripTextBox1.Text.Trim(), out numPapg);
|
numPapg--;
|
toolStripTextBox1.Text = numPapg.ToString();
|
int sizetatol = 0;
|
int a = this.toolStripLabel5.Text.Trim().Length;
|
string size = this.toolStripLabel5.Text.Trim().Substring(1, a - 1);
|
int.TryParse(size, out sizetatol);
|
|
if (numPapg <= sizetatol)
|
{
|
|
paging paga = new paging();
|
paga.pagenum = numPapg;
|
paga.pagesize = pagesize;
|
findData(paga, positionNames, islocks, isfrees);
|
toolStripLabel2.Enabled = true;
|
toolStripLabel3.Enabled = true;
|
if (numPapg == 1)
|
{
|
toolStripLabel1.Enabled = false;
|
}
|
}
|
else
|
{
|
toolStripTextBox1.Text = "1";
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "请输入数字,并大于1且不大于总页数");
|
ms.Show();
|
}
|
|
}
|
catch (Exception)
|
{
|
|
}
|
}
|
/// <summary>最后一页
|
///
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void toolStripLabel3_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
int sizetatol = 0;
|
int a = this.toolStripLabel5.Text.Trim().Length;
|
string size = this.toolStripLabel5.Text.Trim().Substring(1, a - 1);
|
int.TryParse(size, out sizetatol);
|
paging paga = new paging();
|
paga.pagenum = sizetatol;
|
paga.pagesize = pagesize;
|
findData(paga, positionNames, islocks, isfrees);
|
toolStripLabel3.Enabled = false;
|
toolStripLabel4.Enabled = true;
|
toolStripTextBox1.Text = sizetatol.ToString();
|
toolStripTextBox1.Enabled = true;
|
toolStripLabel1.Enabled = true;
|
toolStripLabel2.Enabled = false;
|
|
}
|
catch (Exception)
|
{
|
|
}
|
}
|
/// <summary>第一页
|
///
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void toolStripLabel4_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
paging paga = new paging();
|
paga.pagenum = 1;
|
paga.pagesize = pagesize;
|
findData(paga, positionNames, islocks, isfrees);
|
toolStripLabel4.Enabled = false;
|
toolStripLabel3.Enabled = true;
|
toolStripTextBox1.Text = "1";
|
toolStripTextBox1.Enabled = true;
|
toolStripLabel1.Enabled = false;
|
toolStripLabel2.Enabled = true;
|
|
}
|
catch (Exception)
|
{
|
|
}
|
}
|
/// <summary>每页数发生改变时
|
///
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
try
|
{
|
pagesize = (toolStripComboBox1.SelectedIndex + 1) * 10;
|
paging paga = new paging();
|
paga.pagenum = 1;
|
paga.pagesize = pagesize;
|
findData(paga, positionNames, islocks, isfrees);
|
toolStripTextBox1.Text = "1";
|
}
|
catch (Exception)
|
{
|
|
}
|
}
|
|
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
{
|
try
|
{
|
if (dataGridView1.Columns[e.ColumnIndex].Name == "edit")
|
{
|
int i = dataGridView1.CurrentRow.Index;
|
string ID = dataGridView1.Rows[i].Cells["positionId"].Value.ToString();
|
string name = dataGridView1.Rows[i].Cells["positionName"].Value.ToString();
|
int islock = dataGridView1.Rows[i].Cells["isLock"].Value.ToString()=="True"?1:0;
|
int isfree = dataGridView1.Rows[i].Cells["isfree"].Value.ToString() == "True" ? 1 : 0;
|
int enable = dataGridView1.Rows[i].Cells["enable"].Value.ToString() == "True" ? 1 : 0;//positionType
|
int types = Convert.ToInt32(dataGridView1.Rows[i].Cells["positionTpye"].Value);
|
placeEdit listView = new placeEdit(ID,name,islock,isfree,enable,types);
|
|
listView.ShowDialog();
|
if (listView.DialogResult == DialogResult.OK)
|
{
|
int numPapg = 0;
|
int.TryParse(toolStripTextBox1.Text.Trim(), out numPapg);
|
paging paga = new paging();
|
paga.pagenum = numPapg == 0 ? 1 : numPapg;
|
paga.pagesize = pagesize;
|
findData(paga, positionNames, islocks, isfrees);
|
}
|
}
|
}
|
catch (Exception)
|
{
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "出错了");
|
ms.Show();
|
}
|
|
}
|
|
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
|
{
|
SolidBrush b = new SolidBrush(this.dataGridView1.RowHeadersDefaultCellStyle.ForeColor);
|
e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), this.dataGridView1.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
|
|
}
|
|
}
|
}
|