private void OnExecuteEvent() { if (batchStatus == DBMode.Run) { userStopBatch = MetroMessageBox.Show(this, Properties.Resources.Msg_StopBatch, Properties.Resources.Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Yes; return; } if (!this.Validate()) { return; } if (OnBeforeRun()) { metroToolbar1.Status = MetroToolbarState.Run; userStopBatch = false; batchStatus = DBMode.Run; ManageToolbarEvents(); UseWaitCursor = true; //Cursor = Cursors.WaitCursor; Application.DoEvents(); OnRun(); //Cursor = System.Windows.Forms.Cursors.Default; UseWaitCursor = false; batchStatus = DBMode.Browse; ManageToolbarEvents(); OnDisableControlsForRun(); metroToolbar1.Status = MetroToolbarState.Browse; } }
private void OnStartPrintEvent() { if (!this.Validate()) { return; } if (OnBeforeRun()) { userStopBatch = false; batchStatus = DBMode.Run; ManageToolbarEvents(); //Parent.Cursor = Cursors.WaitCursor; Application.DoEvents(); ClearParameters(); OnRun(); //Cursor = System.Windows.Forms.Cursors.Default; batchStatus = DBMode.Browse; ManageToolbarEvents(); OnDisableControlsForRun(); } }
private void btnOK_Click(object sender, System.EventArgs e) { if (DBServerType == OGen.lib.datalayer.DBServerTypes.invalid) { System.Windows.Forms.MessageBox.Show( "a valid 'DB Type' must be provided", "Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning ); Pick_DBType.Focus(); return; } if (DBMode.Trim() == string.Empty) { System.Windows.Forms.MessageBox.Show( "a valid 'Mode' must be provided", "Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning ); txtMode.Focus(); return; } if (rbtConnectionstring.Checked) { if (txtConnectionString.Text.Trim() == string.Empty) { System.Windows.Forms.MessageBox.Show( "a valid 'Connectionstring' must be provided", "Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning ); txtConnectionString.Focus(); return; } } else { if (txtServer.Text.Trim() == string.Empty) { System.Windows.Forms.MessageBox.Show( "a valid 'Server' must be provided", "Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning ); txtServer.Focus(); return; } if (txtUserName.Text.Trim() == string.Empty) { System.Windows.Forms.MessageBox.Show( "a valid 'User Name' must be provided", "Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning ); txtUserName.Focus(); return; } if (txtDatabase.Text.Trim() == string.Empty) { System.Windows.Forms.MessageBox.Show( "a valid 'Database' must be provided", "Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning ); txtDatabase.Focus(); return; } } this.DialogResult = DialogResult.OK; this.Close(); }
public ActionResult Index() { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } Session["colordata"] = null; ViewBag.Logout = Session["Username"]; ViewBag.roleid = Session["RoleID"]; //calculating Corrected Date TimeSpan currentHourMint = new TimeSpan(05, 59, 59); TimeSpan RealCurrntHour = System.DateTime.Now.TimeOfDay; string CorrectedDate = DateTime.Now.Date.ToString("yyyy-MM-dd"); if (RealCurrntHour < currentHourMint) { CorrectedDate = DateTime.Now.AddDays(-1).Date.ToString("yyyy-MM-dd"); } // getting all machine details and their count. var macData = db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.IsNormalWC == 0); int mc = macData.Count(); ViewBag.macCount = mc; int[] macid = new int[mc]; int macidlooper = 0; foreach (var v in macData) { macid[macidlooper++] = v.MachineID; } Session["macid"] = macid; ViewBag.macCount = mc; int[,] maindata = new int[mc, 5]; //int[,] maindata = new int[mc, 6]; // write a raw query to get sum of powerOff, Operating, Idle, BreakDown, PlannedMaintenance. using (MsqlConnection mc1 = new MsqlConnection()) { mc1.open(); //SqlCommand cmd1 = new SqlCommand("SELECT MachineID,sum(MachineOffTime) as op,sum(OperatingTime)as o,sum(IdleTime) as it,sum(BreakdownTime)as bt FROM i_facility_tsal.dbo.tblmimics where CorrectedDate='" + CorrectedDate + "'and MachineID IN (select distinct(MachineID) from tblmachinedetails where IsDeleted = 0 and IsNormalWC = 0) group by MachineID", mc1.msqlConnection); //SqlCommand cmd1 = " SELECT MachineID, sum(convert(int, MachineOffTime) )as op,sum(convert(int, OperatingTime)) as o,sum(convert(int, IdleTime)) as it,sum(convert(int, BreakdownTime)) as bt FROM i_facility_tsal.dbo.tblmimics where CorrectedDate = '2019-06-21'and MachineID IN(select distinct(MachineID) from tblmachinedetails where IsDeleted = 0 and IsNormalWC = 0) group by MachineID", //SqlCommand cmd1 = new SqlCommand("SELECT MachineID,sum(convert (int,MachineOffTime) )as op,sum(convert (int,OperatingTime))as o,sum(convert (int,IdleTime)) as it,sum(convert (int,BreakdownTime))as bt FROM i_facility_tsal.dbo.tblmimics where CorrectedDate='" + CorrectedDate + "' and MachineID IN (select distinct(MachineID) from tblmachinedetails where IsDeleted = 0 and IsNormalWC = 0) group by MachineID", mc1.msqlConnection); SqlCommand cmd1 = new SqlCommand("SELECT MachineID, sum(convert(int, MachineOffTime) )as op,sum(convert(int, OperatingTime)) as o,sum(convert(int, IdleTime)) as it,sum(convert(int, BreakdownTime)) as bt FROM i_facility_tsal.dbo.tblmimics where CorrectedDate = '" + CorrectedDate + "' and MachineID IN(select distinct(MachineID) from tblmachinedetails where IsDeleted = 0 and IsNormalWC = 0) group by MachineID", mc1.msqlConnection); SqlDataReader datareader = cmd1.ExecuteReader(); int maindatalooper1 = 0; while (datareader.Read()) { int maindatalooper2 = 0; maindata[maindatalooper1, maindatalooper2++] = datareader.GetInt32(0); maindata[maindatalooper1, maindatalooper2++] = datareader.GetInt32(1); maindata[maindatalooper1, maindatalooper2++] = datareader.GetInt32(2); maindata[maindatalooper1, maindatalooper2++] = datareader.GetInt32(3); maindata[maindatalooper1, maindatalooper2++] = datareader.GetInt32(4); maindatalooper1++; } mc1.close(); } Session["colordata"] = maindata; //var tblMainDT = db.tbllivedailyprodstatus.Include(t => t.tblmachinedetail).Where(m => m.CorrectedDate == CorrectedDate).OrderBy(m => m.StartTime); //return View(tblMainDT.ToList()); //Get Modes for All Machines for Today //List<tbllivemodedb> tblModeDT = db.tblmodes.Where(m => m.CorrectedDate == CorrectedDate && m.tblmachinedetail.IsDeleted == 0 && m.tblmachinedetail.IsNormalWC == 0).OrderBy(m => m.MachineID).ThenBy(m => m.StartTime).ToList(); List <tbllivemodedb> tblModeDT = db.tbllivemodedbs.Where(m => m.CorrectedDate == CorrectedDate && m.tblmachinedetail.IsDeleted == 0 && m.tblmachinedetail.IsNormalWC == 0 && m.IsCompleted == 1).OrderBy(m => m.MachineID).ThenBy(m => m.StartTime).ToList(); List <tbllivemodedb> tblModeDTCurr = db.tbllivemodedbs.Where(m => m.CorrectedDate == CorrectedDate && m.tblmachinedetail.IsDeleted == 0 && m.tblmachinedetail.IsNormalWC == 0 && m.IsCompleted == 0).OrderBy(m => m.MachineID).ThenByDescending(m => m.ModeID).ToList(); //Get Latest Mode for each machine and Update the DurationInSec Column List <tbllivemodedb> CurrentModesOfAllMachines = (from row in tblModeDT where row.IsCompleted == 0 select row).ToList(); int PrvMachineID = 0; foreach (var row in tblModeDTCurr) { // DateTime startDateTime = Convert.ToDateTime( row.StartTime); // int DurInSec = Convert.ToInt32( DateTime.Now.Subtract(startDateTime).TotalSeconds ); // //row.DurationInSec = Convert.ToInt32( DateTime.Now.Subtract(startDateTime).TotalSeconds ); // int ModeID = row.ModeID; //foreach ( var tom in tblModeDT.Where(w => w.ModeID == ModeID)) { // tom.DurationInSec = DurInSec; // } if (PrvMachineID != row.MachineID) { DateTime startDateTime = Convert.ToDateTime(row.StartTime); int DurInSec = Convert.ToInt32(DateTime.Now.Subtract(startDateTime).TotalSeconds); //row.DurationInSec = Convert.ToInt32( DateTime.Now.Subtract(startDateTime).TotalSeconds ); int ModeID = row.ModeID; row.DurationInSec = DurInSec; tblModeDT.Add(row); //foreach (var tom in tblModeDT.Where(w => w.ModeID == ModeID)) //{ //} PrvMachineID = row.MachineID; } } List <DBMode> ShowMode = new List <DBMode>(); //Update DurationInSec to Minutes foreach (var MainRow in tblModeDT.Where(m => m.DurationInSec > 0)) { DBMode ShowModeItem = new DBMode(); ShowModeItem.ColorCode = MainRow.ColorCode; ShowModeItem.CorrectedDate = MainRow.CorrectedDate; ShowModeItem.DurationInSec = MainRow.DurationInSec / 60.00; ShowModeItem.EndTime = MainRow.EndTime; ShowModeItem.InsertedBy = MainRow.InsertedBy; ShowModeItem.InsertedOn = MainRow.InsertedOn; ShowModeItem.IsCompleted = MainRow.IsCompleted; ShowModeItem.IsDeleted = MainRow.IsDeleted; ShowModeItem.MachineID = MainRow.MachineID; ShowModeItem.Mode = MainRow.Mode; ShowModeItem.ModeID = MainRow.ModeID; ShowModeItem.ModifiedBy = MainRow.ModifiedBy; ShowModeItem.ModifiedOn = MainRow.ModifiedOn; ShowModeItem.StartTime = MainRow.StartTime; ShowModeItem.tblmachinedetail = MainRow.tblmachinedetail; ShowMode.Add(ShowModeItem); MainRow.DurationInSec = Convert.ToInt32(MainRow.DurationInSec / 60); } ; List <string> ShopNames = db.tbllivemodedbs.Where(m => m.CorrectedDate == CorrectedDate && m.tblmachinedetail.IsDeleted == 0 && m.tblmachinedetail.IsNormalWC == 0).Select(m => m.tblmachinedetail.ShopNo).Distinct().ToList(); ViewBag.DistinctShops = ShopNames; //return View(tblModeDT); return(View(ShowMode)); }
private void Button_mode_notDB_Click(object sender, EventArgs e) { mode = DBMode.NOTDB; Button_mode_all.Checked = false; Button_mode_database.Checked = false; Button_mode_files.Checked = false; Button_mode_missing.Checked = false; Button_mode_notDB.Checked = true; RefreshEntries(); }
private void AssignFiles() { if (NesEmu.EmulationON) NesEmu.EmulationPaused = true; FormAssignFilesToDB frm = new FormAssignFilesToDB(); if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { mode = DBMode.ALL; Button_mode_all.Checked = true; Button_mode_database.Checked = false; Button_mode_files.Checked = false; Button_mode_missing.Checked = false; Button_mode_notDB.Checked = false; _thread_busy = true; _assign_folders = frm.FoldersToScan; _assign_subfolders = frm.IncludeSubFolders; _assign_addFilesNotFound = frm.AddFilesNotFound; _assign_update_entries_already_assigned = frm.UpdateEntriesAlreadyAssigned; _generate_thread = new Thread(new ThreadStart(AssignFilesThreaded)); _generate_thread.CurrentUICulture = Program.CultureInfo; _generate_thread.Start(); // Show working frmG = new FormGeneratingDatabase(false); frmG.ShowDialog(this); } }
private void GenerateDatabase() { if (NesEmu.EmulationON) NesEmu.EmulationPaused = true; FormCreateDatabase frm = new FormCreateDatabase(); if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { mode = DBMode.ALL; Button_mode_all.Checked = true; Button_mode_database.Checked = false; Button_mode_files.Checked = false; Button_mode_missing.Checked = false; Button_mode_notDB.Checked = false; _generate_dbName = frm.DBName; _generate_dbPath = frm.DBPath; _generate_dbMakeNesCartEntries = frm.DBGenerateNesCart; _generate_thread = new Thread(new ThreadStart(GenerateDatabaseThreaded)); _generate_thread.CurrentUICulture = Program.CultureInfo; _generate_thread.Start(); // Show working frmG = new FormGeneratingDatabase(true); frmG.ShowDialog(this); } }