示例#1
0
        private void PrevRevision_barButtonItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            PreviousRevision_Frm frm = new PreviousRevision_Frm();

            ServiceCallDataElements.SQLServer sqlServer = null;
            string          sCommandText     = "";
            string          sPrevCostSheetID = "";
            string          sMessage         = "";
            NotificationFrm notification     = null;

            try
            {
                sCommandText = "SELECT TOP 1 CostSheetID from Reporting.ForecastCostsheets WHERE WorkorderID = '" + myForecast.WorkOrderID + "' AND AddedOn < '" + myForecast.AddedOn + "' Order By Addedon DESC";

                sqlServer = new ServiceCallDataElements.SQLServer();

                sqlServer.ConnectionString = sConnectionString;

                sPrevCostSheetID = sqlServer.GetStringValue(sCommandText);

                if (sPrevCostSheetID != "")
                {
                    frm.OpenPrevCostSheet(myForecast.WorkOrderID, myForecast.ConnectionString, myForecast.AddedBy, sPrevCostSheetID);
                    frm.Show();
                }
                else
                {
                    // Display Notification there are no previous cost sheets to show!
                    sMessage = "There are no previous cost sheets to show!";

                    notification = new NotificationFrm();

                    notification.Display(sMessage, "Work Order Adjusted", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);

                    if (notification.ShowDialog() == DialogResult.OK)
                    {
                        notification.Hide();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (notification != null)
                {
                    notification.Dispose();
                }
            }
        }
示例#2
0
        private bool IsLatest()
        {
            bool   bResult = false;
            string sCommandText;
            string sLatestCostSheetID;

            try
            {
                sCommandText = "SELECT TOP 1 CostSheetID FROM Reporting.ForecastCostSheets WHERE workorderid='" + myForecast.WorkOrderID + "' AND Adjusted = 0 ORDER BY AddedOn DESC";

                sLatestCostSheetID = sqlServer.GetStringValue(sCommandText);

                if (myForecast.CostSheetID == sLatestCostSheetID)
                {
                    bResult = true;
                }
                else
                {
                    // check if sheet exists if not allow editing
                    sCommandText = "SELECT TOP 1 CostSheetID FROM Reporting.ForecastCostSheets WHERE CostSheetID='" + myForecast.CostSheetID + "'";

                    sLatestCostSheetID = sqlServer.GetStringValue(sCommandText);

                    if (sLatestCostSheetID == "")
                    {
                        bResult = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(bResult);
        }