?? removeadd.aspx.cs
字號:
?using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Model;
namespace 金利來分銷管理系統.Remove
{
public partial class RemoveAdd : System.Web.UI.Page
{
bool x = true;
DataTable dt;
//實例化的BLL層
BLL.Remove.RemoveBll bllshow;
BLL.Goods.ProductBll productbllshow;
BLL.Store.StoreBll storeIDshow;
List<Model.Remove.RemoveModel> show = new List<Model.Remove.RemoveModel>();
public RemoveAdd()
{
bllshow = new BLL.Remove.RemoveBll();
productbllshow = new BLL.Goods.ProductBll();
storeIDshow = new BLL.Store.StoreBll();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
//將所有商品編號添加到DropDownList
List<Model.Goods.ProductModel> productid = productbllshow.SelectProductID();
foreach (var item in productid)
{
this.ddlProductID.Items.Add(item.product_id);
}
//獲取當天時間
this.lblRemoveID.Text = "DB" + DateTime.Now.ToString("yyyyMMddhhmmssfff");
//將所有分店編號添加到DropDownList
List<Model.Store.StoreModel> storeid = storeIDshow.SelectStoreID();
foreach (var item in storeid)
{
this.ddlstorego.Items.Add(item.store_id.ToString());
this.ddlstoreto.Items.Add(item.store_id.ToString());
}
}
}
private void createDT()
{
dt = new DataTable();
dt.Columns.Add("商品ID");
dt.Columns.Add("商品顏色");
dt.Columns.Add("31");
dt.Columns.Add("32");
dt.Columns.Add("33");
dt.Columns.Add("34");
dt.Columns.Add("35");
dt.Columns.Add("36");
dt.Columns.Add("37");
dt.Columns.Add("數量");
dt.Columns.Add("始");
dt.Columns.Add("至");
}
//通過商品ID查詢該商品信息
protected void ddlProductID_SelectedIndexChanged(object sender, EventArgs e)
{
//當未選擇商品編號時
if (this.ddlProductID.Text == "請選擇商品編號")
{
//提示“請選擇商品編號”
this.lblproductidcheck.Visible = true;
}
else
{
//提示框“請選擇商品編號”
this.lblproductidcheck.Visible = false;
}
//顏色框的值清空
ddlColor.Items.Clear();
txtProductName.Text = "";
//獲取商品信息
List<Model.Goods.ProductModel> p = productbllshow.SelectProductByID(this.ddlProductID.Text);
foreach (Model.Goods.ProductModel item in p)
{
ddlColor.Items.Add(item.producttype_color);
this.txtProductName.Text = item.product_name;
this.lblsize1.Text = item.producttype_s1.ToString();
this.lblsize2.Text = item.producttype_s2.ToString();
this.lblsize3.Text = item.producttype_s3.ToString();
this.lblsize4.Text = item.producttype_s4.ToString();
this.lblsize5.Text = item.producttype_s5.ToString();
this.lblsize6.Text = item.producttype_s6.ToString();
this.lblsize7.Text = item.producttype_s7.ToString();
}
this.txtSize1.Text = "0";
this.txtSize2.Text = "0";
this.txtSize3.Text = "0";
this.txtSize4.Text = "0";
this.txtSize5.Text = "0";
this.txtSize6.Text = "0";
this.txtSize7.Text = "0";
}
//提交申請單到ViewState["dt"]
protected void btnSubmit_Click(object sender, EventArgs e)
{
this.lblSum.Visible = false;
this.lblShow.Visible = false;
//當商品編號選擇為‘請選擇商品編號’
if (this.ddlProductID.SelectedValue != "請選擇商品編號")
{
//發貨倉庫和接受倉庫都有選擇時
if (this.ddlstorego.Text != "請選擇門店編號" && this.ddlstoreto.Text != "請選擇門店編號")
{
if (ViewState["dt"] == null)
{
createDT();
}
else
{
dt = (DataTable)ViewState["dt"];
}
DataRow dr = dt.NewRow();
dr[0] = this.ddlProductID.Text.Trim();
dr[1] = this.ddlColor.Text;
dr[2] = this.txtSize1.Text;
dr[3] = this.txtSize2.Text;
dr[4] = this.txtSize3.Text;
dr[5] = this.txtSize4.Text;
dr[6] = this.txtSize5.Text;
dr[7] = this.txtSize6.Text;
dr[8] = this.txtSize7.Text;
dr[9] = Convert.ToInt32(this.txtSize1.Text) + Convert.ToInt32(this.txtSize2.Text) + Convert.ToInt32(this.txtSize3.Text) + Convert.ToInt32(this.txtSize4.Text) + Convert.ToInt32(this.txtSize5.Text) + Convert.ToInt32(this.txtSize6.Text) + Convert.ToInt32(this.txtSize7.Text);
dr[10] = this.ddlstorego.Text;
dr[11] = this.ddlstoreto.Text;
int s1 = int.Parse(this.txtSize1.Text);
int s2 = int.Parse(this.txtSize2.Text);
int s3 = int.Parse(this.txtSize3.Text);
int s4 = int.Parse(this.txtSize4.Text);
int s5 = int.Parse(this.txtSize5.Text);
int s6 = int.Parse(this.txtSize6.Text);
int s7 = int.Parse(this.txtSize7.Text);
//如果數量都是為“零”
if (int.Parse(dr[9].ToString()) == 0)
{
this.lblSum.Visible = true;
}
//大于零的時候
else
{
//通過商品在庫存中
Model.Store.StoreModel storemodel = storeIDshow.SelectStoreByProduct(int.Parse(this.ddlstorego.Text), this.ddlProductID.Text, this.ddlColor.Text);
//在dt表里的每一行循環
foreach (DataRow item in dt.Rows)
{
//提交的信息,與dt表里存在的信息做對比
if (int.Parse(this.ddlstorego.Text) == Convert.ToInt32(item[10]) && this.ddlProductID.Text.Trim() == item[0].ToString() && this.ddlColor.Text.Trim() == item[1].ToString())
{
//開始記錄該倉庫,該商品,該顏色,在dt表里已存在的尺碼數量
s1 += Convert.ToInt32(item[2]);
s2 += Convert.ToInt32(item[3]);
s3 += Convert.ToInt32(item[4]);
s4 += Convert.ToInt32(item[5]);
s5 += Convert.ToInt32(item[6]);
s6 += Convert.ToInt32(item[7]);
s7 += Convert.ToInt32(item[8]);
//該倉庫,該商品,該顏色的信息,是否小于(提交的信息加dt表里所對應的信息)
if (storemodel.store_size1 < s1 || storemodel.store_size2 < s2 || storemodel.store_size3 < s3 || storemodel.store_size4 < s4 || storemodel.store_size5 < s5 || storemodel.store_size6 < s6 || storemodel.store_size7 < s7)
{
this.lblShow.Visible = true;
//如果小于添加的數額,跳出
return;
}
}
}
//判斷每次提交的數量,是否是小于倉庫的數量
if (storemodel.store_size1 < int.Parse(this.txtSize1.Text) || storemodel.store_size2 < int.Parse(this.txtSize2.Text) || storemodel.store_size3 < int.Parse(this.txtSize3.Text) || storemodel.store_size4 < int.Parse(this.txtSize4.Text) || storemodel.store_size5 < int.Parse(this.txtSize5.Text) || storemodel.store_size6 < int.Parse(this.txtSize6.Text) || storemodel.store_size7 < int.Parse(this.txtSize7.Text))
{
this.lblShow.Visible = true;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -