1 using System;
2 using System.Collections.Generic;
3 using System.Data;
4 using System.Linq;
5
6 using System.Web;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using ReviewFrame;
10
11 public partial class PositionBuilder : System.Web.UI.Page
12 {
13
14 string gLastClicked = "";
15 List<string> gSkillSetIDList;
16 int gPositionID = 0;
17
18 private int DepartmentID { get { return (ddlDepartment.SelectedIndex > 0 ? Convert.ToInt32(ddlDepartment.SelectedItem.Value) : 0); } }
19 private int JobNameID { get { return (ddlJobName.SelectedIndex > 0 ? Convert.ToInt32(ddlJobName.SelectedItem.Value) : 0); } }
20 private int SkillSetID { get { return (ddlSkillSet.SelectedIndex > 0 ? Convert.ToInt32(ddlSkillSet.SelectedItem.Value) : 0); } }
21 string txtNestedTextBox = "<div>{0}</div><br/><input id='{1}' value='' class='nestedTextBox' type='text' runat='server' style='width:600px; font-size: 10pt' />";
22
23 protected override void OnInit(EventArgs e)
24 {
25 base.OnInit(e);
26
27
28 //// *** Read our custom client managed Form Var that holds the tab selection
29 try
30 {
31 StatusBar1.addNewLine("BEGIN OnInit");
32
33 //LoadTab();
34 // MeasurementTabRow.Visible = false;
35 //loadMeasurement();
36
37 StatusBar1.addNewLine("END OnInit");
38 }
39 catch (Exception ex)
40 {
41 InsertError(ex);
42 }
43 }
44
45 protected void Page_Load(object sender, EventArgs e)
46 {
47 #region IsPostBack
48 if (Page.IsPostBack)
49 {
50
51 }
52 else
53 {
54 //LoadExistingUserData();
55 StatusBar1.addNewLine("not postback");
56 loadDepartment();
57 loadJobName();
58 // loadSkillSet();
59 StatusBar1.addNewLine(ddlJobName.SelectedIndex.ToString());
60 lblCreatedDate.Text = (lblCreatedDate.Text == string.Empty ? DateTime.Now.ToShortDateString() : lblCreatedDate.Text);
61 }
62 #endregion IsPostBack
63 }
64
65 private SSM_Cache FieldValues
66 {
67 get
68 {
69 SSM_Cache TableObject = new SSM_Cache()
70 {
71 DepartmentID = (ddlDepartment.SelectedIndex > 0 ? Convert.ToInt32(ddlDepartment.SelectedItem.Value) : 0),
72 JobNameID = (ddlJobName.SelectedIndex > 0 ? Convert.ToInt32(ddlJobName.SelectedItem.Value) : 0),
73 SkillSetID = (ddlSkillSet.SelectedIndex > 0 ? Convert.ToInt32(ddlSkillSet.SelectedItem.Value) : 0),
74 SessionID = Session.SessionID
75 };
76
77 return TableObject;
78
79 //TableObject.DepartmentID = Convert.ToInt32(ddlDepartment.SelectedItem.Value);
80 //TableObject.JobNameID = Convert.ToInt32(ddlJobName.SelectedValue);
81 //TableObject.MeasurementID = Convert.ToInt32(ddlSkillSet.SelectedValue);
82 //TableObject.SkillSetID = Convert.ToInt32(ddlSkillSet.SelectedValue);
83 //TableObject.SessionID = Session.SessionID;
84 }
85 }
86
87
88
89
90
91 ///// <summary>
92 ///// Gets SSM_Cache Table Data Based on Current Session.SessionID
93 ///// </summary>
94 ///// <returns>
95 ///// <list type="bool">Exists</list>
96 ///// <list type="Object">Query</list>
97 ///// <list type="int">Count</list>
98 ///// </returns>
99 //private QueryReturnType GetSSMCache()
100 //{
101 // QueryReturnType Result = new QueryReturnType();
102 // var query = new GSRDB1DataContext().SSM_Caches.Where(o => o.SessionID == Session.SessionID);
103 // Result.Query = query;
104 // Result.Count = query.Count();
105 // return Result;
106 //}
107
108 #region DOM/JavaScript/Ajax/JSON
109 //====================================================================================
110 protected void PostBackReturn(object sender, EventArgs e)
111 {
112 __CodeBehindReturn.Value = __CodeBehindInput.Value;
113 string JSScript_LoadScrollPosition = String.Format("<script type='text/javascript'>alert('here PostBackReturn');</script>");
114 //return "you clicked it";
115
116 KSSMCache QR = new KSSMCache();
117 QR.SessionID = Session.SessionID.ToString();
118 //QR.DepartmentID = 1;
119 //QR.JobNameID = 1;
120 //QR.SkillSetID = 1;
121 QR.MeasurementID = 18;
122
123 UpdateSSMCached(QR);
124 }
125
126 private void JSShowModalBox()
127 {
128 string JSScript_LoadScrollPosition = String.Format("<script type='text/javascript'>ShowModal();</script>");
129 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", JSScript_LoadScrollPosition, false);
130 }
131
132 private void JS_MaintainScrollPosition()
133 {
134 string JSScript_LoadScrollPosition = "<script type='text/javascript'>LoadScrollPosition();</script>";
135 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", JSScript_LoadScrollPosition, false);
136 }
137
138 private void JS_GetDescriptionTextFieldValue(string counter)
139 {
140 string JSScript_LoadScrollPosition = String.Format("<script type='text/javascript'>getDescriptionTextFieldValue('{0}');</script>", counter);
141 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", JSScript_LoadScrollPosition, false);
142 }
143
144 private void JavaScriptCall(string JScript)
145 {
146 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", JScript, false);
147 }
148 //====================================================================================
149 #endregion
150
151
152
153 private Position PositionFieldValues
154 {
155 get
156 {
157 Position tPosition = new Position() { Description = txtDescription.Text, CreatedDate = Convert.ToDateTime(lblCreatedDate.Text) };
158
159 return tPosition;
160 //tPosition.Description = txtDescription.Text;
161 //tPosition.CreatedDate = Convert.ToDateTime(lblCreatedDate.Text);
162 }
163 }
164
165 public void ConvertData(object sender, EventArgs e)
166 {
167 StatusBar1.addNewLine("here ConvertData");
168
169 KSSMCache QR = new KSSMCache();
170 GSRDB1DataContext db = new GSRDB1DataContext();
171 SSM_Cache oSSMCache = new SSM_Cache();
172
173 int UserID = Convert.ToInt32(Session["UserID"]);
174
175 var query = from p in db.SSM_Caches
176 where p.UserID == Convert.ToInt32(UserID)
177 select p;
178 foreach (var x in query)
179 {
180 StatusBar1.addNewLine(x.MeasurementID.ToString());
181 }
182
183 }
184
185 protected void InsertWrongData(object sender, EventArgs e)
186 {
187 KSSMCache QR = new KSSMCache();
188 QR.InsertWrongData(11849, "5xlbyc45xv4klxvmgbep1e40");
189 }
190 // if SSM Cache Exists
191 private void LoadExistingUserData()
192 {
193 KSSMCache QR = new KSSMCache();
194
195 int UserID = Convert.ToInt32(Session["UserID"]);
196
197 QR.UserID = UserID;
198 QR.SessionID = Session.SessionID;
199
200
201
202 var query = QR.GetUserData(UserID);
203
204 int CountByUserID = query.Count();
205 int CountBySessionID = query.Where(o => o.SessionID == Session.SessionID).Count();
206
207 int isBlankSessionID = QR.HasBlankedSessionID();
208
209
210 bool ByUserIDExists = QR.UserIDExists;
211 bool BySessionIDUserIDExists = QR.SessionIDExists;
212
213
214 if (CountByUserID == CountBySessionID)
215 {
216 // Good to go...
217 // nothing needs to be done...
218 LoadTab();
219 UpdatePanel1.Update();
220 }
221
222 if (CountByUserID != CountBySessionID)
223 {
224 //needs fixing
225 __SessionIDBlank.Value = isBlankSessionID.ToString();
226 __UserIDExists.Value = QR.UserIDExists.ToString().ToLower();
227 __SessionIDExists.Value = QR.SessionIDExists.ToString().ToLower();
228 __UserID.Value = UserID.ToString();
229 string Message = "\n" + "You have an Existing Data but the data doesn't match your session ID" + "\n" + "Would you like to recover the data?";
230 divMessageByServer.InnerText = Message;
231 }
232
233
234 if (ByUserIDExists && (isBlankSessionID > 0))
235 {
236 __SessionIDBlank.Value = isBlankSessionID.ToString();
237 __UserIDExists.Value = "true";
238 __SessionIDExists.Value = "true";
239 __ItemClicked.Value = "true";
240 __UserID.Value = UserID.ToString();
241
242 int UpdateCount = QR.UpdateWithCurrentSessionID(UserID, QR.SessionID);
243
244 string Message = "\n" + "Data Has Been Converted: " + UpdateCount.ToString();
245
246 divResponseMessage.InnerText = Message;
247
248 System.Threading.Thread.Sleep(1000);
249
250 UpdatePanel1.Update();
251
252 System.Threading.Thread.Sleep(1000);
253
254 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script>window.location.reload();</script>", false);
255 }
256
257 StatusBar1.addNewLine(UserID.ToString());
258 StatusBar1.addNewLine("userid count: " + CountByUserID.ToString());
259 StatusBar1.addNewLine("session count: " + CountBySessionID.ToString());
260
261 }
262
263 private void loadMeasurement2(string alpha)
264 {
265 KMeasurement oMeasurement = new KMeasurement();
266
267 var query = oMeasurement.getMeasurements().Where(o => o.Name.ToLower().StartsWith(alpha.ToLower()));
268
269 ddlMeasurement.Items.Clear();
270 ddlMeasurement.Items.Add("");
271
272 cblMeasurement.Items.Clear();
273 cblMeasurement.Items.Add("");
274
275 foreach (var x in query)
276 {
277 ListItem newItem = new ListItem();
278 newItem.Text = x.Name;
279 newItem.Value = x.ID.ToString();
280 ddlMeasurement.Items.Add(newItem);
281 cblMeasurement.Items.Add(newItem);
282 }
283 }
284
285
286 #region preload/clear
287 //====================================================================================
288 private void refreshForm()
289 {
290 StatusBar1.addNewLine("refreshForm BEGINS -----");
291 //updateGrids();
292 loadGridValues();
293 StatusBar1.addNewLine("refreshForm ENDS -----");
294 }
295
296 /// <summary>
297 /// loads form fields
298 /// doesn't not load table weight values
299 /// </summary>
300 /// <returns></returns>
301 private bool getCurrentValues()
302 {
303 bool success = false;
304
305 int DepartmentIndex = Convert.ToInt32(ddlDepartment.SelectedValue);
306 int JobNameIndex = Convert.ToInt32(ddlJobName.SelectedValue);
307
308 GSRDB1DataContext db = new GSRDB1DataContext();
309
310 var query = from p in db.Positions
311 where p.DepartmentID == DepartmentIndex && p.JobNameID == JobNameIndex
312 select p;
313
314 StatusBar1.addNewLine("getCurrentValues() query: " + query.Count().ToString() + " " + DepartmentIndex + " " + JobNameIndex);
315
316 if (query.Count() > 0)
317 {
318 lblPositionID.Text = query.First().ID.ToString();
319
320 if (query.First().ID > 0)
321 {
322 ddlDepartment.BackColor = System.Drawing.Color.LightGreen;
323 ddlJobName.BackColor = System.Drawing.Color.LightGreen;
324 lblCreatedDate.Text = query.First().CreatedDate.ToString();
325 txtDescription.Text = query.First().Description;
326 success = true;
327 }
328 }
329 else
330 {
331 ddlDepartment.BackColor = System.Drawing.Color.White;
332 ddlJobName.BackColor = System.Drawing.Color.White;
333 lblCreatedDate.Text = "";
334 txtDescription.Text = "";
335 success = false;
336 }
337 return success;
338 }
339
340 class MyDropDownList : System.Web.UI.WebControls.DropDownList
341 {
342 public void Reset()
343 {
344 this.Items.Clear();
345 this.Items.Add("");
346 this.SelectedIndex = - 1;
347 }
348 }
349
350
351
352 private void loadSkillSet(IQueryable<SkillSetMeasurement> querySSM)
353 {
354 //ddlSkillSet.reset();
355 //ddlSkillSet.DataSource = new KSkillSet().ListItems;
356 //ddlSkillSet.DataBind();
357 var query = querySSM.GroupBy(o => o.SkillSetID);
358 foreach (var x in (new GSRDB1DataContext().SkillSets.OrderBy(o => o.Name)))
359 {
360 //ListItem ListItem1 = new ListItem();
361 if (querySSM.Where(o => o.SkillSetID == x.ID).Count() > 0)
362 {
363 StatusBar1.addNewLine("loadSkillSet querySSM search found");
364 ddlSkillSet.Items.Add(new ListItem(x.Name + " [Exists]", x.ID.ToString()));
365 }
366 else
367 {
368 ddlSkillSet.Items.Add(new ListItem(x.Name, x.ID.ToString()));
369 }
370 //ListItem1.Text = x.Name;
371 //ListItem1.Value = x.ID.ToString();
372
373 }
374 ddlSkillSet.SelectedIndex = -1;
375 }
376
377 private void loadPosition()
378 {
379 GSRDB1DataContext db = new GSRDB1DataContext();
380
381 var query = db.Positions.Where(o => o.JobNameID == Convert.ToInt16(ddlJobName.SelectedItem.Value)).First();
382
383 lblCreatedDate.Text = query.CreatedDate.ToString();
384 txtDescription.Text = query.Description;
385 }
386
387 private void fillddlMeasurement()
388 {
389 try
390 {
391 GSRDB1DataContext db = new GSRDB1DataContext();
392 KMeasurement oMeasurement = new KMeasurement();
393
394 var query = oMeasurement.getMeasurements();
395
396 ddlMeasurement.Items.Clear();
397 ddlMeasurement.Items.Add("");
398
399 foreach (var x in query)
400 {
401 ListItem newItem = new ListItem();
402 newItem.Text = x.Name;
403 newItem.Value = x.ID.ToString();
404 ddlMeasurement.Items.Add(newItem);
405 }
406 }
407 catch (Exception ex)
408 {
409 InsertError(ex);
410 }
411 }
412
413 private void loadGridValues()
414 {
415 try
416 {
417 StatusBar1.addNewLine("loadGridValues BEGIN");
418 if (gPositionID == 0)
419 {
420 gPositionID = GetCurrentPositionID();
421 }
422
423 GSRDB1DataContext db = new GSRDB1DataContext();
424 var query = db.Positions.SingleOrDefault(o => o.ID == gPositionID);
425
426 if (query != null)
427 {
428 txtDescription.Text = query.Description.ToString().Replace("\n", "<br/>");
429 }
430
431 var queryPGP = from p in db.PositionGradingPercentages
432 where p.PositionID == gPositionID
433 select p;
434
435 UInt32 SkillSetID = 0;
436
437 foreach (string x in getTextBoxNameList())
438 {
439 TextBox TextA = (TextBox)PlaceHolder1.FindControl("txtPercentage_A_" + x.ToString());
440 TextBox TextB = (TextBox)PlaceHolder1.FindControl("txtPercentage_B_" + x.ToString());
441
442 SkillSetID = Convert.ToUInt32(x);
443 PositionGradingPercentage oPGP = queryPGP.SingleOrDefault(o => o.SkillSetID == SkillSetID);
444
445 if (oPGP != null)
446 {
447 TextA.Text = oPGP.Percentage.ToString();
448 TextB.Text = oPGP.Percentage2.ToString();
449 }
450 }
451
452 StatusBar1.addNewLine("loadGridValues END");
453 }
454 catch (Exception ex)
455 {
456 InsertError(ex);
457 }
458 }
459
460 private void loadJobName()
461 {
462 ddlJobName.Items.Clear();
463 ddlJobName.Items.Add("");
464
465 GSRDB1DataContext db = new GSRDB1DataContext();
466 var query = from p in db.JobNames
467 select p;
468
469 try
470 {
471 foreach (var x in query.OrderBy(o => o.Name))
472 {
473 ddlJobName.Items.Add(new ListItem(x.Name, x.ID.ToString()));
474 }
475 }
476 catch (Exception ex)
477 {
478 InsertError(ex);
479 }
480
481
482 }
483
484 private void loadDepartment()
485 {
486 // var departments = ((IQueryable<Department>)oDept.List).OrderBy(o => o.Name);
487 try
488 {
489 ddlDepartment.Items.Clear(); ddlDepartment.Items.Add(String.Empty);
490 foreach (var x in new GSRDB1DataContext().Departments.AsQueryable())
491 {
492 ddlDepartment.Items.Add(new ListItem(x.Name, x.ID.ToString()));
493 }
494 }
495 catch (Exception ex)
496 {
497 InsertError(ex);
498 }
499 }
500
501 // loads ssm_cache
502 private void LoadTab()
503 {
504 try
505 {
506 GSRDB1DataContext db = new GSRDB1DataContext();
507
508 KDepartment oDepartment = new KDepartment();
509 KMeasurement oMeasurement = new KMeasurement();
510 KSkillSet oSkillSet = new KSkillSet();
511
512 //KSSMCache oCache = new KSSMCache
513 // SessionIDExists DepartmentIDExists JobNameIDExists SkillSetIDExists MeasurementIDExists UserIDExists
514 //StatusBar1.addNewLine(oCache.s
515 Panel newPanel = new Panel();
516 StatusBar1.addNewLine(ddlDepartment.SelectedIndex.ToString());
517 StatusBar1.addNewLine(ddlJobName.SelectedIndex.ToString());
518
519 StatusBar1.addNewLine("department : " + ddlDepartment.SelectedValue);
520 StatusBar1.addNewLine("jobname: " + ddlJobName.SelectedValue);
521
522 foreach (ListItem x in ddlDepartment.Items)
523 {
524 StatusBar1.addNewLine(x.Text + " " + x.Value);
525 }
526
527 foreach (var x in new GSRDB1DataContext().Departments)
528 {
529 StatusBar1.addNewLine(x.Name + " " + x.ID.ToString());
530 }
531
532 var queryJobName = db.Positions.Where(o => o.DepartmentID == DepartmentID && o.JobNameID == JobNameID);
533 StatusBar1.addNewLine("LoadTab queryJobName.Count() " + queryJobName.Count().ToString());
534
535 if (queryJobName != null)
536 {
537 // StatusBar1.addNewLine("LoadTab querySSM.Count() " + queryJobName.Count().ToString());
538 }
539
540 var query = db.SSM_Caches.Where(o => o.SessionID == Session.SessionID);
541
542 //load txtdescription if exists
543 var queryDescription = (query.Where(o => o.Description != null).Count() == 0 ? null : query.Where(o => o.Description != null).First().Description);
544 var queryQualification = (query.Where(o => o.Qualification != null).Count() == 0 ? null : query.Where(o => o.Qualification != null).First().Qualification);
545 //.First().Description;
546 txtDescription.Text = (queryDescription == null ? "" : queryDescription);
547 txtQualification.Text = (queryQualification == null ? "" : queryQualification);
548 // StatusBar1.addNewLine(Session.SessionID + " " + query.Count().ToString());
549 short TabIndex = 100;
550 string strGrade = "";
551 if (query.Count() > 0)
552 {
553 foreach (var x in query.GroupBy(o => o.SkillSetID))
554 {
555 AjaxControlToolkit.TabPanel newTab = new AjaxControlToolkit.TabPanel();
556
557 newTab.ID = x.Key.Value.ToString();
558 newTab.Visible = true;
559 newTab.HeaderText = oSkillSet.GetName(x.Key.Value) + " [" + x.Count().ToString() + "]";
560 newTab.Attributes.Add("overflow", "auto");
561 newTab.ScrollBars = ScrollBars.Vertical;
562 newTab.Attributes.Add("runat", "server");
563 newTab.CssClass = "header";
564
565 //newTab.HeaderTemplate = (new TextBoxCreator(oSkillSet.GetName(x.Key.Value) + " [" + x.Count().ToString() + "]", x.Key.Value.ToString(), Unit.Pixel(50), "header"));
566
567 //string strBabTextBoxA = string.Format(" <asp:TextBox runat='server' CssClass='{0}' EnableViewState='true' ></asp:TextBox>", "txtManager");
568 //string strBabTextBoxB = string.Format(" <asp:TextBox runat='server' CssClass='{0}' EnableViewState='true' ></asp:TextBox>", "txtOther");
569
570 //string strBabTextBox1 = string.Format("<input type='TextBox' runat='server' class='{0}' EnableViewState='true'></input>","txtManager");
571 //string strBabTextBox2 = string.Format("<input type='TextBox' runat='server' class='{0}' EnableViewState='true'></input>", "txtOther");
572 newTab.HeaderText = oSkillSet.GetName(x.Key.Value); // +" [" + x.Count().ToString() + "]";
573
574 Table newTable = new Table();
575 TableRow newRow = new TableRow();
576 newTable.Attributes.Add("width", "400px");
577
578 #region Add Button and Two fields
579 //Button btnUpdate4SkillSet = new Button();
580 //btnUpdate4SkillSet.Text = "Update";
581 //btnUpdate4SkillSet.ID = "btnUpdate4SkillSet";
582 //btnUpdate4SkillSet.Style.Add("cursor", "pointer");
583 //btnUpdate4SkillSet.ToolTip = "Update for " + x.Key.Value.ToString();
584 //btnUpdate4SkillSet.Click += btnUpdate4SkillSet_Click;
585 //btnUpdate4SkillSet.Attributes.Add("runat", "server");
586
587 LiteralControl lblManager = new LiteralControl(String.Format("<span class='{0}' >Manager: </span>", "ManagerLabelCell"));
588 LiteralControl lblOther = new LiteralControl(String.Format("<span class='{0}' >Other: </span>", "OthersLabelCell"));
589
590 TextBox TextBox1 = new TextBox();
591 TextBox1.ID = "txtPercentage_A_" + x.Key.Value.ToString();
592 TextBox1.ToolTip = "txtPercentage_A_" + x.Key.Value.ToString();
593 TextBox1.CssClass = "txtPercentage";
594 TextBox1.Width = Unit.Pixel(30);
595 TextBox1.Height = Unit.Pixel(15);
596 TextBox1.EnableViewState = true;
597 TextBox1.TabIndex = TabIndex;
598 strGrade = (x.Where(o => o.Manager1 != null).Count() != 0 ? x.Where(o => o.Manager1 != null).First().Peer1.Value.ToString() : "0");
599 TextBox1.Text = strGrade;
600 TabIndex++;
601
602 TextBox TextBox2 = new TextBox();
603 TextBox2.ID = "txtPercentage_B_" + x.Key.Value.ToString();
604 TextBox2.ToolTip = "txtPercentage_B_" + x.Key.Value.ToString();
605 TextBox2.CssClass = "txtPercentage";
606 TextBox2.Width = Unit.Pixel(30);
607 TextBox2.Height = Unit.Pixel(15);
608 TextBox2.EnableViewState = true;
609 TextBox2.TabIndex = TabIndex;
610 strGrade = (x.Where(o => o.Self != null).Count() != 0 ? x.Where(o => o.Self != null).First().Self.Value.ToString() : "0");
611 TextBox2.Text = strGrade;
612 TabIndex++;
613
614 TableCell newCell = new TableCell();
615
616 //TableCell newCell = new TableCell();
617 //newCell.Width = Unit.Pixel(30);
618 //newCell.Text = "Manager: ";
619 //newRow.Cells.Add(newCell);
620
621 newCell = new TableCell();
622 newCell.Width = Unit.Pixel(30);
623 //newCell.Controls.Add(lblManager);
624 newCell.Controls.Add(TextBox1);
625 newRow.Cells.Add(newCell);
626
627 // newCell = new TableCell();
628 //newCell.Width = Unit.Pixel(30);
629 //newCell.Text = "Other: ";
630 //newRow.Cells.Add(newCell);
631
632 newCell = new TableCell();
633 newCell.Width = Unit.Pixel(30);
634 newCell.Controls.Add(TextBox2);
635 newRow.Cells.Add(newCell);
636
637 //newCell = new TableCell();
638 //newCell.Width = Unit.Pixel(425);
639 //newCell.HorizontalAlign = HorizontalAlign.Right;
640 //newCell.Controls.Add(btnUpdate4SkillSet);
641 //newRow.Cells.Add(newCell);
642
643 newTable.Rows.Add(newRow);
644 newTab.Controls.Add(newTable);
645 #endregion
646
647 GridView GridView1 = new GridView();
648
649 GridView1.CssClass = "grid1";
650 GridView1.ID = "SSM_" + x.Key.Value.ToString();
651 GridView1.Width = Unit.Pixel(920);
652 GridView1.RowCommand += Grid_RowCommand;
653 //GridView1.PageIndexChanging += Grid_PageIndexChanging;
654 GridView1.RowDeleting += Grid_RowDeleting;
655 //GridView1.AllowPaging = true;
656 GridView1.AutoGenerateColumns = false;
657 GridView1.GridLines = GridLines.None;
658
659 var query1 = from p in query
660 where p.SkillSetID == x.Key
661 select new
662 {
663 Selected = true,
664 SkillSetID = p.SkillSetID,
665 MeasurementID = p.MeasurementID,
666 MeasurementName = oMeasurement.getMeasurementByID(p.MeasurementID.Value)
667 };
668
669 foreach (var y in query1)
670 {
671
672 }
673
674 HTMLUtility oHTMLUtility = new HTMLUtility();
675
676 ButtonField DeleteButton = oHTMLUtility.CreateImageButtonField("Delete", "Delele", 50);
677 BoundField MeasurementField = oHTMLUtility.CreateBoundField("Name", "Measurement Name", "Name", 525);
678 BoundField MeasurementIDField = oHTMLUtility.CreateBoundField("MeasurementID", "ID", "Name", 25);
679 MeasurementField.ControlStyle.CssClass = "Measurement";
680 MeasurementField.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
681 MeasurementIDField.ControlStyle.CssClass = "Measurement";
682 MeasurementIDField.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
683
684 TemplateField TemplateField1 = new TemplateField();
685 TemplateField1.ItemTemplate = new GridViewTemplate4Measurement(DataControlRowType.DataRow, "Name", Unit.Pixel(750), "");
686 TemplateField1.HeaderTemplate = new GridViewTemplate4Measurement(DataControlRowType.Header, "Name", Unit.Pixel(750), "");
687
688 GridViewTemplate4Measurement xx = new GridViewTemplate4Measurement(DataControlRowType.Header, "Name", Unit.Pixel(750), "");
689
690 GridView1.Columns.Add(DeleteButton);
691 GridView1.Columns.Add(TemplateField1);
692 //GridView1.Columns.Add(MeasurementField);
693 GridView1.Columns.Add(MeasurementIDField);
694
695 GridView1.DataSource = query1;
696 GridView1.DataBind();
697
698 //CheckBoxList CBL = new CheckBoxList();
699 //foreach (var y in query.Where(o => o.SkillSetID == x.Key))
700 //{
701 // string MeasurementName = oMeasurement.getMeasurementByID(y.MeasurementID.Value);
702 // ListItem ListItem1 = new ListItem(MeasurementName, y.MeasurementID.ToString());
703 // ListItem1.Selected = true;
704 // ListItem1.Attributes.Add("textvalue", MeasurementName);
705 // CBL.Items.Add(ListItem1);
706 //}
707 //CBL.Attributes.Add("runat", "server");
708 //newTab.Controls.Add(CBL);
709
710 newTab.Controls.Add(GridView1);
711 TabContainer1.Controls.Add(newTab);
712 }
713 TabContainer1.ActiveTabIndex = 0;
714 }
715 }
716 catch (Exception ex)
717 {
718 InsertError(ex);
719 }
720 }
721
722 //loads ssm
723 private void LoadTab(IQueryable<SkillSetMeasurement> querySSM, IQueryable<Position> queryPosition)
724 {
725 try
726 {
727 GSRDB1DataContext db = new GSRDB1DataContext();
728
729 KDepartment oDepartment = new KDepartment();
730 KMeasurement oMeasurement = new KMeasurement();
731 KSkillSet oSkillSet = new KSkillSet();
732
733 Panel newPanel = new Panel();
734 var queryPGP = db.PositionGradingPercentages.Where(o => o.PositionID == queryPosition.First().ID);
735
736
737
738 var queryJobName = queryPosition.Where(o => o.DepartmentID == DepartmentID && o.JobNameID == JobNameID);
739
740
741 foreach (var x in querySSM.GroupBy(o=>o.SkillSetID) )
742 {
743
744 var query1 = from p in querySSM
745 where p.SkillSetID == x.Key
746 select new
747 {
748 Selected = true,
749 SkillSetID = p.SkillSetID,
750
751
752 MeasurementID = p.MeasurementID,
753 MeasurementName = oMeasurement.getMeasurementByID(p.MeasurementID),
754
755 Manager1 = queryPGP.SingleOrDefault(o => o.SkillSetID == p.SkillSetID).Percentage,
756 Self = queryPGP.SingleOrDefault(o => o.SkillSetID == p.SkillSetID).Percentage2
757 };
758
759
760 //var querySSM2 = from p in querySSM.AsQueryable<SkillSetMeasurement>()
761 // select new
762 // {
763 // SkillSetID = p.SkillSetID,
764 // SkillSetName = db.SkillSets.SingleOrDefault(o => o.ID == p.SkillSetID).Name,
765
766 // MeasurementID = p.MeasurementID,
767 // MeasurementName = db.Measurements.SingleOrDefault(o => o.ID == p.MeasurementID).Name,
768
769 // Manager1 = queryPGP.SingleOrDefault(o => o.SkillSetID == p.SkillSetID).Percentage,
770 // Self = queryPGP.SingleOrDefault(o => o.SkillSetID == p.SkillSetID).Percentage2
771 // };
772
773
774 StatusBar1.addNewLine(query1.Count().ToString());
775 }
776
777 //if (queryJobName != null)
778 //{
779 // StatusBar1.addNewLine("LoadTab querySSM.Count() " + queryJobName.Count().ToString());
780 //}
781
782 //StatusBar1.addNewLine("LoadTab queryPosition.First().Description " + queryPosition.First().Description);
783 //StatusBar1.addNewLine("LoadTab queryPosition.First().Qualification " + queryPosition.First().Qualification);
784 ////.First().Description;
785 //txtDescription.Text = (queryPosition == null ? "" : queryPosition.First().Description);
786 //txtQualification.Text = (queryPosition == null ? "" : queryPosition.First().Qualification);
787 //// StatusBar1.addNewLine(Session.SessionID + " " + query.Count().ToString());
788 //short TabIndex = 100;
789 //string strGrade = "";
790 //if (querySSM2.Count() > 0)
791 //{
792 // StatusBar1.addNewLine("querySSM2 count: " + querySSM2.Count().ToString());
793
794 // foreach (var x in querySSM2.GroupBy(o => o.SkillSetID))
795 // {
796 // AjaxControlToolkit.TabPanel newTab = new AjaxControlToolkit.TabPanel();
797
798 // newTab.ID = x.Key.ToString();
799 // newTab.Visible = true;
800 // newTab.HeaderText = oSkillSet.GetName(x.Key) + " [" + x.Count().ToString() + "]";
801 // newTab.Attributes.Add("overflow", "auto");
802 // newTab.ScrollBars = ScrollBars.Vertical;
803 // newTab.Attributes.Add("runat", "server");
804 // newTab.CssClass = "header";
805
806 // //newTab.HeaderTemplate = (new TextBoxCreator(oSkillSet.GetName(x.Key.Value) + " [" + x.Count().ToString() + "]", x.Key.Value.ToString(), Unit.Pixel(50), "header"));
807
808 // //string strBabTextBoxA = string.Format(" <asp:TextBox runat='server' CssClass='{0}' EnableViewState='true' ></asp:TextBox>", "txtManager");
809 // //string strBabTextBoxB = string.Format(" <asp:TextBox runat='server' CssClass='{0}' EnableViewState='true' ></asp:TextBox>", "txtOther");
810
811 // //string strBabTextBox1 = string.Format("<input type='TextBox' runat='server' class='{0}' EnableViewState='true'></input>","txtManager");
812 // //string strBabTextBox2 = string.Format("<input type='TextBox' runat='server' class='{0}' EnableViewState='true'></input>", "txtOther");
813 // newTab.HeaderText = oSkillSet.GetName(x.Key); // +" [" + x.Count().ToString() + "]";
814
815 // Table newTable = new Table();
816 // TableRow newRow = new TableRow();
817 // newTable.Attributes.Add("width", "400px");
818
819 // #region Add Button and Two fields
820 // //Button btnUpdate4SkillSet = new Button();
821 // //btnUpdate4SkillSet.Text = "Update";
822 // //btnUpdate4SkillSet.ID = "btnUpdate4SkillSet";
823 // //btnUpdate4SkillSet.Style.Add("cursor", "pointer");
824 // //btnUpdate4SkillSet.ToolTip = "Update for " + x.Key.Value.ToString();
825 // //btnUpdate4SkillSet.Click += btnUpdate4SkillSet_Click;
826 // //btnUpdate4SkillSet.Attributes.Add("runat", "server");
827
828 // LiteralControl lblManager = new LiteralControl(String.Format("<span class='{0}' >Manager: </span>", "ManagerLabelCell"));
829 // LiteralControl lblOther = new LiteralControl(String.Format("<span class='{0}' >Other: </span>", "OthersLabelCell"));
830
831 // TextBox TextBox1 = new TextBox();
832 // TextBox1.ID = "txtPercentage_A_" + x.Key.ToString();
833 // TextBox1.ToolTip = "txtPercentage_A_" + x.Key.ToString();
834 // TextBox1.CssClass = "txtPercentage";
835 // TextBox1.Width = Unit.Pixel(30);
836 // TextBox1.Height = Unit.Pixel(15);
837 // TextBox1.EnableViewState = true;
838 // TextBox1.TabIndex = TabIndex;
839 // strGrade = (x.Where(o => o.Manager1 != null).Count() != 0 ? x.Where(o => o.Manager1 != null).First().Manager1.ToString() : "0");
840 // TextBox1.Text = strGrade;
841 // TabIndex++;
842
843 // TextBox TextBox2 = new TextBox();
844 // TextBox2.ID = "txtPercentage_B_" + x.Key.ToString();
845 // TextBox2.ToolTip = "txtPercentage_B_" + x.Key.ToString();
846 // TextBox2.CssClass = "txtPercentage";
847 // TextBox2.Width = Unit.Pixel(30);
848 // TextBox2.Height = Unit.Pixel(15);
849 // TextBox2.EnableViewState = true;
850 // TextBox2.TabIndex = TabIndex;
851 // strGrade = (x.Where(o => o.Self != null).Count() != 0 ? x.Where(o => o.Self != null).First().Self.Value.ToString() : "0");
852 // TextBox2.Text = strGrade;
853 // TabIndex++;
854
855 // TableCell newCell = new TableCell();
856
857 // //TableCell newCell = new TableCell();
858 // //newCell.Width = Unit.Pixel(30);
859 // //newCell.Text = "Manager: ";
860 // //newRow.Cells.Add(newCell);
861
862 // newCell = new TableCell();
863 // newCell.Width = Unit.Pixel(30);
864 // //newCell.Controls.Add(lblManager);
865 // newCell.Controls.Add(TextBox1);
866 // newRow.Cells.Add(newCell);
867
868 // // newCell = new TableCell();
869 // //newCell.Width = Unit.Pixel(30);
870 // //newCell.Text = "Other: ";
871 // //newRow.Cells.Add(newCell);
872
873 // newCell = new TableCell();
874 // newCell.Width = Unit.Pixel(30);
875 // newCell.Controls.Add(TextBox2);
876 // newRow.Cells.Add(newCell);
877
878 // //newCell = new TableCell();
879 // //newCell.Width = Unit.Pixel(425);
880 // //newCell.HorizontalAlign = HorizontalAlign.Right;
881 // //newCell.Controls.Add(btnUpdate4SkillSet);
882 // //newRow.Cells.Add(newCell);
883
884 // newTable.Rows.Add(newRow);
885 // newTab.Controls.Add(newTable);
886 // #endregion
887
888 // GridView GridView1 = new GridView();
889
890 // GridView1.CssClass = "grid1";
891 // GridView1.ID = "SSM_" + x.Key.ToString();
892 // GridView1.Width = Unit.Pixel(920);
893 // GridView1.RowCommand += Grid_RowCommand;
894 // //GridView1.PageIndexChanging += Grid_PageIndexChanging;
895 // GridView1.RowDeleting += Grid_RowDeleting;
896 // //GridView1.AllowPaging = true;
897 // GridView1.AutoGenerateColumns = false;
898 // GridView1.GridLines = GridLines.None;
899
900 // //var query1 = from p in querySSM2
901 // // where p.SkillSetID == x.Key
902 // // select new
903 // // {
904 // // Selected = true,
905 // // SkillSetID = p.SkillSetID,
906 // // MeasurementID = p.MeasurementID,
907 // // MeasurementName = oMeasurement.getMeasurementByID(p.MeasurementID.Value)
908 // // };
909
910 // HTMLUtility oHTMLUtility = new HTMLUtility();
911
912 // ButtonField DeleteButton = oHTMLUtility.CreateImageButtonField("Delete", "Delele", 50);
913 // BoundField MeasurementField = oHTMLUtility.CreateBoundField("MeasurementName", "Measurement Name", "Name", 525);
914 // BoundField MeasurementIDField = oHTMLUtility.CreateBoundField("MeasurementID", "ID", "Name", 25);
915 // MeasurementField.ControlStyle.CssClass = "Measurement";
916 // MeasurementField.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
917 // MeasurementIDField.ControlStyle.CssClass = "Measurement";
918 // MeasurementIDField.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
919
920 // TemplateField TemplateField1 = new TemplateField();
921 // TemplateField1.ItemTemplate = new GridViewTemplate4Measurement(DataControlRowType.DataRow, "Name", Unit.Pixel(750), "");
922 // TemplateField1.HeaderTemplate = new GridViewTemplate4Measurement(DataControlRowType.Header, "Name", Unit.Pixel(750), "");
923
924 // GridViewTemplate4Measurement xx = new GridViewTemplate4Measurement(DataControlRowType.Header, "Name", Unit.Pixel(750), "");
925
926 // GridView1.Columns.Add(DeleteButton);
927 // GridView1.Columns.Add(TemplateField1);
928 // //GridView1.Columns.Add(MeasurementField);
929 // GridView1.Columns.Add(MeasurementIDField);
930
931 // GridView1.DataSource = querySSM2;
932 // GridView1.DataBind();
933
934 // //CheckBoxList CBL = new CheckBoxList();
935 // //foreach (var y in query.Where(o => o.SkillSetID == x.Key))
936 // //{
937 // // string MeasurementName = oMeasurement.getMeasurementByID(y.MeasurementID.Value);
938 // // ListItem ListItem1 = new ListItem(MeasurementName, y.MeasurementID.ToString());
939 // // ListItem1.Selected = true;
940 // // ListItem1.Attributes.Add("textvalue", MeasurementName);
941 // // CBL.Items.Add(ListItem1);
942 // //}
943 // //CBL.Attributes.Add("runat", "server");
944 // //newTab.Controls.Add(CBL);
945
946 // newTab.Controls.Add(GridView1);
947 // TabContainer1.Controls.Add(newTab);
948 // }
949 //TabContainer1.ActiveTabIndex = 0;
950 //}
951 }
952 catch (Exception ex)
953 {
954 InsertError(ex);
955 }
956 }
957
958 private void LoadAlphabetTab()
959 {
960 //try
961 //{
962 // KMeasurement oMeasurement = new KMeasurement();
963 // var query = oMeasurement.FirstLetterList;
964 // HTMLUtility oHU = new HTMLUtility();
965
966 // foreach (var x in query)
967 // {
968 // AjaxControlToolkit.TabPanel newTab = new AjaxControlToolkit.TabPanel();
969
970 // newTab.ID = "btn" + x;
971 // newTab.Visible = true;
972 // newTab.HeaderText = x;
973
974 // newTab.Controls.Add(new LiteralControl(String.Format("<div class={0}>{1}</div>", "randomBox", "hello")));
975
976 // AlphabetTab.Tabs.Add(newTab);
977 // }
978 // AlphabetTab.ActiveTabIndex = 0;
979 //}
980 //catch (Exception ex)
981 //{
982 // StatusBar1.addNewLine(ex.Message + " " + ex.StackTrace);
983 //}
984 }
985 //====================================================================================
986 #endregion preload
987
988 // TextBox firstEmpty = accountDetails.Controls
989 //.All()
990 //.OfType<TextBox>()
991 //.Where(tb => tb.Text.Trim().Length == 0)
992 //.FirstOrDefault();
993
994 #region Short Routines
995 //====================================================================================
996
997 private List<string> getTextBoxNameList()
998 {
999 StatusBar1.addNewLine("getTextBoxNameList BEGIN");
1000
1001 if (gSkillSetIDList == null)
1002 {
1003 gSkillSetIDList = new List<string>();
1004
1005 StatusBar1.addNewLine("PlaceHolder1.Controls.Count: " + PlaceHolder1.Controls.Count.ToString());
1006
1007 foreach (Control x in PlaceHolder1.Controls)
1008 {
1009 if (x.ID != null)
1010 {
1011 //StatusBar1.addNewLine("getTextBoxNameList: PlaceHolder1 x.id " + x.ID);
1012
1013 if (x.ToString().Contains("Table"))
1014 {
1015 Table newTable = (Table)x;
1016
1017 StatusBar1.addNewLine("getTextBoxNameList table id? " + newTable.ID);
1018
1019 gSkillSetIDList.Add(newTable.ID);
1020 }
1021 }
1022 }
1023
1024 StatusBar1.addNewLine("getTextBoxNameList: Filled In *END" + gSkillSetIDList.Count.ToString());
1025 return gSkillSetIDList;
1026 }
1027 else
1028 {
1029 StatusBar1.addNewLine("getTextBoxNameList: Already Exists. *END" + gSkillSetIDList.Count.ToString());
1030 return gSkillSetIDList;
1031 }
1032 }
1033
1034 private int GetCurrentPositionID()
1035 {
1036 try
1037 {
1038 StatusBar1.addNewLine("getCurrentPositionID BEGIN===");
1039
1040 if (gPositionID == 0)
1041 {
1042 StatusBar1.addNewLine(gPositionID.ToString());
1043
1044 int DepartmentID = Convert.ToInt32(ddlDepartment.SelectedItem.Value);
1045 int JobNameID = Convert.ToInt32(ddlJobName.SelectedItem.Value);
1046
1047 GSRDB1DataContext db = new GSRDB1DataContext();
1048 gPositionID = db.Positions.Single(p => p.DepartmentID == DepartmentID && p.JobNameID == JobNameID).ID;
1049
1050 StatusBar1.addNewLine("getCurrentPositionID new END===: " + gPositionID.ToString() + " from "
1051 + DepartmentID.ToString() + " " + JobNameID.ToString());
1052 return gPositionID;
1053 }
1054 else
1055 {
1056 StatusBar1.addNewLine("getCurrentPositionID existing END===");
1057 return gPositionID;
1058 }
1059 }
1060 catch (Exception ex)
1061 {
1062 InsertError(ex);
1063 return -1;
1064 }
1065 }
1066
1067 #endregion Short Routines
1068
1069 private List<TextBox> GetTextBoxList()
1070 {
1071 List<TextBox> TextBoxList = new List<TextBox>();
1072
1073 foreach (AjaxControlToolkit.TabPanel x in TabContainer1.Controls)
1074 {
1075 foreach (var y in x.Controls)
1076 {
1077 if (y.ToString().Contains("Table"))
1078 {
1079 Table Table1 = (Table)y;
1080 foreach (var z in Table1.Controls[0].Controls)
1081 {
1082 TableCell TableCell1 = (TableCell)z;
1083 if (TableCell1.Controls[0].ToString().Contains("TextBox"))
1084 {
1085 TextBox TextBox1 = (TextBox)TableCell1.Controls[0];
1086 TextBoxList.Add(TextBox1);
1087 StatusBar1.addNewLine("GetTextBoxList(): " + TextBox1.ID + " " + TextBox1.Text);
1088 }
1089 }
1090 }
1091 }
1092 }
1093 return TextBoxList;
1094 }
1095
1096
1097 #region Measurement
1098
1099 private void loadMeasurement()
1100 {
1101 StatusBar1.addNewLine("loadMeasurement: " + DateTime.Now.ToString());
1102
1103 KMeasurement oMeasurement = new KMeasurement();
1104 //cblMeasurement.Items.Clear();
1105 //cblMeasurement.DataSource = new KMeasurement().ListItems;
1106 //cblMeasurement.DataBind();
1107 foreach (var x in oMeasurement.getMeasurements().OrderBy(o => o.Name))
1108 {
1109 cblMeasurement.Items.Add(new ListItem(x.Name, x.ID.ToString()));
1110 }
1111 }
1112
1113 protected void cblMeasurement_SelectedIndexChanged(object sender, EventArgs e)
1114 {
1115 CheckBoxList CBL = (CheckBoxList)sender;
1116 blMeasurement.Items.Clear();
1117 txtCheckListBoxData.Text = "";
1118 try
1119 {
1120 foreach (ListItem x in cblMeasurement.Items)
1121 {
1122 if (x.Selected)
1123 {
1124 blMeasurement.Items.Add(x);
1125 txtCheckListBoxData.Text += x.Value + " " + x.Text + "\n";
1126 }
1127 }
1128 Div4blMeasurement.Visible = true;
1129 Div4blMeasurement.Style.Add("height", (blMeasurement.Items.Count * 20).ToString());
1130 }
1131 catch (Exception ex)
1132 {
1133 InsertError(ex);
1134 }
1135 JS_MaintainScrollPosition();
1136 }
1137
1138 //====================================================================================
1139 #endregion
1140
1141
1142 #region Dropdown events
1143 //====================================================================================
1144
1145 protected void ddlDepartment_SelectedIndexChanged(object sender, EventArgs e)
1146 {
1147
1148 }
1149
1150 // CHECK IF THERE IS A POSITION EXISTING.
1151 protected void ddlJobName_SelectedIndexChanged(object sender, EventArgs e)
1152 {
1153 GSRDB1DataContext db = new GSRDB1DataContext();
1154
1155
1156 var queryPosition = db.Positions.Where(o=>o.DepartmentID == Convert.ToInt32(ddlDepartment.SelectedValue) && o.JobNameID == Convert.ToInt32(ddlJobName.SelectedValue));
1157 if (queryPosition.Count() > 0)
1158 {
1159 var querySSM = db.SkillSetMeasurements.Where(o => o.PositionID == queryPosition.First().ID);
1160
1161 loadSkillSet(querySSM);
1162 LoadTab(querySSM, queryPosition);
1163
1164
1165
1166 StatusBar1.addNewLine("querySSM.Count(: " + querySSM.Count().ToString());
1167
1168 //ddlSkillSet.SelectedValue = "";
1169 ddlDepartment.BackColor = System.Drawing.Color.Gray;
1170 ddlJobName.BackColor = System.Drawing.Color.ForestGreen;
1171 StatusBar1.addNewLine("has item");
1172 }
1173 else
1174 {
1175
1176 }
1177 //loadGridValues();
1178
1179
1180
1181 if ( ( ddlDepartment.SelectedIndex > 0 ) && ( ddlJobName.SelectedIndex > 0 ) )
1182 {
1183 MeasurementSelector.Visible = true;
1184 MeasurementCheckBoxListRow.Visible = true;
1185 MeasurementBulletedList.Visible = true;
1186 // MeasurementTabRow.Visible = true;
1187 }
1188 else
1189 {
1190 MeasurementSelector.Visible = false;
1191 MeasurementCheckBoxListRow.Visible = false;
1192 MeasurementBulletedList.Visible = false;
1193 //MeasurementTabRow.Visible = false;
1194 }
1195 }
1196
1197 protected void ddlSkillSet_SelectedIndexChanged(object sender, EventArgs e)
1198 {
1199 if (ddlSkillSet.SelectedIndex > 0)
1200 {
1201 loadMeasurement();
1202 }
1203 }
1204
1205 private ListItemCollection GetblMeasurementItems()
1206 {
1207 //return null;
1208 ListItemCollection Lists = new ListItemCollection();
1209
1210 foreach (ListItem x in blMeasurement.Items)
1211 {
1212 Lists.Add(x);
1213 }
1214
1215 return Lists;
1216 // cblMeasurement.
1217 }
1218
1219 protected void ToggleDebugPanel(object sender, EventArgs e)
1220 {
1221 Button CurrentButton = (Button)sender;
1222
1223 if (CurrentButton.Text == "-")
1224 {
1225 DebugPanel.Visible = false;
1226 }
1227 else
1228 {
1229 DebugPanel.Visible = true; ;
1230 CurrentButton.Text = "-";
1231 }
1232 //btnExpand.Attributes.Add("display", "block");
1233 //btnExpand.Attributes.Add("display", "none");
1234
1235 //btnCollapse.Attributes.Add("display", "block");
1236 //btnCollapse.Attributes.Add("display", "none");
1237
1238 }
1239
1240
1241
1242 //protected void ddlDepartment_TextChanged(object sender, EventArgs e)
1243 //{
1244 //}
1245
1246 //====================================================================================
1247 #endregion Dropdown events
1248
1249
1250
1251
1252 #region User Click Events
1253 //====================================================================================
1254
1255 protected void btnAlertOkay_Click(object sender, EventArgs e)
1256 {
1257 //AlertTable.Visible = false;
1258
1259 System.Threading.Thread.Sleep(2000);
1260 refreshForm();
1261 }
1262
1263 private void AlertBoxAdd(string Title, string Message)
1264 {
1265 //AlertTable.Visible = true;
1266 //lblAlertTitle.Text = Title;
1267 //lblAlertMessage.Text = Message;
1268
1269 }
1270
1271 private void AlertBoxAdd()
1272 {
1273 //AlertTable.Visible = true;
1274 }
1275
1276 //====================================================================================
1277 #endregion User Click Events
1278
1279
1280 #region SSMCache
1281 //====================================================================================
1282
1283 /// <summary>
1284 /// Returns the Query of [GetSSMCache(): SessionID], DepartmentID, JobNameID, SkillSetID
1285 /// </summary>
1286 /// <returns></returns>
1287 //private QueryReturnType SSMCacheExist()
1288 //{
1289 // QueryReturnType Result = new QueryReturnType();
1290
1291 // var query = from SSM_Cache p in (IEnumerable<SSM_Cache>)GetSSMCache().Query
1292 // where p.DepartmentID == DepartmentID &&
1293 // p.JobNameID == JobNameID &&
1294 // p.SkillSetID == SkillSetID
1295 // select p;
1296
1297 // Result.Query = query;
1298 // Result.Count = query.Count();
1299 // Result.Exists = (query.Count() > 0 ? true : false);
1300
1301 // return Result;
1302 //}
1303
1304 //private QuerySSMReturnType SSMCache()
1305 //{
1306 // QuerySSMReturnType Result = new QuerySSMReturnType(Session.SessionID, DepartmentID, JobNameID);
1307
1308 // return Result;
1309 //}
1310
1311 // //MeasurementSelector MeasurementBulletedList MeasurementTabRow MeasurementCheckBoxListRow
1312
1313 private void TruncateSSMCache()
1314 {
1315 new GSRDB1DataContext().Truncate_SSM_Cache();
1316 }
1317
1318
1319 private TableRow GetTableRow(string Header, string session, string department, string jobname, string skillset, string measurement)
1320 {
1321 TableRow newRow = new TableRow();
1322 TableCell newCell;
1323 {
1324 newCell = new TableCell(); newCell.Font.Bold = true; newCell.Text = Header; newRow.Cells.Add(newCell);
1325 }
1326 {
1327 newCell = new TableCell(); newCell.Text = session; newRow.Cells.Add(newCell);
1328 }
1329 {
1330 newCell = new TableCell(); newCell.Text = department; newRow.Cells.Add(newCell);
1331 }
1332 {
1333 newCell = new TableCell(); newCell.Text = jobname; newRow.Cells.Add(newCell);
1334 }
1335 {
1336 newCell = new TableCell(); newCell.Text = skillset; newCell.Text = skillset; newCell.Text = skillset;
1337 }
1338 {
1339 newCell = new TableCell(); newCell.Text = measurement; newCell.Text = measurement;
1340 }
1341 return newRow;
1342 }
1343 private Table GetTable()
1344 {
1345 KSSMCache QueryObject = new KSSMCache(Session.SessionID, DepartmentID, JobNameID, SkillSetID, 0);
1346 Table newTable = new Table();
1347 TableRow newRow = new TableRow();
1348
1349 //Session Department JobName SkillSet Measurement
1350 newTable.Style.Add("width", "640px");
1351 newTable.Style.Add("font-size", "10pt");
1352 newTable.Style.Add("background", "#ccffcc");
1353 newTable.Style.Add("color", "000000");
1354
1355 #region Title
1356 {
1357 newRow = GetTableRow("", "Session", "Department", "JobName", "SkillSet", "Measurement");
1358 newRow.Font.Bold = true;
1359 newTable.Rows.Add(newRow);
1360 }
1361 #endregion
1362
1363 #region IDs
1364 {
1365 newTable.Rows.Add(GetTableRow("Current Value", QueryObject.SessionID, QueryObject.DepartmentID.ToString(), QueryObject.JobNameID.ToString(),
1366 QueryObject.SkillSetID.ToString(), QueryObject.MeasurementID.ToString()));
1367 }
1368 #endregion
1369
1370 #region IDs Exists
1371 {
1372 newTable.Rows.Add(GetTableRow("Exists?", QueryObject.SessionIDExists.ToString(), QueryObject.DepartmentIDExists.ToString(),
1373 QueryObject.JobNameIDExists.ToString(), QueryObject.SkillSetIDExists.ToString(), QueryObject.MeasurementIDExists.ToString()));
1374 }
1375 #endregion
1376
1377 #region Count
1378 {
1379 newTable.Rows.Add(GetTableRow("Count?", "", "", "", QueryObject.SkillSetCount.ToString(), QueryObject.MeasurementCount.ToString()));
1380 }
1381 #endregion
1382
1383 return newTable;
1384 }
1385 private Table GetTable(KSSMCache QueryObject)
1386 {
1387 Table newTable = new Table();
1388 TableRow newRow = new TableRow();
1389
1390 //Session Department JobName SkillSet Measurement
1391 newTable.Style.Add("width", "640px");
1392 newTable.Style.Add("font-size", "10pt");
1393 newTable.Style.Add("background", "#ccffcc");
1394 newTable.Style.Add("color", "000000");
1395
1396 #region Title
1397 {
1398 newRow = GetTableRow("", "Session", "Department", "JobName", "SkillSet", "Measurement");
1399 newRow.Font.Bold = true;
1400 newTable.Rows.Add(newRow);
1401 }
1402 #endregion
1403
1404 #region IDs
1405 {
1406 newTable.Rows.Add(GetTableRow("Current Value", QueryObject.SessionID, QueryObject.DepartmentID.ToString(), QueryObject.JobNameID.ToString(),
1407 QueryObject.SkillSetID.ToString(), QueryObject.MeasurementID.ToString()));
1408 }
1409 #endregion
1410
1411 #region IDs Exists
1412 {
1413 newTable.Rows.Add(GetTableRow("Exists?", QueryObject.SessionIDExists.ToString(), QueryObject.DepartmentIDExists.ToString(),
1414 QueryObject.JobNameIDExists.ToString(), QueryObject.SkillSetIDExists.ToString(), QueryObject.MeasurementIDExists.ToString()));
1415 }
1416 #endregion
1417
1418 #region Count
1419 {
1420 newTable.Rows.Add(GetTableRow("Count?", "", "", "", QueryObject.SkillSetCount.ToString(), QueryObject.MeasurementCount.ToString()));
1421 }
1422 #endregion
1423
1424 return newTable;
1425 }
1426 private Table GetTable(KSSMCache QueryObject, int measurementid)
1427 {
1428 Table newTable = new Table();
1429 TableRow newRow = new TableRow();
1430
1431 //Session Department JobName SkillSet Measurement
1432 newTable.Style.Add("width", "640px");
1433 newTable.Style.Add("font-size", "10pt");
1434 newTable.Style.Add("background", "#ccffcc");
1435 newTable.Style.Add("color", "000000");
1436
1437 #region Title
1438 {
1439 newRow = GetTableRow("", "Session", "Department", "JobName", "SkillSet", "Measurement");
1440 newRow.Font.Bold = true;
1441 newTable.Rows.Add(newRow);
1442 }
1443 #endregion
1444
1445 #region IDs
1446 {
1447 newTable.Rows.Add(GetTableRow("Current Value", QueryObject.SessionID, QueryObject.DepartmentID.ToString(), QueryObject.JobNameID.ToString(),
1448 QueryObject.SkillSetID.ToString(), QueryObject.MeasurementID.ToString()));
1449 }
1450 #endregion
1451
1452 #region IDs Exists
1453 {
1454 newTable.Rows.Add(GetTableRow("Exists?", QueryObject.SessionIDExists.ToString(), QueryObject.DepartmentIDExists.ToString(),
1455 QueryObject.JobNameIDExists.ToString(), QueryObject.SkillSetIDExists.ToString(), QueryObject.MeasurementIDExists.ToString()));
1456 }
1457 #endregion
1458
1459 #region Count
1460 {
1461 newTable.Rows.Add(GetTableRow("Count?", "", "", "", QueryObject.SkillSetCount.ToString(), QueryObject.MeasurementCount.ToString()));
1462 }
1463 #endregion
1464
1465 return newTable;
1466 }
1467
1468 protected void btnSSMCache_Click(object sender, EventArgs e)
1469 {
1470 int DepartmentID = Convert.ToInt32(ddlDepartment.SelectedItem.Value);
1471 int JobNameID = Convert.ToInt32(ddlJobName.SelectedValue);
1472 int SkillSetID = Convert.ToInt32(ddlSkillSet.SelectedValue);
1473
1474 GSRDB1DataContext db = new GSRDB1DataContext();
1475
1476 StatusBar1.ClearControls();
1477
1478 string StringFormat0 = "SessionID DepartmentID JobNameID SkillSetID: MeasurementID: ";
1479 string StringFormat1 = " {0}, {1}, {2}, {3}, {4}";
1480 System.Text.StringBuilder SB = new System.Text.StringBuilder();
1481 SB.AppendLine(StringFormat0 + "<br/>");
1482 try
1483 {
1484 KSSMCache QR = null;
1485 foreach (ListItem x in GetblMeasurementItems())
1486 {
1487 StatusBar1.addNewLine("x.Value: " + x.Value);
1488 int MeasurementID = Convert.ToInt32(x.Value);
1489
1490 #region Setup QuerySSMReturnType
1491
1492 //GetDescriptionTextFieldValue(x.Value);
1493
1494 // QR = new QuerySSMReturnType(Session.SessionID, DepartmentID, JobNameID, SkillSetID, MeasurementID);
1495 QR = new KSSMCache();
1496 QR.SessionID = Session.SessionID;
1497 QR.DepartmentID = DepartmentID;
1498 QR.JobNameID = JobNameID;
1499 QR.SkillSetID = SkillSetID;
1500 QR.MeasurementID = MeasurementID;
1501 // QR.Description = __txtDescriptionNth.Value;
1502
1503 #endregion
1504
1505
1506 #region Stringformats
1507 string StringOutput = string.Format(
1508 StringFormat1,
1509 QR.SessionIDExists.ToString(),
1510 QR.DepartmentIDExists.ToString(),
1511 QR.JobNameIDExists.ToString(),
1512 QR.SkillSetIDExists.ToString(),
1513 QR.MeasurementIDExists.ToString());
1514
1515 string IDOuput = string.Format(
1516 StringFormat1,
1517 QR.SessionIDExists.ToString(),
1518 QR.DepartmentID.ToString(),
1519 QR.JobNameID.ToString(),
1520 QR.SkillSetID.ToString(),
1521 QR.MeasurementID.ToString());
1522 #endregion
1523
1524 if (QR.MeasurementIDExists)
1525 {
1526 SB.AppendLine("EXISTS NOT ADDED" + "<br/>");
1527 }
1528 else
1529 {
1530 bool saved = UpdateSSMCached(QR);
1531 //CreateTab(QR);
1532 SB.AppendLine("ADDED" + "<br/>");
1533 }
1534 SB.AppendLine("IDExists: " + StringOutput + "<br/>");
1535 SB.AppendLine("IDs: " + IDOuput + "<br/>");
1536 }
1537 StatusBar1.AddTableControl(GetTable(QR));
1538 StatusBar1.addNewLine(SB.ToString());
1539 JS_MaintainScrollPosition();
1540
1541 LoadTab();
1542 }
1543 catch (Exception ex)
1544 {
1545 StatusBar1.addNewLine(ex.Message + "<br />" + ex.StackTrace.ToString());
1546 JS_MaintainScrollPosition();
1547 InsertError(ex);
1548 }
1549 }
1550
1551
1552 private bool UpdateSSMCached(KSSMCache QR)
1553 {
1554 try
1555 {
1556 GSRDB1DataContext db = new GSRDB1DataContext();
1557
1558 SSM_Cache SSMCacheData = new SSM_Cache();
1559
1560 SSMCacheData.SessionID = QR.SessionID;
1561 SSMCacheData.DepartmentID = QR.DepartmentID;
1562 SSMCacheData.JobNameID = QR.JobNameID;
1563 SSMCacheData.SkillSetID = QR.SkillSetID;
1564 SSMCacheData.UserID = QR.UserID;
1565 SSMCacheData.MeasurementID = QR.MeasurementID;
1566 // SSMCacheData.Description = QR.des
1567 SSMCacheData.CreatedDate = DateTime.Now;
1568 SSMCacheData.ExpirationDate = DateTime.Now.AddDays(1);
1569 db.SSM_Caches.InsertOnSubmit(SSMCacheData);
1570 db.SubmitChanges();
1571
1572 return true;
1573 }
1574 catch (Exception ex)
1575 {
1576 InsertError(ex);
1577 return false;
1578 }
1579 }
1580
1581 protected void btnUpdate4SkillSet_Click(object sender, EventArgs e)
1582 {
1583 StatusBar1.addNewLine("btnUpdate4SkillSet_Click: TabContainer1.Controls.Count-> " + TabContainer1.Controls.Count.ToString());
1584
1585 GSRDB1DataContext gdb = new GSRDB1DataContext();
1586 HTMLUtility.PositionBuilder oHTMLUtility = new HTMLUtility.PositionBuilder(TabContainer1);
1587
1588
1589 StatusBar1.addNewLine("oHTMLUtility.GradeTextBoxes: " + oHTMLUtility.GradeTextBoxes.Count.ToString());
1590 StatusBar1.addNewLine("oHTMLUtility.CommentTextBoxes: " + oHTMLUtility.CommentTextBoxes.Count.ToString());
1591 foreach (var x in oHTMLUtility.GradeTextBoxes) { StatusBar1.addNewLine(x.GradeType.ToString() + " " + x.TextBox.Text); }
1592 foreach (var x in oHTMLUtility.CommentTextBoxes) { StatusBar1.addNewLine(x.SkillSetID.ToString() + " " + x.MeasurementID.ToString()); }
1593
1594
1595 //txtPercentage_A_17
1596 //txtPercentage_B_17
1597 // SkillSet Part1 and SkillSet Part2
1598
1599 StringUtility oSU = new StringUtility();
1600
1601
1602
1603 int DepartmentID = Convert.ToInt16(ddlDepartment.SelectedItem.Value);
1604 int JobNameID = Convert.ToInt16(ddlJobName.SelectedItem.Value);
1605 string SessionID = Session.SessionID;
1606
1607 //var query2 = from p in oHTMLUtility.GradeTextBoxes.AsQueryable()
1608 // let score = p.Grade
1609 // select new
1610 // {
1611 // score = score
1612 // };
1613
1614 KDepartment oDepartment = new KDepartment();
1615 KJobName oJobName = new KJobName();
1616
1617 IEnumerable<SSM_Cache> QueryResult;
1618
1619 if ((oHTMLUtility.GradeTextBoxes.AsQueryable().Sum(o=>o.Grade) / 2) != 100)
1620 {
1621 StatusBar1.addNewLine("not eq 100: " + oHTMLUtility.GradeTextBoxes.AsQueryable().Sum(o => o.Grade).ToString());
1622 }
1623 else
1624 {
1625 foreach (HTMLUtility.GradeTextBox GradeTextBox in oHTMLUtility.GradeTextBoxes)
1626 {
1627 QueryResult = from p in gdb.SSM_Caches
1628 where p.DepartmentID == DepartmentID &&
1629 p.SessionID == SessionID &&
1630 p.JobNameID == JobNameID &&
1631 p.SkillSetID == GradeTextBox.SkillSetID
1632 select p;
1633
1634 StatusBar1.addNewLine(SessionID.ToString() + " " + oDepartment.GetName(DepartmentID) + " " + oJobName.GetName(JobNameID));
1635 StatusBar1.addNewLine(QueryResult.Count().ToString());
1636 if (GradeTextBox.GradeType == 'A')
1637 {
1638 //StatusBar1.addNewLine("Manager: " + temp[2].ToString() + " " + textbox.Text);
1639 QueryResult.First().Manager1 = GradeTextBox.Grade;
1640 }
1641 else
1642 {
1643 // StatusBar1.addNewLine("Employee: " + temp[2].ToString() + " " + textbox.Text);
1644 QueryResult.First().Self = GradeTextBox.Grade;
1645 QueryResult.First().Peer1 = GradeTextBox.Grade;
1646 }
1647 //ListItems.Add(new ListItem(temp[2], GradeTextBox.Text));
1648 }
1649
1650 QueryResult = from p in gdb.SSM_Caches
1651 where p.DepartmentID == DepartmentID &&
1652 p.SessionID == SessionID &&
1653 p.JobNameID == JobNameID
1654 select p;
1655
1656 QueryResult.First().Description = txtDescription.Text;
1657 QueryResult.First().Qualification = txtQualification.Text;
1658
1659
1660 gdb.SubmitChanges();
1661 }
1662 }
1663
1664
1665
1666
1667
1668
1669 private void CreateTab(KSSMCache QR)
1670 {
1671 //AjaxControlToolkit.TabPanel newTab = new AjaxControlToolkit.TabPanel();
1672 //KDepartment oDepartment = new KDepartment();
1673
1674 //newTab.ID = "btn" + QR.DepartmentID.ToString() + QR.JobNameID.ToString() + QR.SkillSetID.ToString() + QR.MeasurementID.ToString();
1675 //newTab.Visible = true;
1676 //newTab.HeaderText = oDepartment.GetName(QR.DepartmentID);
1677 //newTab.Controls.Add(new LiteralControl(String.Format("<div class={0}>{1}</div>", "randomBox", "hello")));
1678 //TabContainer1.Controls.Add(newTab);
1679 //TabContainer1.ActiveTabIndex = 0;
1680 }
1681
1682 //====================================================================================
1683 #endregion
1684
1685
1686
1687 #region Process Add/Delete/Remove/Complete Process
1688 //====================================================================================
1689
1690 private void clearForm()
1691 {
1692 ddlJobName.SelectedIndex = -1;
1693 lblPositionID.Text = "";
1694 lblCreatedDate.Text = "";
1695 txtDescription.Text = "";
1696 }
1697
1698 /// <summary>
1699 /// called from ibnt_add()
1700 /// </summary>
1701 private void add()
1702 {
1703 StatusBar1.StatusContent += "add() start here <br/>";
1704 try
1705 {
1706 GSRDB1DataContext db = new GSRDB1DataContext();
1707 KPosition oPosition = new KPosition();
1708
1709 int DepartmentID = Convert.ToInt16(ddlDepartment.SelectedItem.Value);
1710 int JobNameID = Convert.ToInt16(ddlJobName.SelectedItem.Value);
1711 int SkillSetID = Convert.ToInt16(ddlSkillSet.SelectedItem.Value);
1712 int MeasurementID = Convert.ToInt16(ddlMeasurement.SelectedItem.Value);
1713
1714 StatusBar1.StatusContent += DepartmentID.ToString() + "<br/>";
1715 StatusBar1.StatusContent += JobNameID.ToString() + "<br/>";
1716 StatusBar1.StatusContent += SkillSetID.ToString() + "<br/>";
1717 StatusBar1.StatusContent += MeasurementID.ToString() + "<br/>";
1718
1719
1720 int PositionID = db.Positions.Single(o => o.DepartmentID == DepartmentID && o.JobNameID == JobNameID).ID;
1721
1722 StatusBar1.StatusContent += "PositionID.ToString(): " + PositionID.ToString() + "<br/>";
1723
1724 bool exist = oPosition.validateMeasurements(JobNameID, MeasurementID);
1725
1726 var queryDoesSkillSetMeasurementExists = from p in db.SkillSetMeasurements
1727 where p.PositionID == PositionID && p.SkillSetID == SkillSetID && p.MeasurementID == MeasurementID
1728 select p;
1729
1730 if (queryDoesSkillSetMeasurementExists.Count() == 0)
1731 {
1732 SkillSetMeasurement tSSM = new SkillSetMeasurement();
1733
1734 tSSM.PositionID = PositionID;
1735
1736 tSSM.DepartmentID = DepartmentID;
1737 tSSM.JobNameID = JobNameID;
1738
1739
1740 tSSM.SkillSetID = SkillSetID;
1741 tSSM.MeasurementID = MeasurementID;
1742
1743 db.SkillSetMeasurements.InsertOnSubmit(tSSM);
1744 db.SubmitChanges();
1745
1746 StatusBar1.StatusContent += " saved...<br/>";
1747 }
1748 else
1749 {
1750 StatusBar1.StatusContent += " not saved...<br/>";
1751 }
1752
1753 }
1754 catch (Exception ex)
1755 {
1756 InsertError(ex);
1757 }
1758 }
1759
1760 /// <summary>
1761 /// There are only 3 saving points
1762 /// 1. ADD SMM - merely adds to SMM_Cache table
1763 /// 2. "Update" updates the scores
1764 /// 3. Complete/Finish
1765 /// DATe: 01-25-2009
1766 /// </summary>
1767 private void Complete()
1768 {
1769 //1.. Create Position
1770 //2. SAVe SMM
1771 //3. SAve..
1772 // save the cheerleader?
1773 //querySSMCached
1774 bool Success = false;
1775 try
1776 {
1777 StatusBar1.addNewLine("here");
1778
1779 int DepartmentID = Convert.ToInt16(ddlDepartment.SelectedItem.Value);
1780 int JobNameID = Convert.ToInt16(ddlJobName.SelectedItem.Value);
1781 GSRDB1DataContext db = new GSRDB1DataContext();
1782
1783 var querySSMCached = from p in db.SSM_Caches
1784 where p.SessionID == Session.SessionID &&
1785 p.DepartmentID == DepartmentID &&
1786 p.JobNameID == JobNameID
1787 select p;
1788
1789 // Create Position
1790 KPosition oPosition = new KPosition();
1791 int PositionID = 0;
1792 Position tPosition;
1793
1794 if (oPosition.Exists(DepartmentID, JobNameID) == false)
1795 {
1796 tPosition = new Position();
1797 tPosition.DepartmentID = querySSMCached.First().DepartmentID;
1798 tPosition.JobNameID = querySSMCached.First().JobNameID;
1799 tPosition.Description = (querySSMCached.Where(o => o.Description != null).Count() > 0 ? querySSMCached.Where(o => o.Description != null).First().Description : "");
1800 tPosition.CreatedDate = DateTime.Now;
1801 tPosition.ModifiedDate = DateTime.Now;
1802 tPosition.Qualification = (querySSMCached.Where(o => o.Qualification != null).Count() > 0 ? querySSMCached.Where(o => o.Qualification != null).First().Qualification : "");
1803 db.Positions.InsertOnSubmit(tPosition);
1804 db.SubmitChanges();
1805 StatusBar1.addNewLine("Position created: ");
1806
1807 System.Threading.Thread.Sleep(2000);
1808
1809 var query0 = from p in db.Positions
1810 where p.DepartmentID == tPosition.DepartmentID &&
1811 p.JobNameID == tPosition.JobNameID
1812 select p;
1813
1814 var query = query0.Where(o => o.CreatedDate == tPosition.CreatedDate).Single();
1815
1816 PositionID = query.ID;
1817 }
1818 // SAVING SSM
1819
1820 StatusBar1.addNewLine("Updating SSM..... " + txtDescription.Text);
1821
1822 var querySSM = db.SkillSetMeasurements.Where(o => o.DepartmentID == DepartmentID && o.JobNameID == JobNameID);
1823
1824 foreach (var x in querySSMCached)
1825 {
1826 var queryExist = from p in querySSM
1827 where p.SkillSetID == x.SkillSetID && p.MeasurementID == x.MeasurementID
1828 select p;
1829
1830 if (queryExist.Count() == 0)
1831 {
1832 SkillSetMeasurement saveQuerySSM = new SkillSetMeasurement();
1833 saveQuerySSM.PositionID = PositionID;
1834 saveQuerySSM.DepartmentID = x.DepartmentID;
1835 saveQuerySSM.JobNameID = x.JobNameID;
1836 saveQuerySSM.SkillSetID = x.SkillSetID.Value;
1837 saveQuerySSM.MeasurementID = x.MeasurementID.Value;
1838 db.SkillSetMeasurements.InsertOnSubmit(saveQuerySSM);
1839 db.SubmitChanges();
1840 StatusBar1.addNewLine("ADDEd: " + x.DepartmentID.ToString() + " " + x.JobNameID.ToString() + " " + x.SkillSetID.ToString() + " " + x.MeasurementID.ToString());
1841 }
1842 else
1843 {
1844 StatusBar1.addNewLine("Not Added: " + x.DepartmentID.ToString() + " " + x.JobNameID.ToString() + " " + x.SkillSetID.ToString() + " " + x.MeasurementID.ToString());
1845 }
1846 }
1847
1848 KSkillSet oSkillSet = new KSkillSet();
1849
1850 //Create PositionGradingPercentage.. or PGP
1851
1852 foreach (var x in querySSMCached.Where(o => o.Manager1.Value != null && o.Self != null))
1853 {
1854 PositionGradingPercentage queryPGP = db.PositionGradingPercentages.SingleOrDefault(p => p.SkillSetID == x.SkillSetID && p.PositionID == PositionID);
1855 if (queryPGP != null)
1856 {
1857 queryPGP.PositionID = PositionID;
1858 queryPGP.Percentage = Convert.ToByte(x.Manager1.Value);
1859 queryPGP.Percentage2 = Convert.ToByte(x.Self.Value);
1860 queryPGP.SkillSetID = x.SkillSetID.Value;
1861 queryPGP.SkillSetName = oSkillSet.GetName(x.SkillSetID.Value);
1862
1863 }
1864 else
1865 {
1866 PositionGradingPercentage PGP = new PositionGradingPercentage();
1867 PGP.PositionID = PositionID;
1868 PGP.Percentage = Convert.ToByte(x.Manager1.Value);
1869 PGP.Percentage2 = Convert.ToByte(x.Self.Value);
1870 PGP.SkillSetID = x.SkillSetID.Value;
1871 PGP.SkillSetName = oSkillSet.GetName(x.SkillSetID.Value);
1872 db.PositionGradingPercentages.InsertOnSubmit(PGP);
1873 }
1874 db.SubmitChanges();
1875 }
1876 StatusBar1.addNewLine(querySSM.Count().ToString() + " --- " + querySSMCached.Count().ToString());
1877 }
1878 catch (Exception ex)
1879 {
1880 InsertError(ex);
1881 }
1882 }
1883
1884 private void DeleteCache()
1885 {
1886 try
1887 {
1888 GSRDB1DataContext db = new GSRDB1DataContext();
1889
1890 var querySSMCached = from p in db.SSM_Caches
1891 where p.SessionID == Session.SessionID &&
1892 p.DepartmentID == DepartmentID &&
1893 p.JobNameID == JobNameID
1894 select p;
1895 StatusBar1.addNewLine(querySSMCached.Count().ToString());
1896
1897 db.SSM_Caches.DeleteAllOnSubmit(querySSMCached);
1898 db.SubmitChanges();
1899 }
1900 catch (Exception ex)
1901 {
1902 InsertError(ex);
1903 }
1904 }
1905
1906 //====================================================================================
1907 #endregion Process
1908
1909
1910 #region Grid Row Command
1911 //====================================================================================
1912
1913 protected void Grid_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
1914 {
1915 StatusBar1.addNewLine("xx");
1916
1917 GridView gridview1 = (GridView)sender;
1918
1919 StatusBar1.addNewLine(e.CommandName + " " + e.CommandArgument + " " + e.CommandSource);
1920 GSRDB1DataContext db = new GSRDB1DataContext();
1921
1922 int JobNameID = Convert.ToInt32(ddlJobName.SelectedValue);
1923 int DepartmentID = Convert.ToInt32(ddlDepartment.SelectedValue);
1924
1925 int SkillSetID = Convert.ToInt32(TabContainer1.ActiveTab.ID);
1926 int MeasurementID = Convert.ToInt16(gridview1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[2].Text);
1927
1928 StatusBar1.addNewLine(DepartmentID.ToString() + " " + JobNameID.ToString() + " " + SkillSetID.ToString() + " " + MeasurementID); ;
1929
1930
1931 KSSMCache oKSSMCache = new KSSMCache();
1932
1933 var query = oKSSMCache.Delete(DepartmentID, JobNameID, SkillSetID, MeasurementID);
1934
1935 StatusBar1.addNewLine("delete: " + query.Count().ToString());
1936 string JSScript = string.Format("<script>alert('{0}');window.location.reload();</script>", query.Count().ToString());
1937
1938 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", JSScript, false);
1939
1940 //StatusBar1.StatusContent = "Grid_RowCommand: " + e.CommandName + "<br/>";
1941
1942 // If multiple ButtonField column fields are used, use the
1943 // CommandName property to determine which button was clicked.
1944 //printDebug(false,"Row Command");
1945 //if (e.CommandName == "Select")
1946 //{
1947
1948 // // updateGrids();
1949 // GridView gridview1 = (GridView)sender;
1950
1951 // // Convert the row index stored in the CommandArgument
1952 // // property to an Integer.
1953 // int index = Convert.ToInt32(e.CommandArgument);
1954
1955 // // Get the last name of the selected author from the appropriate
1956 // // cell in the GridView control.
1957 // GridViewRow selectedRow = gridview1.Rows[index];
1958 // TableCell selectedCell = selectedRow.Cells[1];
1959 // string contact = selectedCell.Text;
1960
1961
1962 // string SectionName = selectedRow.Cells[SectionColumnNumber].Text;
1963 // string DepartmentName = selectedRow.Cells[DepartmentIDColumnNumber].Text;
1964
1965 // ddlDepartmentName.SelectedValue = DepartmentName;
1966
1967 // fillddlSectionName();
1968
1969 // ddlSectionName.SelectedValue = selectedRow.Cells[SectionIDColumnNumber].Text;
1970 //}
1971
1972 //StatusBar1.StatusContent += e.CommandName + "<br/>";
1973 }
1974 //Deletes Caching
1975 protected void Grid_RowDeleting(object sender, GridViewDeleteEventArgs e)
1976 {
1977 StatusBar1.StatusContent += "Grid_RowDeleting: " + e.RowIndex.ToString() + "<br/>";
1978
1979 try
1980 {
1981 GridView gridview1 = (GridView)sender;
1982
1983 int index = e.RowIndex;
1984 GSRDB1DataContext db = new GSRDB1DataContext();
1985
1986 int JobNameID = Convert.ToInt32(ddlJobName.SelectedValue);
1987 int DepartmentID = Convert.ToInt32(ddlDepartment.SelectedValue);
1988
1989 int SkillSetID = Convert.ToInt32(TabContainer1.ActiveTab.ID);
1990
1991 StatusBar1.addNewLine(DepartmentID.ToString() + " " + JobNameID.ToString() + " " + SkillSetID.ToString());
1992
1993
1994 //int MeasurementID = Convert.ToInt16(gridview1.Rows[index].Cells[3].Text);
1995
1996 //int PositionID = new KPosition().getPositionID(DepartmentID, JobNameID);
1997
1998 //if (PositionID != -1)
1999 //{
2000 // SSM_Cache oSSM = db.SSM_Caches.Single(o=>o.SkillSetID == SkillSetID && o.MeasurementID == MeasurementID);
2001
2002 // SkillSetMeasurement oSSM = db.SkillSetMeasurements.Single(p => p.PositionID == PositionID &&
2003 // p.SkillSetID == SkillSetID &&
2004 // p.MeasurementID == MeasurementID);
2005
2006 // StatusBar1.StatusContent += "Grid_RowDeleting: " + PositionID.ToString() + " "
2007 // + SkillSetID.ToString() + " " + MeasurementID.ToString() + " " + oSSM.ID.ToString() + "<br/>";
2008
2009 // db.SkillSetMeasurements.DeleteOnSubmit(oSSM);
2010 // db.SubmitChanges();
2011
2012 // updateGrids();
2013 // loadGridValues();
2014 //}
2015
2016 }
2017 catch (Exception ex)
2018 {
2019 InsertError(ex);
2020 StatusBar1.StatusContent += ex.Message;
2021 }
2022 }
2023
2024 protected void Grid_PageIndexChanging(object sender, GridViewPageEventArgs e)
2025 {
2026
2027 }
2028
2029 //====================================================================================
2030 #endregion
2031
2032
2033
2034 #region Button Events
2035 //====================================================================================
2036
2037 // bring all new
2038 protected void btnNew_Click(object sender, EventArgs e)
2039 {
2040 ddlDepartment.Visible = true;
2041 ddlJobName.Visible = true;
2042 //ddlPosition.Visible = false;
2043 //btnCreatePosition.Visible = true;
2044
2045 }
2046
2047 protected void btnQuery_Click(object sender, EventArgs e)
2048 {
2049
2050 }
2051
2052 protected void btnOkay_Click(object sender, EventArgs e)
2053 {
2054 //AlertTable.Visible = false;
2055 //ErrorMsgTable.Visible = false;
2056 }
2057
2058 protected void btnClear_Click(object sender, EventArgs e)
2059 {
2060 clearForm();
2061 }
2062
2063 protected void btnUpdate_Click(object sender, EventArgs e)
2064 {
2065 Button CurrentButton = (Button)sender;
2066
2067 switch (CurrentButton.CommandArgument)
2068 {
2069 case "complete":
2070 Complete();
2071 DeleteCache();
2072 break;
2073 case "update":
2074 Complete();
2075 break;
2076 case "ssm":
2077 break;
2078 }
2079
2080 //updateWeights();
2081 //System.Threading.Thread.Sleep(4000);
2082 //refreshForm();
2083 }
2084 // cache = ssm_cache , data = ssm, position, ect...
2085 protected void btnDelete_Click(object sender, EventArgs e)
2086 {
2087 switch (((Button)sender).CommandArgument)
2088 {
2089 case "cache":
2090 DeleteCache();
2091 break;
2092 case "data":
2093 break;
2094
2095 }
2096
2097 //refreshForm();
2098 }
2099
2100 protected void btnExit_Click(object sender, EventArgs e)
2101 {
2102 Response.Redirect("Default.aspx");
2103 }
2104
2105 protected void btnToggleButton_Click(object sender, EventArgs e)
2106 {
2107 Button CurrentButton = (Button)sender;
2108 switch (CurrentButton.CommandArgument)
2109 {
2110 case "MeasurementBulletedList":
2111 MeasurementBulletedList.Visible = true;
2112 MeasurementCheckBoxListRow.Visible = true;
2113 MeasurementTabRow.Visible = false;
2114 DescriptionRow.Style.Add("display", "none");
2115 QualificationRow.Style.Add("display", "none");
2116 SSMCacheButtonRow.Style.Add("display", "block");
2117 break;
2118 case "MeasurementTabRow":
2119 MeasurementBulletedList.Visible = false;
2120 MeasurementCheckBoxListRow.Visible = false;
2121 MeasurementTabRow.Visible = true;
2122 DescriptionRow.Style.Add("display", "block");
2123 QualificationRow.Style.Add("display", "block");
2124 SSMCacheButtonRow.Style.Add("display", "none");
2125 break;
2126 }
2127 }
2128
2129 protected void btnTruncateSSMCache_Click(object sender, EventArgs e)
2130 {
2131 TruncateSSMCache();
2132 }
2133
2134 //====================================================================================
2135 #endregion Button Events
2136
2137
2138 private void InsertError(Exception ex)
2139 {
2140 WebErrorReport oWebErrorReport = new WebErrorReport();
2141 //oWebErrorReport.InsertError(ex, Request.Url.ToString(), Request.ServerVariables["REMOTE_ADDR"]);
2142 StatusBar1.addNewLine(ex.Message + " " + ex.StackTrace.ToString());
2143 }
2144
2145 [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
2146 public static string GetDynamicContent(string contextKey)
2147 {
2148 return default(string);
2149 }
2150 }
2151
2152
2153
2154