-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnew_库柜管理.cs
190 lines (181 loc) · 5.08 KB
/
new_库柜管理.cs
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
using Sunny.UI;
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 Warehouse.工具窗体;
namespace Warehouse
{
public partial class new_库柜管理 : UITitlePage
{
SystemLog log = new SystemLog();
int Dindex = -1;
public new_库柜管理()
{
InitializeComponent();
//给search控件赋值
search1.uiComboBox1.Items.Add("库柜ID");
search1.uiComboBox1.Items.Add("库柜名称");
//search1.uiComboBox1.Items.Add("负责人名称");
search1.uiComboBox1.SelectedIndex = 0;
grid.ClearAll();
//窗体初始化绑定数据
grid.AddColumn("库柜ID", "chest_id");
grid.AddColumn("库柜名称", "chest_name");
grid.AddColumn("库柜剩余体积", "chest_remain_volume");
grid.AddColumn("库柜剩余库位", "chest_remain_seat");
grid.AddColumn("库柜创建时间", "chest_create_time");
grid.AddColumn("库柜类型", "chest_type");
grid.AddColumn("库柜所属仓库", "chest_belong_storage");
grid.AddColumn("名称缩写", "chest_sx");
#region 添加修改,删除两个按钮
DataGridViewButtonColumn but = new DataGridViewButtonColumn();
but.HeaderText = "操作"; //设置列表头的名字
but.SetFixedMode(50);//设置按钮大小
but.Name = "UpDate";//设置按钮的名字
but.DefaultCellStyle.NullValue = "修改";
grid.Columns.Add(but);
DataGridViewButtonColumn but1 = new DataGridViewButtonColumn();
but1.HeaderText = "";
but1.SetFixedMode(50);
but1.Name = "Delete";
but1.DefaultCellStyle.NullValue = "删除";
grid.Columns.Add(but1);
#endregion
for (int i = 0; i < grid.ColumnCount; i++) { grid.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; }
AddRow();
//确定按钮和搜索按钮赋值
search1.uiButton1.Click += new EventHandler(this.search1_AddEvent);
search1.SearchButton.Click += new EventHandler(this.search1_SearchEvent);
}
//赋值
private void AddRow()
{
BLL.chest bllchest = new BLL.chest();
this.grid.DataSource = bllchest.GetModelList("");
this.uiPagination1.DataSource = bllchest.GetModelList("");
uiPagination1.ActivePage = 1;
}
//搜索
private void search1_SearchEvent(object sender, EventArgs e)
{
if (search1.SearchBox.Text.Trim() != "")
{
int f = search1.uiComboBox1.SelectedIndex;
string leixing = null;
string leixing_log = null;
if (f == 0)
{
leixing = "chest_id";
leixing_log = "库柜ID";
}
if (f == 1)
{
leixing = "chest_name";
leixing_log = "库柜名称";
}
string m = search1.SearchBox.Text.Trim();
string str = leixing.Trim() +
"=" + "\"" + search1.SearchBox.Text.Trim() + "\"";
BLL.chest dep = new BLL.chest();
uiPagination1.DataSource = dep.GetModelList(str);
grid.DataSource = dep.GetModelList(str);
log.WriteLog(4, Session.staffId, DateTime.Now.ToString("yyyy-MM-dd"), "库柜管理", "查询" + leixing_log, "");
}
}
private void search1_AddEvent(object sender, EventArgs e)
{
kugui ku = new kugui();
ku.ShowDialog();
if (ku.IsOK)
{
BLL.chest sr_ = new BLL.chest();
bool m = sr_.Add(ku.ChestModel);
if (m == true)
{
UIMessageBox.ShowSuccess("新增成功");
}
else
{
UIMessageBox.ShowWarning("新增失败");
}
}
}
//翻页
private void uiPagination1_PageChanged(object sender, object pagingSource, int pageIndex, int count)
{
grid.DataSource = pagingSource;
}
private void grid_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
//更新
if (grid.Columns[e.ColumnIndex].Name == "UpDate" && e.RowIndex >= 0)
{
//获得选择的行
int rowIndex = e.RowIndex;
string id = grid.CurrentRow.Cells[2].Value.ToString();
Model.chest sta = new Model.chest();
sta.chest_id = id;
//弹出对话框
kugui gui = new kugui();
//gui.uiListBox1.Visible = false;
//gui.uiButton1.Visible = false;
gui.uiListBox1.Enabled = false;
gui.uiButton1.Enabled = false;
bool m = gui.FuZhi(id);
if (m != true)
{
UIMessageBox.ShowWarning("错误", true);
}
else
{
gui.ShowDialog();
}
if (gui.IsOK)
{
BLL.chest bllchest = new BLL.chest();
bool k = bllchest.Update(gui.ChestModel);
//更改成功
if (k)
{
ShowSuccessDialog("更改成功");
}
//更改失败
else
{
UIMessageBox.ShowError("编辑失败");
}
}
else
{
UIMessageBox.ShowError("编辑失败");
}
}
//删除
if (grid.Columns[e.ColumnIndex].Name == "Delete" && e.RowIndex >= 0)
{
if (ShowAskDialog("此操作不可恢复。是否确认删除?"))
{
int rowIndex = e.RowIndex;
string id = grid.CurrentRow.Cells[2].Value.ToString();
BLL.chest bllstorage = new BLL.chest();
bool die = bllstorage.Delete(id);
if (die)
{
ShowSuccessDialog("删除成功");
AddRow();
}
else
{
ShowErrorDialog("删除失败");
}
}
}
}
}
}