protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["HAWB"] != null) { hawb = (HAWB)Session["HAWB"]; if (Request.QueryString["type"] != "" && Request.QueryString["type"]!=null) { type = Request.QueryString["type"]; gv_Box.DataSource = hawb.HAWBBoxes; gv_Box.DataBind(); GV_item.DataSource = hawb.HAWBItems; GV_item.DataBind(); } else { item = new HAWBItem(); box = new HAWBBox(); gv_item(); gv_box(); } Evaluate(); ViewState["UrlReferrer"] = Request.UrlReferrer.ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { hawb = (HAWB)Session["HAWB"]; if (!IsPostBack) { if (Session["HAWB"] != null) { if (Request.QueryString["type"] == "Amend")//修改页面显示 { type = Request.QueryString["type"]; ViewState["type"] = type; But_AddHAWB.Text = "保 存"; gv_Box.DataSource = hawb.HAWBBoxes; gv_Box.DataBind(); GV_item.DataSource = hawb.HAWBItems; GV_item.DataBind(); } else //新建页面显示 { item = new HAWBItem(); box = new HAWBBox(); gv_item(); gv_box(); But_AddHAWB.Text = "创 建"; } Evaluate(); BoxType(); ViewState["UrlReferrer"] = Request.UrlReferrer.ToString(); } else { Response.Write("<script>alert('请先填写用户信息!');location='HAWBAdd.aspx'</script>"); } } }
public void RemoveHAWBBox(HAWBBox box) { box.MarkAsDeleted(); this.HAWBBoxes.Remove(box); }
protected void but_AddBox_Click(object sender, EventArgs e) { if (type != "") { foreach (HAWBBox bx in hawb.HAWBBoxes) { box.BoxID = bx.BoxID; AddBox(); } } else { box = new HAWBBox(); box.BoxID = Guid.NewGuid(); AddBox(); } }
public void TestAddHAWB() { //实力化一个虚假运单对象 HAWB HAWBObj = new HAWB { HID=Guid.NewGuid(), BarCode = "2010", //条形码 Carrier = "中国航空", //承运单位 SettleType = 0, //预算方式 ServiceType = 0, //快件或包裹 CreateTime = DateTime.Now, //创建日期 Status = 0, //运单状态 ShipperName = "沈志伟", //发件人姓名或者公司 ShipperContactor = "沈志伟", //发件人姓名 ShipperCountry = "01", //发件人国家 ShipperRegion = "021", //发件人区号 ShipperAddress = "test address", //发件人地址 ShipperZipCode = "200435", //发件人邮编 ShipperTel = "13817011234", //发件人联系电话 ConsigneeContactor = "李宏", //收件人姓名 ConsigneeCountry = "02", //收件人国家 ConsigneeRegion = "022", //收件人区号 ConsigneeAddress = "Japan address", //收件人地址 ConsigneeZipCode = "201011", //收件人邮编 ConsigneeTel = "120120", //收件人联系电话 WeightType = 2, //计重方式 TotalVolume = 10, //总体积 TotalWeight = 10, //总重量 Piece = 10, //件数 IsInternational = true //是否是国际运单 }; //定义盒子 HAWBBox HAWBBox01 = new HAWBBox { BoxType = 0, //盒子类型 Weight = 10, //重量 TransCurrency = 0, //运费货币 Piece = 10 //件数 }; HAWBBox HAWBBox02 = new HAWBBox { BoxType = 0, //盒子类型 Weight = 20, //重量 TransCurrency = 0, //运费货币 Piece = 20 //件数 }; //定义货物 HAWBItem HAWBItem01 = new HAWBItem { Name = "货物01", //货物名称 Piece = 10, //货物件数 UnitAmount = 10, //单价 TotalAmount = 10 //总价 }; HAWBItem HAWBItem02 = new HAWBItem { Name = "货物02", //货物名称 Piece = 20, //货物件数 UnitAmount = 20, //单价 TotalAmount = 20 //总价 }; //定义企业用户 User user01 = new User { LoginName = "test001", //注册名 Password = "******", //密码 RealName = "张三", //真实姓名 //Department = "研发部", //部门名称 //PostCode = "200435", //邮政编码 Phone = "110", //电话 //CountryCode = "01", //国家编号 //RegionCode = "01", //区域编号 //Address = "XXX路XXX号", //地址 UpdateTime = DateTime.Now, //更新日期 CreateTime = DateTime.Now, //创建日期 Operator = "沈志伟", //操作人 FeeDiscountType = 0, //费用折扣类型 FeeDiscountRate = 1, //费用折扣率 WeightDiscountType = 0, //重量折扣类型 WeightDiscountRate = 1, //重量折扣率 SettleType = 0, //结算类型 WeightCalType = 0, //计量方式 Status = 0 //可用状态 }; //in HAWBObj.HAWBBoxes.Add(HAWBBox01); //HAWBObj.HAWBBox.Add(HAWBBox02); //HAWBObj.HAWBItems.Add(HAWBItem01); //HAWBObj.HAWBItem.Add(HAWBItem02); HAWBObj.User = user01; //begin _HAWBManagementService.AddHAWB(HAWBObj); }
/// <summary> /// 包裹删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gv_Box_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { int inex = Convert.ToInt16(e.CommandArgument); Guid id = Guid.Parse(gv_Box.DataKeys[inex].Value.ToString()); foreach (HAWBBox bx in hawb.HAWBBoxes) { if (bx.BoxID == id) { box = bx; } } hawb.HAWBBoxes.Remove(box); Session["HAWB"] = hawb; txt_TotalWeight.Text = hawb.TotalWeight.ToString(); Txt_VolumeWeight.Text = hawb.VolumeWeight.Value.ToString(); lbl_Piece.Text = hawb.Piece.ToString(); gv_Box.DataSource = hawb.HAWBBoxes; gv_Box.DataBind(); } }
/// <summary> /// 包裹更新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gv_Box_RowUpdating(object sender, GridViewUpdateEventArgs e) { int inex = Convert.ToInt16(e.RowIndex); Guid id = Guid.Parse(gv_Box.DataKeys[inex].Value.ToString()); foreach (HAWBBox bx in hawb.HAWBBoxes) { if (bx.BoxID == id) { box = bx; } } if (((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxPiece") as TextBox).Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('包裹件数不能为空!')</script>"); ((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxPiece") as TextBox).Focus(); } else if (((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxWeight") as TextBox).Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('包裹重量不能为空!')</script>"); ((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxWeight") as TextBox).Focus(); } else { if (!Regex.IsMatch(((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxPiece") as TextBox).Text.Trim(), intPattern)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('件数只能输入整数!')</script>"); ((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxPiece") as TextBox).Focus(); } else if (!Regex.IsMatch(((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxWeight") as TextBox).Text.Trim(), decimalPattern)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('重量只能整数或小数且小数点后保留2位!')</script>"); ((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxWeight") as TextBox).Focus(); } else if (!Regex.IsMatch(((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxHeight") as TextBox).Text.Trim(), decimalPattern) && ((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxHeight") as TextBox).Text.Trim() != "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('高度只能整数或小数且小数点后保留2位!')</script>"); ((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxHeight") as TextBox).Focus(); } else if (!Regex.IsMatch(((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxLength") as TextBox).Text.Trim(), decimalPattern) && ((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxLength") as TextBox).Text.Trim() != "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('长度只能整数或小数且小数点后保留2位!')</script>"); ((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxLength") as TextBox).Focus(); } else if (!Regex.IsMatch(((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxWidth") as TextBox).Text.Trim(), decimalPattern) && ((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxWidth") as TextBox).Text.Trim() != "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('宽度只能整数或小数且小数点后保留2位!')</script>"); ((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxWidth") as TextBox).Focus(); } else { if (((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxHeight") as TextBox).Text.Trim() != "") { box.Height = decimal.Parse(((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxHeight") as TextBox).Text.Trim()); } if (((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxLength") as TextBox).Text.Trim() != "") { box.Length = decimal.Parse(((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxLength") as TextBox).Text.Trim()); } box.Piece = int.Parse(((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxPiece") as TextBox).Text.Trim()); if (((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxWeight") as TextBox).Text.Trim() != "") { box.Weight = decimal.Parse(((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxWeight") as TextBox).Text.Trim()); } if (((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxWidth") as TextBox).Text.Trim() != "") { box.Width = decimal.Parse(((TextBox)gv_Box.Rows[e.RowIndex].FindControl("txt_BoxWidth") as TextBox).Text.Trim()); } hawb.HAWBBoxes.Add(box); Txt_VolumeWeight.Text = hawb.VolumeWeight.Value.ToString(); txt_TotalWeight.Text = hawb.TotalWeight.ToString(); lbl_Piece.Text = hawb.Piece.ToString(); gv_Box.EditIndex = -1; Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('更新成功!')</script>"); gv_Box.DataSource = hawb.HAWBBoxes; gv_Box.DataBind(); } } }
/// <summary> /// 添加物品 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void but_AddBox_Click(object sender, EventArgs e) { box = new HAWBBox(); box.BoxID = Guid.NewGuid(); AddBox(); }