-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainMenu.cs
369 lines (336 loc) · 14.1 KB
/
MainMenu.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
using System;
using System.Data;
using System.Reflection;
using System.Threading;
using DevExpress.XtraEditors;
using DevExpress.XtraSplashScreen;
namespace VIRETAILSTORE
{
public partial class MainMenu : XtraForm
{
private DataTable _dt = new DataTable();
public MainMenu()
{
InitializeComponent();
var frm = new Store.Login();
SplashScreenManager.ShowForm(this, typeof(SplashScreen1), true, true, false);
VIRETAILDAL.COMMON.Utils.Connectionstring = Properties.Settings.Default.POSConnectionString;
AppDomain MyDomain = AppDomain.CurrentDomain;
Assembly[] AssembliesLoaded = MyDomain.GetAssemblies();
foreach (Assembly MyAssembly in AssembliesLoaded)
{
SplashScreenManager.Default.SendCommand(SplashScreen1.SplashScreenCommand.SetProgress, MyAssembly.FullName);
Thread.Sleep(100);
}
SplashScreenManager.CloseForm(false);
frm.ShowDialog();
if(!frm.LoginSucess)
Dispose();
CreateTableForPermissions();
LoadPermissionsTiles();
//XtraMessageBox.Show(imageCollection1.Images[20].Height.ToString());
//XtraMessageBox.Show(imageCollection1.Images[30].Height.ToString());
}
void LoadPermissionsTiles()
{
//if(!string.IsNullOrEmpty(VIRETAILDAL.COMMON.Utils.Permissions))
//{
// for(int i = 0 ;i< 3 ; i++)
// {
// foreach(DataRow dr in GetRows(i))
// {}
// }
//}
//else if(VIRETAILDAL.COMMON.Utils.UserType==3)
//{}
var mn = VIRETAILDAL.COMMON.Utils.Permissions.Substring(0, 5);
string defaulttile = "-1";
string maintilename = "";
if(mn.Substring(0,1)=="1")
{
tilepurchasing.Visible = true;
defaulttile = "1";
maintilename = "Purchasing";
}
else
{
tilepurchasing.Visible = false;
}
if(mn.Substring(1,1)=="1")
{
tilesale.Visible = true;
defaulttile += "2";
if(string.IsNullOrEmpty(maintilename))
maintilename = "Sales";
}
else
{
tilesale.Visible = false;
}
if(mn.Substring(2,1)=="1")
{
tileinventory.Visible = true;
defaulttile += "3";
if (string.IsNullOrEmpty(maintilename))
maintilename = "Inventory";
}
else
{
tileinventory.Visible = false;
}
if(mn.Substring(3,1)=="1")
{
tilesetup.Visible = true;
defaulttile += "4";
}
else
{
tilesetup.Visible = false;
}
if (mn.Substring(4, 1) == "1")
{
tilecomm.Visible = true;
defaulttile += "5";
}
else
{
tilecomm.Visible = false;
}
LoadSubTiles(defaulttile,maintilename);
}
void LoadSubTiles(string sr,string maintilename)
{
var dataRow = _dt.Select(" MPARENTID = " + sr.Substring(0, 1));
int reptid = 0;
foreach (var dr in dataRow)
{
bool issub = false;
if(int.Parse(dr["PARENTID"].ToString())==0 && int.Parse(dr["MPARENTID"].ToString()) > 0)
{
reptid = int.Parse(dr["MENUID"].ToString());
tileControl2.Text = dr["MENUNAME"].ToString();
}
if (int.Parse(dr["PARENTID"].ToString()) == reptid && dr["MPARENTID"].ToString()==sr.Substring(0, 1))
{
issub = true;
}
NewTile(dr[1].ToString(), int.Parse(dr[0].ToString()), issub, bool.Parse(dr["ISLARGE"].ToString()));
}
}
DataRow[] GetRows(int i)
{
var drs = new DataRow[] {};
if(i==0)
{
drs = _dt.Select("PARENTID = 0");
}
if (i == 0)
{
drs = _dt.Select("PARENTID = 0");
}
return drs;
}
void CreateTile(string name,string id,int tiletype)
{
TileItem newTile = new TileItem();
//The first frame - Image only
TileItemFrame logoDXFrame = new TileItemFrame();
logoDXFrame.UseImage = true;
logoDXFrame.UseText = true;
logoDXFrame.AnimateImage = true;
logoDXFrame.AnimateText = true;
var logoEl = new TileItemElement();
if (id == "0")
logoEl.Image = Properties.Resources.logout_icon;
if(id=="1")
logoEl.Image = Properties.Resources.packing;
if (id == "2")
logoEl.Image = Properties.Resources.shopping_trolley;
if (id == "3")
logoEl.Image = Properties.Resources.inventory;
if (id == "4")
logoEl.Image = Properties.Resources.skills_icon;
logoEl.Text = "name";
logoEl.ImageAlignment = TileItemContentAlignment.MiddleCenter;
logoDXFrame.Elements.Add(logoEl);
TileItemFrame mottoDXFrame = new TileItemFrame();
TileItemElement mottoEl = new TileItemElement();
mottoEl.Text = "<Size=+3><Color=white><b>Let's see what develops.</b></Color></Size>";
mottoDXFrame.Elements.Add(mottoEl);
mottoDXFrame.UseImage = true;
mottoDXFrame.UseText = true;
mottoDXFrame.AnimateImage = true;
mottoDXFrame.AnimateText = true;
//Global Tile Item Settings
newTile.Frames.Add(logoDXFrame);
newTile.Frames.Add(mottoDXFrame);
//newTile.Appearance.BackColor = System.Drawing.Color.Gray;
//newTile.Appearance.BackColor2 = System.Drawing.Color.SandyBrown;
//newTile.Appearance.GradientMode = System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal;
//newTile.Appearance.BorderColor = System.Drawing.Color.Bisque;
newTile.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
newTile.ImageAlignment = TileItemContentAlignment.MiddleCenter;
newTile.AllowHtmlText = DevExpress.Utils.DefaultBoolean.True;
newTile.TextAlignment = TileItemContentAlignment.MiddleCenter;
newTile.FrameAnimationInterval = 2000;
newTile.IsLarge = true;
if(tiletype==1)
tileControl1.Groups[0].Items.Add(newTile);
if (tiletype == 2)
tileControl2.Groups[0].Items.Add(newTile);
}
private void tileControl2_Click(object sender, EventArgs e)
{}
private void tilesales_ItemClick(object sender, TileItemEventArgs e)
{
}
void LoadTiles(DataTable ds)
{
}
private void tilepurchasing_ItemClick(object sender, TileItemEventArgs e)
{
//for(int i=0;i<10;i++)
//{
// NewTile(i + "d", i);
//}
}
void clickhandler(object sender,TileItemEventArgs e)
{
}
private void NewTile(string tilecaption,int tileid,bool mtype,bool islarge)
{
var newTile = new TileItem();
newTile.ItemClick += clickhandler;
newTile.Name = tileid.ToString();
newTile.Tag = tileid;
newTile.IsLarge = islarge;
newTile.Text = tilecaption;
var logoDXFrame = new TileItemFrame();
logoDXFrame.UseImage = true;
logoDXFrame.UseText = true;
logoDXFrame.AnimateImage = true;
logoDXFrame.AnimateText = true;
var logoEl = new TileItemElement();
logoDXFrame.Elements.Add(logoEl);
if (!mtype)
{
tileControl2.Groups[0].Items.Add(newTile);
tileControl2.ScrollMode = TileControlScrollMode.ScrollBar;
}
else
{
tileControl2.Groups[1].Items.Add(newTile);
tileControl2.ScrollMode = TileControlScrollMode.ScrollBar;
}
}
void CreateTableForPermissions()
{
if(string.IsNullOrEmpty(VIRETAILDAL.COMMON.Utils.Permissions))
return;
var perms = VIRETAILDAL.COMMON.Utils.Permissions;
_dt = new VIRETAILDAL.DataManager().LoadDataSetMenu();
// _dt = new VIRETAILDAL.DataManager().LoadMenu("1,2,3,4,5,");
int i =0;
foreach(DataRow dr in _dt.Rows)
{
// if (perms.Substring(0, 1) == "1")
// {
if (perms.Substring(i+9, 1) == "1")
{
if (dr["MENUID"].ToString() == i.ToString())
{
dr["SEL"] = true;
}
else
{
dr["SEL"] = false;
}
}
i++;
// }
_dt.AcceptChanges();
}
}
//private void NewTile(string Bno, string Fnm, string bdt,string rid, int anicount, string mfrom, int cstat, int act)
//{
// TileItem newTile = new TileItem();
// newTile.ItemClick += new TileItemClickEventHandler(clickhandler);
// newTile.Name = rid;
// newTile.Tag = mfrom;
// //First Frame - Image only
// TileItemFrame logoDXFrame = new TileItemFrame();
// logoDXFrame.UseImage = true;
// logoDXFrame.UseText = true;
// logoDXFrame.AnimateImage = true;
// logoDXFrame.AnimateText = true;
// TileItemElement logoEl = new TileItemElement();
// logoDXFrame.Elements.Add(logoEl);
// logoDXFrame.Elements[0].AnimateTransition = DevExpress.Utils.DefaultBoolean.True;
// if (act == 0)
// {
// logoDXFrame.Elements[0].Text = "<Size=+1><Color=Black><b>Timesheet for Verification.</b></Color></Size>";
// }
// else
// {
// logoDXFrame.Elements[0].Text = "<Size=+1><Color=Black><b>Timesheet for Approval.</b></Color></Size>";
// }
// //logoDXFrame.Elements[0].Text = "<Size=+2><Color=Black><b>" + Bno + "</b></Color></Size>";
// logoDXFrame.Elements[0].TextAlignment = TileItemContentAlignment.TopLeft;
// //logoDXFrame.Elements[0].Appearance.Normal.BorderColor = abc;
// //Second Frame - Text only
// TileItemFrame mottoDXFrame = new TileItemFrame();
// TileItemElement mottoEl = new TileItemElement();
// if (act == 0)
// {
// mottoEl.Text = "<Size=+1><Color=White><b>Timesheet for Verification.</b></Color></Size>";
// }
// else
// {
// mottoEl.Text = "<Size=+1><Color=White><b>Timesheet for Approval.</b></Color></Size>";
// }
// mottoEl.TextAlignment = TileItemContentAlignment.TopLeft;
// mottoDXFrame.Elements.Add(mottoEl);
// mottoDXFrame.Elements[0].AnimateTransition = DevExpress.Utils.DefaultBoolean.True;
// mottoDXFrame.UseImage = true;
// mottoDXFrame.UseText = true;
// mottoDXFrame.AnimateImage = true;
// mottoDXFrame.AnimateText = true;
// TileItemElement mottoEl2 = new TileItemElement();
// mottoEl2.Text = "<Size=+1><Color=Black><i>" + Fnm + "</i></Color></Size>";
// mottoEl2.TextAlignment = TileItemContentAlignment.MiddleCenter;
// mottoDXFrame.Elements.Add(mottoEl2);
// mottoDXFrame.Elements[0].AnimateTransition = DevExpress.Utils.DefaultBoolean.True;
// mottoDXFrame.UseImage = true;
// mottoDXFrame.UseText = true;
// mottoDXFrame.AnimateImage = true;
// mottoDXFrame.AnimateText = true;
// TileItemElement mottoEl3 = new TileItemElement();
// mottoEl3.Text = "<Color=White>Forward Dt: " + bdt + "</Color>";
// mottoEl3.TextAlignment = TileItemContentAlignment.BottomRight;
// mottoDXFrame.Elements.Add(mottoEl3);
// mottoDXFrame.Elements[0].AnimateTransition = DevExpress.Utils.DefaultBoolean.True;
// mottoDXFrame.UseImage = true;
// mottoDXFrame.UseText = true;
// mottoDXFrame.AnimateImage = true;
// mottoDXFrame.AnimateText = true;
// //Global Tile Item Settings
// newTile.Frames.Add(logoDXFrame);
// newTile.Frames.Add(mottoDXFrame);
// newTile.Appearance.BackColor = abc; // System.Drawing.Color.Bisque;
// newTile.Appearance.BackColor2 = abc; // System.Drawing.Color.SandyBrown;
// newTile.Appearance.GradientMode = System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal;
// newTile.Appearance.BorderColor = abc;// System.Drawing.Color.Bisque;
// newTile.AllowHtmlText = DevExpress.Utils.DefaultBoolean.True;
// newTile.FrameAnimationInterval = anicount; //7500;
// newTile.IsLarge = true;
// if (cstat == 1)
// {
// newTile.Checked = true;
// }
// // tileControl1.Groups.Add(new TileGroup());
// tileControl1.Groups[0].Items.Add(newTile);
// tileControl1.ScrollMode = TileControlScrollMode.ScrollBar;
// newTile.StartAnimation();
//}
}
}