コード例 #1
0
        public LotView(Site site)
        {
            //This represents if a new Lot is being created for a Site Object
            InitializeComponent();
            try
            {
                mLot = new Lot(db);

            }
            catch (Exception ex)
            {
                MessageBox.Show("Lot Object - " + msgCodes.GetString("M2101") + ex.Message, "Error - 2102", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            txtAddress.Text = site.GetAddress();
            txtCity.Text = site.GetCity();
            txtServiceSize.Text = ((site.GetServiceSize() == 0) ? "" : "" + site.GetServiceSize());
            unlockForm();
            this.Name = "NewLotView";
            mLot.SetAssociationID(site.GetSiteID());
            DataSet data = db.Select("*", Client.Table, Client.Fields.clientID.ToString() + " = '" + site.GetClientID() + "'");
            data.Read();
            Client client = new Client(data.GetRecordDataSet());
            mLot.SetRoughInValue(client.GetRoughInValue());
            mLot.SetServiceValue(client.GetServiceValue());
            mLot.SetFinalValue(client.GetFinalValue());

            totalPortions[0] = client.GetRoughInValue();
            totalPortions[1] = client.GetServiceValue();
            totalPortions[2] = client.GetFinalValue();
        }
コード例 #2
0
 private void dgSitesOrLots_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.ClickCount == 2)
     {
         if (dgSitesOrLots.SelectedCells.Count > 0)
         {
             SelectedItem = null;
             if (cmboType.SelectedIndex == 0)
             {
                 SiteBinding obj = (SiteBinding)dgSitesOrLots.SelectedCells[0].Item;
                 dataGridViewData.SeekToPrimaryKey(obj.siteID);
                 Site siteObj = new Site(dataGridViewData.GetRecordDataSet());
                 SelectedItem = siteObj;
             }
             else
             {
                 LotSelectorBinding obj = (LotSelectorBinding)dgSitesOrLots.SelectedCells[0].Item;
                 dataGridViewData.SeekToPrimaryKey(obj.lotID);
                 Lot lotObj = new Lot(dataGridViewData.GetRecordDataSet());
                 SelectedItem = lotObj;
             }
             RoutedEventArgs args = new RoutedEventArgs(ObjectSelectedEvent);
             RaiseEvent(args);
             this.Close();
         }
     }
 }
コード例 #3
0
 public InventoryTransactionView(Site site)
 {
     InitializeComponent();
     this.Name = "TransactionViewNewTransaction";
     isNewTransaction = true;
     txtReciever.Text = site.GetSiteName();
     displayOrHideForm();
     lockItemFields();
     ClearFields();
     db.BeginTransaction();
     mTransaction = new InventoryTransaction(site.GetSiteID());
     mTransaction.SetClientType(InventoryTransaction.ClientType.Builder);
 }
コード例 #4
0
 /// <summary>
 /// Creates a site referencing the provided client.
 /// </summary>
 /// <param name="pClient"></param>
 public SiteView(Client pClient)
 {
     try
     {
         mSite = new Site(db);
         foreman = new SiteContact(SiteContact.ContactTypes.Foreman, mSite.GetSiteID());
         SuperVisor1 = new SiteContact(SiteContact.ContactTypes.Supervisor1, mSite.GetSiteID());
         SuperVisor2 = new SiteContact(SiteContact.ContactTypes.Supervisor2, mSite.GetSiteID());
         SupplyAuth = new SiteContact(SiteContact.ContactTypes.SupplyAuth, mSite.GetSiteID());
         mSite.SetClientID(pClient.GetClientID());
         mClient = pClient;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Site Object - " + msgCodes.GetString("M2101") + ex.Message, "Error - 2102", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     InitializeComponent();
     isModified = false;
     this.Name = "SiteNewSite";
     newSite = true;
 }
コード例 #5
0
 /// <summary>
 /// Loads an existing site and allows for reference to client.
 /// </summary>
 /// <param name="pSite"></param>
 /// <param name="pClient"></param>
 public SiteView(Site pSite, Client pClient)
 {
     mSite = pSite;
     mClient = pClient;
     try
     {
         foreman = mSite.GetSiteContact(SiteContact.ContactTypes.Foreman);
         SuperVisor1 = mSite.GetSiteContact(SiteContact.ContactTypes.Supervisor1);
         SuperVisor2 = mSite.GetSiteContact(SiteContact.ContactTypes.Supervisor2);
         SupplyAuth = mSite.GetSiteContact(SiteContact.ContactTypes.SupplyAuth);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Loading Site Contacts - " + msgCodes.GetString("M2102") + ex.Message, "Error - 2102", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     InitializeComponent();
     lockFields();
     this.Name = "SiteView" + mSite.GetSiteID();
     PopulateAllFields();
     cmdSaveEdit.IsEnabled = true;
     isModified = false;
 }
コード例 #6
0
        private void LoadSummary()
        {
            try
            {
                DataSet data = db.Select("SUM(" + LotService.Fields.Amount.ToString() + ")", LotService.Table, LotService.Fields.lotID.ToString() + " = '" + mLot.GetLotID() + "'");
                if (data.NumberOfRows() > 0)
                {
                    data.Read();
                    amtServices.Amount = Single.Parse(data.getString(0));
                }

                data = db.Select("SUM(" + LotExtra.Fields.TotalPrice.ToString() + ")", LotExtra.Table, LotExtra.Fields.lotID.ToString() + " = '" + mLot.GetLotID() + "'");
                data.Read();
                if (data.getString(0).Equals(DBNull.Value))
                {
                    amtExtras.Amount = Single.Parse(data.getString(0));
                }

                data = db.Select("SUM(" + TimeSheet.Fields.Hours.ToString() + " * " + TimeSheet.Fields.Wage.ToString() + ")", TimeSheet.Table, TimeSheet.Fields.lotID.ToString() + " = '" + mLot.GetLotID() + "'");
                data.Read();
                if (data.getString(0).Equals(DBNull.Value))
                {
                    amtLabour.Amount = Single.Parse(data.getString(0));
                }

                data = db.Select("*", Site.Table, Site.Fields.siteID.ToString() + " = '" + mLot.GetAssociationID() + "'");
                if (data.NumberOfRows() > 0)
                {
                    data.Read();
                    Site assocSite = new Site(data.GetRecordDataSet());
                    data = db.Select("Average", "lot_material_average", "assocID = '" + assocSite.GetSiteID() + "'");
                }
                else
                {
                    data = db.Select("Average", "lot_material_average", "assocID = '" + mLot.GetLotID() + "'");

                }
                data.Read();
                if (data.getString(0).Equals(DBNull.Value))
                {
                    amtMaterials.Amount = Single.Parse(data.getString(0));
                }

                if ((amtServices.Amount + amtExtras.Amount) > (amtLabour.Amount + amtMaterials.Amount))
                {
                    amtProfit.Amount = (amtServices.Amount + amtExtras.Amount) - (amtLabour.Amount + amtMaterials.Amount);
                    amtProfit.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#1b9b0a"));
                }
                else
                {
                    amtProfit.Amount = (amtLabour.Amount + amtMaterials.Amount) - (amtServices.Amount + amtExtras.Amount);
                    amtProfit.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#cc3333"));
                }
            }
            catch (FormatException ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Loading Summary - " + msgCodes.GetString("M2102") + ex.Message, "Error - 2102", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #7
0
        private void dgLabourHours_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (dgLabourHours.SelectedItem != null)
            {
                try
                {
                    if (cmboType.SelectedItem.Equals(builderItem))
                    {
                        SiteMaterialCostsBinding obj = (SiteMaterialCostsBinding)dgLabourHours.SelectedItem;
                        DataSet data = db.Select("*", Site.Table, Site.Fields.siteID.ToString() + " = '" + obj.siteID + "'");
                        if (data.NumberOfRows() == 1)
                        {
                            data.Read();
                            Site site = new Site(data.GetRecordDataSet());

                            data = db.Select("*", Client.Table, Client.Fields.clientID.ToString() + " = '" + site.GetClientID() + "'");
                            data.Read();
                            Client client = new Client(data.GetRecordDataSet());

                            MainWindow.OpenTab(new SiteView(site, client), (Image)App.iconSet["symbol-site"], site.GetSiteName());
                        }
                    }
                    else
                    {
                        LotMaterialCostsBinding obj = (LotMaterialCostsBinding)dgLabourHours.SelectedItem;
                        DataSet data = db.Select("*", Lot.Table, Lot.Fields.lotID.ToString() + " = '" + obj.lotID + "'");
                        if (data.NumberOfRows() == 1)
                        {
                            data.Read();
                            Lot lot = new Lot(data.GetRecordDataSet());
                            MainWindow.OpenTab(new LotView(lot), (Image)App.iconSet["home"], lot.LotDisplayName());
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error loading selected lot/site - " + msgCodes.GetString("M2102") + " " + ex.Message, "Error - 2102", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
コード例 #8
0
 private void LoadTransaction()
 {
     ClearFields();
     try
     {
         if (mTransaction.GetClientType().Equals(InventoryTransaction.ClientType.Inventory))
         {
             isRestock = true;
             txtReciever.Text = "Inventory";
         }
         else
         {
             DataSet data = db.Select("*", Site.Table, Site.Fields.siteID.ToString() + " = '" + mTransaction.GetAssocID() + "'");
             if (data.NumberOfRows() > 0)
             {
                 data.Read();
                 Site site = new Site(data.GetRecordDataSet());
                 txtReciever.Text = site.GetSiteName();
             }
             else
             {
                 data = db.Select("*", Lot.Table, Lot.Fields.lotID.ToString() + " = '" + mTransaction.GetAssocID() + "'");
                 if (data.NumberOfRows() > 0)
                 {
                     data.Read();
                     Lot lot = new Lot(data.GetRecordDataSet());
                     txtReciever.Text = lot.LotDisplayName();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Loading Transaction Failed - " + msgCodes.GetString("M2102") + ex.Message, "Error - 2102", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     isTransactionLocked = true;
     dpTransactionDate.Text = mTransaction.GetDateOfTransaction().ToShortDateString();
     dpTransactionDate.IsReadOnly = true;
     LoadDateGrid();
 }