tx
2025-04-09 fa7510e1ed63df0366787fa4ed1b3db6426d2b46
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
106
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TProduct.Model;
using TProduct.UI.WinFrm;
using TProduct.WinFrmUI;
 
namespace TProduct.UI.WinFrm.Main
{
    public partial class AddPartBaseDlg : BaseForm
    {
        public AddPartBaseDlg()
        {
            InitializeComponent();
            this.Text = "添加产品";
        }
        private Model.PartBase _model = null;
        //回调
        public event Action<Model.PartBase> ReloadDataEvent;
        public void SetBindingData(long MianID)
        {
            _model = new Model.PartBase();
            _model.ProductMainID = MianID;
            this.selectManufacturerBaseCtrl1.SetBindingData(0);
            this.selectSenderbaseCtrl1.SetBindingData(0);
        }
        /// <summary>
        /// 验证
        /// </summary> 
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(this.TextEditName.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.TextEditName, "必填项");
                return false;
            }
 
 
 
 
            return true;
        }
 
        private void simpleBtnOK_Click(object sender, EventArgs e)
        {
            if (!Valid())
                return;
  
            _model.Code = this.TextEditCode.Text;
            _model.Name = this.TextEditName.Text.Trim();
            _model.Note = this.MemoEditNote.Text.Trim();
            _model.CreateTime = DateTime.Now;
            _model.CreateUserID = TProduct.WinFrmUI.GlobeParas.CurrentLoginUser.ID;
            _model.UpdateTime = DateTime.Now;
            _model.UpdateUserID = TProduct.WinFrmUI.GlobeParas.CurrentLoginUser.ID;
 
 
            var bll = new BLL.PartBase();
            var id = bll.Insert(_model);
            if (id < 1)
            {
                XtraMessageBox.Show("添加失败!");
                return;
            }
            var model = bll.GetByID(id);
            this.ReloadDataEvent?.Invoke(model);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 
        private void selectManufacturerBaseCtrl1_CheckedChanedEvent(ManufacturerBase obj)
        {
            if (obj == null)
                return;
            _model.ManufacturerID = obj.ID;
        }
 
        private void selectSenderbaseCtrl1_CheckedChanedEvent(Senderbase obj)
        {
            if (obj == null)
                return;
            _model.SenderID = obj.ID;
        }
 
        private void ckCode_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
        {
            //if (ckCode.Checked == true)
            //{
            //    layoutCtrlCode.Enabled = false;
            //}
            //else
            //{
            //    if (ckCode.Checked == false)
            //        layoutCtrlCode.Enabled = true;
            //}
        }
    }
}