using FineUIPro;
using iWareDataCore.BASE.Service;
using iWareWms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
namespace iWareWms.View.SL.WareHouse
{
public partial class WareHouse : PageBase
{
//#region ViewPower
/////
///// 本页面的浏览权限,空字符串表示本页面不受权限控制
/////
//public override string ViewPower
//{
// get
// {
// return "浏览库存";
// }
//}
//#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadData();
}
}
private void LoadData()
{
InitialForRack(1, 15, 16, Panel1);
InitialForRack2(1, 29, 16, Panel2);
BindingPlace1("1");
BindingPlace2("1");
}
/////
///// 库位状态与颜色绑定
/////
private void BindingPlace1(string layer)
{
var srv = WareHouseService.GetInstance();
var NoUseplacelst=srv.GetALlNoUsePlace();
List emptyPlaceLst = srv.GetEmptyInPlace();
List inStockPlaceLst = srv.GetItemInPlace();
List lockedPlaceLst = srv.GetLockedPlace();
lab1.Text = "2";
lab2.Text = emptyPlaceLst.Count.ToString();
//lab3.Text = emptyPlaceLst.Count.ToString();
lab4.Text = inStockPlaceLst.Count.ToString();
lab5.Text = lockedPlaceLst.Count.ToString();
foreach (Control c in Panel1.Controls)
{
if (c is Panel)
{
foreach (Control btn in c.Controls)
{
if (btn is Button)
{
Button b = btn as Button;
string listFind = "";
listFind = emptyPlaceLst.Find(x => x == b.Text.Trim());
if (!string.IsNullOrEmpty(listFind))
{
b.CssClass = "GrayFont";
}
listFind = inStockPlaceLst.Find(x => x == b.Text.Trim());
if (!string.IsNullOrEmpty(listFind))
{
b.CssClass = "GreenFont";
}
listFind = lockedPlaceLst.Find(x => x == b.Text.Trim());
if (!string.IsNullOrEmpty(listFind))
{
b.CssClass = "RedFont";
}
if (b.Text == "20103" )
{
b.Text = "出库口";
b.CssClass = "BlackFont";
}
if (b.Text == "60111" )
{
b.Text = "入库口";
b.CssClass = "BlackFont";
}
if (NoUseplacelst.Contains(b.Text))
{
b.Text = "";
b.CssClass = "WriteFont";
}
}
}
}
}
}
///
/// 库位与颜色绑定
///
///
private void BindingPlace2(string layer)
{
var srv = WareHouseService.GetInstance();
List emptyPlaceLst = srv.GetEmptyInPlace();
List inStockPlaceLst = srv.GetItemInPlace();
List lockedPlaceLst = srv.GetLockedPlace();
lab6.Text = "2";
lab7.Text = emptyPlaceLst.Count.ToString();
//lab3.Text = emptyPlaceLst.Count.ToString();
lab9.Text = inStockPlaceLst.Count.ToString();
lab10.Text = lockedPlaceLst.Count.ToString();
foreach (Control c in Panel2.Controls)
{
if (c is Panel)
{
foreach (Control btn in c.Controls)
{
if (btn is Button)
{
Button b = btn as Button;
string listFind = "";
listFind = emptyPlaceLst.Find(x => x == b.Text.Trim());
if (!string.IsNullOrEmpty(listFind))
{
b.CssClass = "GrayFont";
}
listFind = inStockPlaceLst.Find(x => x == b.Text.Trim());
if (!string.IsNullOrEmpty(listFind))
{
b.CssClass = "GreenFont";
}
listFind = lockedPlaceLst.Find(x => x == b.Text.Trim());
if (!string.IsNullOrEmpty(listFind))
{
b.CssClass = "RedFont";
}
}
}
}
}
}
///
/// 根据列和层数初始化模型1-15
///
/// 控件
/// 列
/// 层
private void InitialForRack(int row, int layer, int column, Panel panel)
{
string r = "0" + row;
string l = "";
string c = "";
for (int i = layer; i >= 1; i--)
{
Panel pl = new Panel()
{
BoxFlex = 1,
TableRowspan = 1,
Layout = LayoutType.HBox,
TableColspan = 16,
BoxConfigChildMargin = "3 3 3 3",
ShowHeader = false
};
string rr = "";
for (int j = 1; j <= column; j++)
{
if (j < 10)
{
c = "0" + j.ToString();
}
else if (j >= 10)
{
c = j.ToString();
}
if (i < 10)
{
l = "0" + i.ToString();
}
else if (i >= 10)
{
l = i.ToString();
}
if ((j % 2) == 0)
{
rr = (j / 2).ToString();
}
if ((j%2) == 1)
{
rr = ((j / 2)+1).ToString();
}
string text1 = rr + l + c;
Button btn = new Button()
{
BoxFlex = 1,
TableRowspan = 1,
TableColspan = 1,
BoxConfigChildMargin = "3 3 3 3",
Text = text1,
CssClass = "GrayFont",
EnablePostBack = false
};
pl.Items.Add(btn);
}
panel.Items.Add(pl);
}
}
///
/// 根据列和层数初始化模型16-29
///
/// 控件
/// 列
/// 层
private void InitialForRack2(int row, int layer, int column, Panel panel)
{
string r = "0" + row;
string l = "";
string c = "";
for (int i = layer; i >= 16; i--)
{
Panel pl = new Panel()
{
BoxFlex = 1,
TableRowspan = 1,
Layout = FineUIPro.LayoutType.HBox,
TableColspan = 16,
BoxConfigChildMargin = "3 3 3 3",
ShowHeader = false
};
string rr = "";
for (int j = 1; j <= column; j++)
{
if (j < 10)
{
c = "0" + j.ToString();
}
else if (j >= 10)
{
c = j.ToString();
}
l = i.ToString();
if ((j % 2) == 0)
{
rr = (j / 2).ToString();
}
if ((j % 2) == 1)
{
rr = ((j / 2) + 1).ToString();
}
string text1 = rr + l + c;
FineUIPro.Button btn = new FineUIPro.Button()
{
BoxFlex = 1,
TableRowspan = 1,
TableColspan = 1,
BoxConfigChildMargin = "3 3 3 3",
Text = text1,
CssClass = "GrayFont",
EnablePostBack = false
};
pl.Items.Add(btn);
}
panel.Items.Add(pl);
}
}
protected void TabStrip1_TabIndexChanged(object sender, EventArgs e)
{
if (TabStrip1.ActiveTabIndex == 0)
{
BindingPlace1("1");
}
else
{
BindingPlace2("1");
}
}
}
}