using Sunny.UI;
|
using sunui.forms;
|
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 WMS.Untils;
|
using WMS.yunneiWCS;
|
|
namespace WMS.UI.Basic
|
{
|
public partial class material : UIPage
|
{
|
int pagesize = 10;//
|
string name = "";
|
string code = "";
|
//物料管理
|
public material()
|
{
|
InitializeComponent();
|
dataGridView1.AutoGenerateColumns = false;
|
this.dataGridView1.Columns["createTime"].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss";
|
this.dataGridView1.Columns["modifierTime"].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss";
|
FormHelper.DataGridViewSelfAdaptionWidth(this.dataGridView1);
|
}
|
private void material_Load(object sender, EventArgs e)
|
{
|
try
|
{
|
paging paga = new paging();
|
paga.pagenum = 1;
|
paga.pagesize = 10;
|
findData(paga, "", "");
|
toolStripTextBox1.Text = "1";
|
}
|
catch (Exception)
|
{
|
}
|
|
}
|
/// <summary>查找数据
|
///
|
/// </summary>
|
/// <param name="paga">分页</param>
|
/// <param name="materialName">物料名称</param>
|
/// <param name="materialCode">物料编号</param>
|
private void findData(paging paga, string materialName, string materialCode)
|
{
|
|
try
|
{
|
//每页10条
|
//每页20条
|
//每页30条
|
//每页100条
|
var aa = toolStripComboBox1.SelectedItem;
|
var res = FLogin.wcsWcf.findMaterial(paga, materialName, materialCode);
|
if (res.status == 200)
|
{
|
this.dataGridView1.DataSource = null;
|
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
|
{
|
this.dataGridView1.DataSource = null;
|
this.toolStripLabel5.Text = "/" + 0;
|
MessageBox.Show("获取失败");
|
}
|
}
|
catch (Exception ex)
|
{
|
WZ.Useful.Commons.LogTextHelper.WriteLine("AddUser", "btnSave_Click", ex.ToString());
|
|
}
|
|
}
|
|
private void materialAdd_Click(object sender, EventArgs e)
|
{
|
addMaterial addmaterial = new addMaterial(1,0,"","",3,"");
|
|
addmaterial.ShowDialog();
|
if (addmaterial.DialogResult == DialogResult.OK)
|
{
|
this.btnReset_Click(null, null);//刷新主窗体
|
}
|
|
}
|
|
private void btnFind_Click(object sender, EventArgs e)
|
{
|
name= textBoxMaterialName.Text.Trim();
|
code= textBoxMaterialCode.Text.Trim();
|
try
|
{
|
paging paga = new paging();
|
paga.pagenum = 1;
|
paga.pagesize = 10;
|
findData(paga, name, code);
|
toolStripTextBox1.Text = "1";
|
}
|
catch (Exception)
|
{
|
}
|
}
|
/// <summary>复位
|
///
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnReset_Click(object sender, EventArgs e)
|
{
|
textBoxMaterialName.Text = "";
|
textBoxMaterialCode.Text = "";
|
name = "";
|
code = "";
|
try
|
{
|
paging paga = new paging();
|
paga.pagenum = 1;
|
paga.pagesize = pagesize;
|
findData(paga, "", "");
|
toolStripTextBox1.Text = "1";
|
}
|
catch (Exception)
|
{
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "出错了");
|
ms.Show();
|
}
|
}
|
|
|
/// <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)
|
{
|
paging paga = new paging();
|
paga.pagenum = numPapg;
|
paga.pagesize = pagesize;
|
findData(paga, name, code);
|
}
|
else
|
{
|
toolStripTextBox1.Text = "1";
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "请输入数字,并不大于总页数");
|
ms.Show();
|
}
|
}
|
}
|
catch (Exception)
|
{
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "出错了");
|
ms.Show();
|
}
|
}
|
|
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
{
|
try
|
{
|
if (dataGridView1.Columns[e.ColumnIndex].Name == "edit")
|
{
|
int i = dataGridView1.CurrentRow.Index;
|
int id =Convert.ToInt32( dataGridView1.Rows[i].Cells["materialId"].Value.ToString());
|
if (id==3||id==4)
|
{
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "空托盘不允许编辑");
|
ms.Show();
|
return;
|
}
|
string code = dataGridView1.Rows[i].Cells["materialCode"].Value.ToString();
|
string name = dataGridView1.Rows[i].Cells["materialName"].Value.ToString();
|
int type = dataGridView1.Rows[i].Cells["materialType"].Value.ToString()=="1"?1:0;
|
string version = dataGridView1.Rows[i].Cells["version"].Value == null ? "" : dataGridView1.Rows[i].Cells["version"].Value.ToString();
|
addMaterial addmaterial = new addMaterial(2, id, code, name, type, version);
|
|
addmaterial.ShowDialog();
|
if (addmaterial.DialogResult == DialogResult.OK)
|
{
|
this.btnReset_Click(null, null);//刷新主窗体
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(1, "修改成功");
|
ms.Show();
|
}
|
else
|
{
|
this.btnReset_Click(null, null);//刷新主窗体
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "修改失败");
|
ms.Show();
|
}
|
}
|
if (dataGridView1.Columns[e.ColumnIndex].Name == "delete")
|
{
|
int i = dataGridView1.CurrentRow.Index;
|
int id = Convert.ToInt32(dataGridView1.Rows[i].Cells["materialId"].Value.ToString());
|
if (id == 3 || id == 4)
|
{
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "空托盘不允许删除");
|
ms.Show();
|
return;
|
}
|
string res = FLogin.wcsWcf.materialOP(3, id, "", "", 0,"");
|
if (res=="")
|
{
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(1, "删除成功");
|
ms.Show();
|
btnReset_Click(null,null);
|
}
|
else
|
{
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, res);
|
ms.Show();
|
}
|
}
|
}
|
catch (Exception)
|
{
|
WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "出错了");
|
ms.Show();
|
}
|
}
|
|
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
{
|
try
|
{
|
if (dataGridView1.DataSource != null)
|
{
|
DataGridView dgv = (DataGridView)sender;
|
|
switch (dgv.Columns[e.ColumnIndex].Name)
|
{
|
case "materialType":
|
if ((int)e.Value<2)
|
{
|
e.Value = (int)e.Value == 1 ? "缸体" : "缸盖";
|
}
|
else
|
{
|
e.Value = "空托盘";
|
}
|
e.FormattingApplied = true;
|
break;
|
|
default:
|
break;
|
}
|
}
|
}
|
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,name,code );
|
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 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, name, code);
|
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, name, code);
|
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 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, name, code);
|
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)
|
{
|
|
}
|
}
|
|
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, name, code);
|
toolStripTextBox1.Text = "1";
|
}
|
catch (Exception)
|
{
|
|
}
|
}
|
|
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);
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
}
|