2
schangxiang@126.com
2024-08-16 b47c50a2a514def7374b32d7194b2c599cba5625
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using iWareCommon.Common.Entity;
using iWareCommon.Common.EnumType;
using iWareDataCore.BASE.Entity;
using iWareDataCore.BASE.EnumType;
using iWareDataCore.BASE.Service;
using iWareWms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace FineUIPro.iWareWms.View.MATERIAL.Material
{
    public partial class MaterialDetail : PageBase
    {
 
        private MaterialEntity GetMaterial()
        {
            return new MaterialEntity
            {
                Name = tbName.Text.Trim(),
                Code = tbCode.Text.Trim(),
                MaterialNo = tbMaterialNo.Text.Trim(),
                Version = tbVersion.Text.Trim(),
                Status = Status.Checked ? (int)EYesOrNo.是 : (int)EYesOrNo.否,
                TypeId = int.Parse(ddlType.SelectedValue),
                GuaranteePeriod = tbGuaranteePeriod.Text.Trim(),
                Unit = tbUnit.Text.Trim(),
                Description = tbDescription.Text.Trim(),
                Cost = decimal.Parse(nbCost.Text.Trim()),
                ClassificationSociety = tbClassificationSociety.Text.Trim(),
                SerialNo = tbSerialNo.Text.Trim(),
                IssueProjectNo = tbIssueProjectNo.Text.Trim(),
                ProcurementProjectNo = tbProcurementProjectNo.Text.Trim(),
                CuttingType = tbCuttingType.Text.Trim(),
                VerticalPosition = tbVerticalPosition.Text.Trim(),
                Weight = tbWeight.Text.Trim(),
                Remark = tbRemark.Text.Trim(),
                Thick = nbThicks.Text.Trim(),
                Length = nbLength.Text.Trim(),
                Wide = nbWide.Text.Trim()
            };
        }
 
        protected override void Save(out string msg)
        {
            MaterialService.GetInstance().Save(GetMaterial(), out msg);
            WriteLog("物料新增" + msg, "物料管理");
        }
 
        protected override void Update(out string msg)
        {
            var material = GetMaterial();
            material.Id = Convert.ToInt32(Request.QueryString["Id"]);
            MaterialService.GetInstance().Update(material, out msg);
            WriteLog("物料更新" + msg, "物料管理");
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            string msg;
            var types = MaterialTypeService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary<string, object> { } }, out msg);
            types.ForEach(x => ddlType.Items.Add(x.Name, x.Id.ToString()));
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["IsEdit"]))
                {
                    var materials = MaterialViewService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary<string, object> { { "Id", Request.QueryString["Id"] } } }, out msg);
                    tbName.Text = materials.Count > 0 ? materials[0].Name : "";
                    tbCode.Text = materials.Count > 0 ? materials[0].Code : "";
                    tbMaterialNo.Text = materials.Count > 0 ? materials[0].MaterialNo : "";
                    if (ddlType.SelectedValue == null)
                    {
                        ddlType.SelectedValue = EMaterialType.AH36.ToString();
                    }
                    tbGuaranteePeriod.Text = materials.Count > 0 ? materials[0].GuaranteePeriod : "0";
                    tbUnit.Text = materials.Count > 0 ? materials[0].Unit : "";
                    nbCost.Text = materials.Count > 0 ? materials[0].Cost.ToString() : "";
                    tbClassificationSociety.Text = materials.Count > 0 ? materials[0].ClassificationSociety : "";
                    tbSerialNo.Text = materials.Count > 0 ? materials[0].SerialNo : "";
                    tbDescription.Text = materials.Count > 0 ? materials[0].Description : "";
                    tbCuttingType.Text = materials.Count > 0 ? materials[0].CuttingType : "";
                    nbThicks.Text = materials.Count > 0 ? materials[0].Thick : "";
                    nbWide.Text = materials.Count > 0 ? materials[0].Wide : "";
                    nbLength.Text = materials.Count > 0 ? materials[0].Length : "";
                    Status.Checked = materials.Count > 0 ? materials[0].Status == (int)EYesOrNo.是 : false;
                    tbVerticalPosition.Text = materials.Count > 0 ? materials[0].VerticalPosition : "";
                    tbWeight.Text = materials.Count > 0 ? materials[0].Weight : "";
                    tbIssueProjectNo.Text = materials.Count > 0 ? materials[0].IssueProjectNo : "";
                    tbProcurementProjectNo.Text = materials.Count > 0 ? materials[0].ProcurementProjectNo : "";
                    tbRemark.Text = materials.Count > 0 ? materials[0].Remark : "";
                    if (!string.IsNullOrEmpty(msg)) { Alert.ShowInTop(msg); }
                }
                else
                {
                    tbClassificationSociety.Text = "LR";
                    tbUnit.Text = "块";
                    tbVersion.Text = "00";
                }
            }
        }
    }
}