提交代码

This commit is contained in:
2024-03-07 09:08:49 +08:00
parent 7038d9c601
commit 5996712fce
19 changed files with 2241 additions and 1462 deletions
@@ -1,5 +1,8 @@
using BLL;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
namespace FineUIPro.Web.TestRun.DriverGoods
{
@@ -15,9 +18,7 @@ namespace FineUIPro.Web.TestRun.DriverGoods
{
if (!IsPostBack)
{
BLL.UserService.InitUserDropDownList(this.drpCompileMan, this.CurrUser.LoginProjectId, true);
string id = Request.Params["id"];
string id = Request.Params["GoodsBuyId"];
if (!string.IsNullOrEmpty(id))
{
Model.DriverGoods_GoodsBuy data = BLL.GoodsBuyService.GetGoodsBuyById(id);
@@ -25,18 +26,27 @@ namespace FineUIPro.Web.TestRun.DriverGoods
{
this.hdId.Text = id;
this.txtCode.Text = data.Code;
this.txtBuyName.Text = data.BuyName;
this.txtBuyCode.Text = data.BuyCode;
if (!string.IsNullOrEmpty(data.CompileMan))
if (!string.IsNullOrEmpty(data.BuyCode))
{
this.drpCompileMan.SelectedValue = data.CompileMan;
this.hdBuyCode.Text = data.BuyCode;
this.txtBuyName.Text = GoodsBuyService.ConvertBugType(data.BuyCode);
}
this.txtUnitCode.Text = data.UnitCode;
var list = from x in Funs.DB.View_DriverGoods_GoodsBuyItem where x.GoodsBuyId == id orderby x.Code select x;
this.Grid1.DataSource = list;
this.Grid1.DataBind();
if (list.Count() > 0)
{
var ids = list.Select(x => x.GoodsModelId).ToArray();
this.hdItemsString.Text = Funs.GetStringByArray(ids);
}
this.txtApprovalDate.Text = data.ApprovalDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.ApprovalDate) : "";
this.txtSubmitDate.Text = data.SubmitDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.SubmitDate) : "";
this.txtGetGoodsDate.Text = data.GetGoodsDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.GetGoodsDate) : "";
this.txtRemark.Text = data.Remark;
}
}
else
{
this.hdBuyCode.Text = Request.Params["BuyCode"];
this.txtBuyName.Text = GoodsBuyService.ConvertBugType(this.hdBuyCode.Text);
}
}
}
#endregion
@@ -65,19 +75,14 @@ namespace FineUIPro.Web.TestRun.DriverGoods
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
string id = Request.Params["id"];
string id = Request.Params["GoodsBuyId"];
Model.DriverGoods_GoodsBuy newData = new Model.DriverGoods_GoodsBuy();
newData.Code = this.txtCode.Text.Trim();
newData.BuyName = this.txtBuyName.Text.Trim();
newData.BuyCode = this.txtBuyCode.Text.Trim();
if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
{
newData.CompileMan = this.drpCompileMan.SelectedValue;
}
newData.ApprovalDate = Funs.GetNewDateTime(this.txtApprovalDate.Text.Trim());
newData.SubmitDate = Funs.GetNewDateTime(this.txtSubmitDate.Text.Trim());
newData.GetGoodsDate = Funs.GetNewDateTime(this.txtGetGoodsDate.Text.Trim());
newData.Remark = this.txtRemark.Text.Trim();
newData.BuyCode = this.hdBuyCode.Text.Trim();
newData.UnitCode = this.txtUnitCode.Text.Trim();
newData.CompileMan = this.CurrUser.UserId;
newData.ApprovalDate = DateTime.Now;
newData.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(id))
{
@@ -97,9 +102,122 @@ namespace FineUIPro.Web.TestRun.DriverGoods
}
BLL.GoodsBuyService.AddGoodsBuy(newData);
}
BLL.GoodsBuyItemService.DeleteGoodsBuyItemByGoodsBuyId(newData.GoodsBuyId);
var details = jerqueSaveList();
foreach (var detail in details)
{
Model.DriverGoods_GoodsBuyItem item = new Model.DriverGoods_GoodsBuyItem();
item.GoodsBuyItemId = SQLHelper.GetNewID();
item.GoodsBuyId = newData.GoodsBuyId;
item.GoodsModelId = detail.GoodsModelId;
item.Quantity = detail.Quantity;
item.RequiredTime = detail.RequiredTime;
BLL.GoodsBuyItemService.AddGoodsBuyItem(item);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
#region
/// <summary>
/// 搜索
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNew_Click(object sender, EventArgs e)
{
string window = String.Format("ShowGoodsModel.aspx?Ids={0}", hdItemsString.Text, "查找 - ");
PageContext.RegisterStartupScript(Window1.GetSaveStateReference(hdItemsString.ClientID) + Window1.GetShowReference(window));
}
#endregion
#region Grid集合
/// <summary>
/// 检查并保存集合
/// </summary>
private List<Model.View_DriverGoods_GoodsBuyItem> jerqueSaveList()
{
var models = from x in Funs.DB.DriverGoods_GoodsModel where x.ProjectId == this.CurrUser.LoginProjectId select x;
List<Model.View_DriverGoods_GoodsBuyItem> details = new List<Model.View_DriverGoods_GoodsBuyItem>();
foreach (JObject mergedRow in Grid1.GetMergedData())
{
JObject values = mergedRow.Value<JObject>("values");
int i = mergedRow.Value<int>("index");
Model.View_DriverGoods_GoodsBuyItem detail = new Model.View_DriverGoods_GoodsBuyItem();
detail.GoodsModelId = this.Grid1.Rows[i].RowID;
Model.DriverGoods_GoodsModel model = models.FirstOrDefault(x => x.GoodsModelId == detail.GoodsModelId);
detail.Purpose = model.Purpose;
detail.Description = model.Description;
detail.Attachment = model.Attachment;
detail.Remark = model.Remark;
detail.Quantity = values.Value<string>("Quantity");
string requiredTime = values.Value<string>("RequiredTime");
if (!string.IsNullOrEmpty(requiredTime))
{
detail.RequiredTime = Convert.ToDateTime(requiredTime);
}
details.Add(detail);
}
return details;
}
#endregion
#region
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
if (!string.IsNullOrEmpty(hdItemsString.Text))
{
string[] ids = hdItemsString.Text.Split(',');
var details = jerqueSaveList();
var models = from x in Funs.DB.DriverGoods_GoodsModel where x.ProjectId == this.CurrUser.LoginProjectId select x;
foreach (var id in ids)
{
var oldDetail = details.FirstOrDefault(x => x.GoodsModelId == id);
if (oldDetail == null) //添加集合没有的新纪录
{
Model.DriverGoods_GoodsModel model = models.FirstOrDefault(x => x.GoodsModelId == id);
if (model != null)
{
Model.View_DriverGoods_GoodsBuyItem detail = new Model.View_DriverGoods_GoodsBuyItem();
detail.GoodsModelId = model.GoodsModelId;
detail.Purpose = model.Purpose;
detail.Description = model.Description;
detail.Attachment = model.Attachment;
detail.Remark = model.Remark;
details.Add(detail);
}
}
}
this.Grid1.DataSource = details;
this.Grid1.DataBind();
}
}
#endregion
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
{
string itemId = Grid1.DataKeys[e.RowIndex][0].ToString();
List<Model.View_DriverGoods_GoodsBuyItem> details = jerqueSaveList();
if (e.CommandName == "delete")
{
foreach (Model.View_DriverGoods_GoodsBuyItem detail in details)
{
if (detail.GoodsModelId == itemId)
{
details.Remove(detail);
break;
}
}
Grid1.DataSource = details;
Grid1.DataBind();
}
}
}
}