예제 #1
0
        protected void GoBtn_Click(object sender, EventArgs e)
        {
            // construct the string with the where clause as per above parameters.
            string _strSQL = "SELECT ItemTypeTbl.ItemDesc, ROUND(SUM(OrdersTbl.QuantityOrdered),2) AS Quantity" +
                             " FROM (OrdersTbl INNER JOIN ItemTypeTbl ON OrdersTbl.ItemTypeID = ItemTypeTbl.ItemTypeID)";

            bool _ByRoastDate = ddlFilterByRoastDate.SelectedValue.Equals("RoastDate");

            if (_ByRoastDate)
            {
                _strSQL += " WHERE (OrdersTbl.RoastDate >= ?) AND (OrdersTbl.RoastDate <= ?) ";
            }
            else
            {
                _strSQL += "  WHERE (OrdersTbl.RequiredByDate >= ?) AND (OrdersTbl.RequiredByDate <= ?) ";
            }
            _strSQL += " AND (ItemTypeTbl.ServiceTypeID = 2) GROUP BY ItemTypeTbl.ItemDesc";

            TrackerDb _TDB    = new TrackerDb();
            DateTime  _dtFrom = Convert.ToDateTime(tbxDateFrom.Text); // (ddlDateFrom.SelectedValue);

            _TDB.AddWhereParams(_dtFrom, DbType.Date, "@RoastDateFrom");
            _TDB.AddWhereParams(Convert.ToDateTime(tbxDateTo.Text), DbType.Date, "@RoastDateTo"); // ddlDateTo.SelectedValue), DbType.Date, "@RoastDateTo");
            double _Dbl = _dtFrom.DayOfYear / 7;

            ViewState[CONST_WEEKDESC] = "Y" + _dtFrom.Year.ToString() + " Wk " + Convert.ToString(Math.Ceiling(_Dbl) + 1);
            ltrlDates.Text            = String.Format("{0} - From: {1} to {2}", ((_ByRoastDate) ? "Roast Date" : "Prep Date"), tbxDateFrom.Text, tbxDateTo.Text); // ddlDateFrom.SelectedValue + " " + ddlDateTo.SelectedValue;
            // zero values
            ZeroViewStateVals();
            ;
            DataSet _ds = _TDB.ReturnDataSet(_strSQL);

            gvPreperationSummary.DataSource = _ds;
            gvPreperationSummary.DataBind();
        }
예제 #2
0
        /// <summary>
        /// Check to see if this contact has ever taken an item from this group before - if so return it otherwise return -1
        /// </summary>
        /// <param name="pContactID">The ID of the contact</param>
        /// <param name="pGroupItemTypeID">The Group ID requesed</param>
        /// <returns>True if it </returns>
        public UsedItemGroupTbl ContactLastGroupItem(long pContactID, int pGroupItemTypeID)
        {
            UsedItemGroupTbl _DataItem = new UsedItemGroupTbl();

            TrackerDb _TDB = new TrackerDb();

            _TDB.AddWhereParams(pContactID, DbType.Int64, "@ContactID");
            _TDB.AddWhereParams(pGroupItemTypeID, DbType.Int32, "@GroupItemTypeID");

            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(CONST_SQL_GETGROUPITEMTYPED); //SELECT UsedItemGroupID, LastItemTypeID, LastItemTypeSortPos, LastItemDateChanged, Notes FROM UsedItemGroupTbl WHERE(ContactID = ?) AND (GroupItemTypeID = ?)";

            if (_DataReader != null)
            {
                if (_DataReader.Read())
                {
                    _DataItem.UsedItemGroupID     = (_DataReader["UsedItemGroupID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["UsedItemGroupID"]);
                    _DataItem.ContactID           = pContactID;
                    _DataItem.GroupItemTypeID     = pGroupItemTypeID;
                    _DataItem.LastItemTypeID      = (_DataReader["LastItemTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["LastItemTypeID"]);
                    _DataItem.LastItemTypeSortPos = (_DataReader["LastItemTypeSortPos"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["LastItemTypeSortPos"]);
                    _DataItem.LastItemDateChanged = (_DataReader["LastItemDateChanged"] == DBNull.Value) ? System.DateTime.Now : Convert.ToDateTime(_DataReader["LastItemDateChanged"]);
                    _DataItem.Notes = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString();
                }
                _DataReader.Close();
            }
            _TDB.Close();

            return(_DataItem);
        }
예제 #3
0
        public string Update(UsedItemGroupTbl pUsedItemGroupTbl, int pOrignal_UsedItemGroupID)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            #region UpdateParameters
            if (pOrignal_UsedItemGroupID > 0)
            {
                _TDB.AddWhereParams(pOrignal_UsedItemGroupID, DbType.Int32); // check this line it assumes id field is int32
            }
            else
            {
                _TDB.AddWhereParams(pUsedItemGroupTbl.UsedItemGroupID, DbType.Int32, "@UsedItemGroupID");
            }

            _TDB.AddParams(pUsedItemGroupTbl.ContactID, DbType.Int64, "@ContactID");
            _TDB.AddParams(pUsedItemGroupTbl.GroupItemTypeID, DbType.Int32, "@GroupItemTypeID");
            _TDB.AddParams(pUsedItemGroupTbl.LastItemTypeID, DbType.Int32, "@LastItemTypeID");
            _TDB.AddParams(pUsedItemGroupTbl.LastItemTypeSortPos, DbType.Int32, "@LastItemTypeSortPos");
            _TDB.AddParams(pUsedItemGroupTbl.LastItemDateChanged, DbType.Date, "@LastItemDateChanged");
            _TDB.AddParams(pUsedItemGroupTbl.Notes, DbType.String, "@Notes");
            #endregion
            // Now we have the parameters excute the SQL
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATE); // UPDATE UsedItemGroupTbl SET ContactID = ?, GroupItemTypeID = ?, LastItemTypeID = ?, LastItemTypeSortPos = ?, LastItemDateChanged = ?, Notes = ?  WHERE (UsedItemGroupID = ?)";
            _TDB.Close();
            return(_result);
        }
예제 #4
0
        public ItemGroupTbl GetNextGroupItemType(int pGroupItemTypeID, int pItemTypeSortPos)
        {
            ItemGroupTbl _DataItem = new ItemGroupTbl();

            TrackerDb _TDB = new TrackerDb();

            _TDB.AddWhereParams(pGroupItemTypeID, DbType.Int32, "GroupItemTypeID");
            _TDB.AddWhereParams(pItemTypeSortPos, DbType.Int32, "ItemTypeSortPos");

            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(CONST_SELECT_NEXTINGROUP);

            if (_DataReader != null)
            {
                if (_DataReader.Read())
                {
                    #region StoreThisDataItem
                    _DataItem.ItemGroupID     = (_DataReader["ItemGroupID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ItemGroupID"]);
                    _DataItem.GroupItemTypeID = (_DataReader["GroupItemTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["GroupItemTypeID"]);
                    _DataItem.ItemTypeID      = (_DataReader["ItemTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ItemTypeID"]);
                    _DataItem.ItemTypeSortPos = (_DataReader["ItemTypeSortPos"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ItemTypeSortPos"]);
                    _DataItem.Enabled         = (_DataReader["Enabled"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["Enabled"]);
                    _DataItem.Notes           = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString();
                    #endregion
                }
                else
                {
                    _DataItem = GetFirstGroupItemType(pGroupItemTypeID); // did not find we must be at the end of the group.
                }
                _DataReader.Close();
            }

            _TDB.Close();

            return(_DataItem);
        }
예제 #5
0
        public UsedItemGroupTbl GetLastUsedItemID(long pContactID, int pItemID, DateTime pDeliveryDate)
        {
            UsedItemGroupTbl _DataItem = new UsedItemGroupTbl();
            TrackerDb        _TDB      = new TrackerDb();

            _TDB.AddWhereParams(pContactID, DbType.Int64, "@ContactID");
            _TDB.AddWhereParams(pItemID, DbType.Int32, "@LastItemTypeID");
            _TDB.AddWhereParams(pDeliveryDate, DbType.Date, "@LastItemDateChanged ");

            //"SELECT UsedItemGroupID, GroupItemTypeID, LastItemTypeSortPos, Notes FROM UsedItemGroupTbl WHERE ContactID = ? AND LastItemTypeID = ? AND LastItemDateChanged = ?";
            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(CONST_SELECTLASTUSEDITEMID);

            if (_DataReader != null)
            {
                if (_DataReader.Read())
                {
                    _DataItem.UsedItemGroupID     = (_DataReader["UsedItemGroupID"] == DBNull.Value) ? TrackerDb.CONST_INVALIDID : Convert.ToInt32(_DataReader["UsedItemGroupID"]);
                    _DataItem.ContactID           = pContactID;
                    _DataItem.GroupItemTypeID     = (_DataReader["GroupItemTypeID"] == DBNull.Value) ? TrackerDb.CONST_INVALIDID : Convert.ToInt32(_DataReader["GroupItemTypeID"]);
                    _DataItem.LastItemTypeID      = pItemID;
                    _DataItem.LastItemTypeSortPos = (_DataReader["LastItemTypeSortPos"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["LastItemTypeSortPos"]);
                    _DataItem.LastItemDateChanged = pDeliveryDate;
                    _DataItem.Notes = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString();
                }
                _DataReader.Close();
            }
            _TDB.Close();

            return(_DataItem);
        }
예제 #6
0
        public string Update(PaymentTermsTbl pPaymentTermsTbl, int pOrignal_PaymentTermID)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            #region UpdateParameters
            if (pOrignal_PaymentTermID > 0)
            {
                _TDB.AddWhereParams(pOrignal_PaymentTermID, DbType.Int32); // check this line it assumes id field is int32
            }
            else
            {
                _TDB.AddWhereParams(pPaymentTermsTbl.PaymentTermID, DbType.Boolean, "@PaymentTermID");
            }

            _TDB.AddParams(pPaymentTermsTbl.PaymentTermDesc, DbType.String, "@PaymentTermDesc");
            _TDB.AddParams(pPaymentTermsTbl.PaymentDays, DbType.Int32, "@PaymentDays");
            _TDB.AddParams(pPaymentTermsTbl.DayOfMonth, DbType.Int32, "@DayOfMonth");
            _TDB.AddParams(pPaymentTermsTbl.UseDays, DbType.Boolean, "@UseDays");
            _TDB.AddParams(pPaymentTermsTbl.Enabled, DbType.Boolean, "@Enabled");
            _TDB.AddParams(pPaymentTermsTbl.Notes, DbType.String, "@Notes");
            #endregion
            // Now we have the parameters excute the SQL
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATE);
            _TDB.Close();
            return(_result);
        }
예제 #7
0
        public string Update(PriceLevelsTbl pPriceLevelsTbl, int pOrignal_PriceLevelID)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            #region UpdateParameters
            if (pOrignal_PriceLevelID > 0)
            {
                _TDB.AddWhereParams(pOrignal_PriceLevelID, DbType.Int32); // check this line it assumes id field is int32
            }
            else
            {
                _TDB.AddWhereParams(pPriceLevelsTbl.PriceLevelID, DbType.Boolean, "@PriceLevelID");
            }

            _TDB.AddParams(pPriceLevelsTbl.PriceLevelDesc, DbType.String, "@PriceLevelDesc");
            _TDB.AddParams(Math.Round(pPriceLevelsTbl.PricingFactor, 3), DbType.Double, "@PricingFactor");
            _TDB.AddParams(pPriceLevelsTbl.Enabled, DbType.Int32, "@Enabled");
            _TDB.AddParams(pPriceLevelsTbl.Notes, DbType.String, "@Notes");
            #endregion
            // Now we have the parameters excute the SQL
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATE);
            _TDB.Close();
            return(_result);
        }
예제 #8
0
        public string UpdateItemGroup(ItemGroupTbl pItemGroupTbl, int pOrignal_ItemGroupID)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            #region UpdateParameters
            if (pOrignal_ItemGroupID > 0)
            {
                _TDB.AddWhereParams(pOrignal_ItemGroupID, DbType.Int32); // check this line it assumes id field is int32
            }
            else
            {
                _TDB.AddWhereParams(pItemGroupTbl.ItemGroupID, DbType.Int32, "@ItemGroupID");
            }

            _TDB.AddParams(pItemGroupTbl.GroupItemTypeID, DbType.Int32, "@GroupItemTypeID");
            _TDB.AddParams(pItemGroupTbl.ItemTypeID, DbType.Int32, "@ItemTypeID");
            _TDB.AddParams(pItemGroupTbl.ItemTypeSortPos, DbType.Int32, "@ItemTypeSortPos");
            _TDB.AddParams(pItemGroupTbl.Enabled, DbType.Boolean, "@Enabled");
            _TDB.AddParams(pItemGroupTbl.Notes, DbType.String, "@Notes");
            #endregion
            // Now we have the parameters excute the SQL
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATE);
            _TDB.Close();
            return(_result);
        }
예제 #9
0
        public string Update(CustomersAccInfoTbl pCustomersAccInfoTbl, long pOrignal_CustomersAccInfoID)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            if (pCustomersAccInfoTbl.CustomerID == 0)
            {
                _result = "error: CustomerID cannot be 0";
            }
            else
            {
                #region UpdateParameters

                if (pOrignal_CustomersAccInfoID > 0)
                {
                    _TDB.AddWhereParams(pOrignal_CustomersAccInfoID, DbType.Int64); // check this line it assumes id field is int32
                }
                else
                {
                    _TDB.AddWhereParams(pCustomersAccInfoTbl.CustomersAccInfoID, DbType.Int64, "@CustomersAccInfoID");
                }

                _TDB.AddParams(pCustomersAccInfoTbl.CustomerID, DbType.Int64, "@CustomerID");
                _TDB.AddParams(pCustomersAccInfoTbl.RequiresPurchOrder, DbType.Int32, "@RequiresPurchOrder");
                _TDB.AddParams(pCustomersAccInfoTbl.CustomerVATNo, DbType.String, "@CustomerVATNo");
                _TDB.AddParams(pCustomersAccInfoTbl.BillAddr1, DbType.String, "@BillAddr1");
                _TDB.AddParams(pCustomersAccInfoTbl.BillAddr2, DbType.String, "@BillAddr2");
                _TDB.AddParams(pCustomersAccInfoTbl.BillAddr3, DbType.String, "@BillAddr3");
                _TDB.AddParams(pCustomersAccInfoTbl.BillAddr4, DbType.String, "@BillAddr4");
                _TDB.AddParams(pCustomersAccInfoTbl.BillAddr5, DbType.String, "@BillAddr5");
                _TDB.AddParams(pCustomersAccInfoTbl.ShipAddr1, DbType.String, "@ShipAddr1");
                _TDB.AddParams(pCustomersAccInfoTbl.ShipAddr2, DbType.String, "@ShipAddr2");
                _TDB.AddParams(pCustomersAccInfoTbl.ShipAddr3, DbType.String, "@ShipAddr3");
                _TDB.AddParams(pCustomersAccInfoTbl.ShipAddr4, DbType.String, "@ShipAddr4");
                _TDB.AddParams(pCustomersAccInfoTbl.ShipAddr5, DbType.String, "@ShipAddr5");
                _TDB.AddParams(pCustomersAccInfoTbl.AccEmail, DbType.String, "@AccEmail");
                _TDB.AddParams(pCustomersAccInfoTbl.AltAccEmail, DbType.String, "@AltAccEmail");
                _TDB.AddParams(pCustomersAccInfoTbl.PaymentTermID, DbType.Int32, "@PaymentTermID");
                _TDB.AddParams(pCustomersAccInfoTbl.Limit, DbType.Double, "@Limit");
                _TDB.AddParams(pCustomersAccInfoTbl.FullCoName, DbType.String, "@FullCoName");
                _TDB.AddParams(pCustomersAccInfoTbl.AccFirstName, DbType.String, "@AccFirstName");
                _TDB.AddParams(pCustomersAccInfoTbl.AccLastName, DbType.String, "@AccLastName");
                _TDB.AddParams(pCustomersAccInfoTbl.AltAccFirstName, DbType.String, "@AltAccFirstName");
                _TDB.AddParams(pCustomersAccInfoTbl.AltAccLastName, DbType.String, "@AltAccLastName");
                _TDB.AddParams(pCustomersAccInfoTbl.PriceLevelID, DbType.Int32, "@PriceLevelID");
                _TDB.AddParams(pCustomersAccInfoTbl.InvoiceTypeID, DbType.Int32, "@InvoiceTypeID");
                _TDB.AddParams(pCustomersAccInfoTbl.RegNo, DbType.String, "@RegNo");
                _TDB.AddParams(pCustomersAccInfoTbl.BankAccNo, DbType.String, "@BankAccNo");
                _TDB.AddParams(pCustomersAccInfoTbl.BankBranch, DbType.String, "@BankBranch");
                _TDB.AddParams(pCustomersAccInfoTbl.Enabled, DbType.Boolean, "@Enabled");
                _TDB.AddParams(pCustomersAccInfoTbl.Notes, DbType.String, "@Notes");
                #endregion
                // Now we have the parameters excute the SQL
                _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATE);
                _TDB.Close();
            }
            return(_result);
        }
예제 #10
0
        public string DeleteGroupItemFromGroup(int pGroupItemID, int pItemTypeID)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            _TDB.AddWhereParams(pGroupItemID, DbType.Int32, "@GroupItemTypeID");
            _TDB.AddWhereParams(pItemTypeID, DbType.Int32, "@ItemTypeID");
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_DELETEITEMFROMGROUP);
            _TDB.Close();
            return(_result);
        }
예제 #11
0
        public string UpdateItemsSortPos(int pSortPos, int pGroupItemID, int pItemTypeID)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            _TDB.AddParams(pSortPos, DbType.Int32, "@SortPos");
            _TDB.AddWhereParams(pGroupItemID, DbType.Int32, "@GroupItemTypeID");
            _TDB.AddWhereParams(pItemTypeID, DbType.Int32, "@ItemTypeID");
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATEITEMSORTPOS);
            _TDB.Close();
            return(_result);
        }
예제 #12
0
        /// <summary>
        /// Update only Contact Type, usese pContact.CustType and pContact.CustID
        /// </summary>
        /// <param name="pContact">cus</param>
        /// <returns></returns>
        public string UpdateContactTypeIfInfoOnly(long pCustomerID, int pCustomerTypeID)
        {
            string _Err = String.Empty;

            TrackerDb _TDB = new TrackerDb();

            _TDB.AddParams(pCustomerTypeID, DbType.Int32);
            _TDB.AddWhereParams(pCustomerID, DbType.Int64);
            _TDB.AddWhereParams(CustomerTypeTbl.CONST_INFO_ONLY, DbType.Int32);
            // CONST_SQL_UPDATE

            _Err = _TDB.ExecuteNonQuerySQLWithParams(CONST_SQL_UPDATETYPEONLY, _TDB.Params, _TDB.WhereParams);
            _TDB.Close();
            return(_Err);
        }
예제 #13
0
        public int GetLastIDInserted(long pCustomerID)
        {
            int _LastID = 0;

            TrackerDb _TDB = new TrackerDb();

            _TDB.AddWhereParams(pCustomerID, DbType.Int64);

            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(CONST_SQL_SELECTLAST);

            if (_DataReader != null)
            {
                if (_DataReader.Read())
                {
                    _LastID = (_DataReader["RepairID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["RepairID"]);
                }
                else
                {
                    _DataReader.Close();
                }
            }

            _TDB.Close();

            return(_LastID);
        }
예제 #14
0
        public List <SentRemindersLogTbl> GetAllByDate(DateTime pDateSent, string SortBy)
        {
            List <SentRemindersLogTbl> _DataItems = new List <SentRemindersLogTbl>();
            TrackerDb _TrackerDb = new TrackerDb();
            string    _sqlCmd    = CONST_SQL_SELECT_BYDATESENT;

            if (!String.IsNullOrEmpty(SortBy))
            {
                _sqlCmd += " ORDER BY " + SortBy;                              // Add order by string
            }
            // params would go here if need
            _TrackerDb.AddWhereParams(pDateSent.Date, DbType.Date);
            IDataReader _DataReader = _TrackerDb.ExecuteSQLGetDataReader(_sqlCmd);

            if (_DataReader != null)
            {
                while (_DataReader.Read())
                {
                    SentRemindersLogTbl _DataItem = new SentRemindersLogTbl();

                    _DataItem.ReminderID        = (_DataReader["ReminderID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ReminderID"]);
                    _DataItem.CustomerID        = (_DataReader["CustomerID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["CustomerID"]);
                    _DataItem.DateSentReminder  = (_DataReader["DateSentReminder"] == DBNull.Value) ? System.DateTime.Now.Date : Convert.ToDateTime(_DataReader["DateSentReminder"]).Date;
                    _DataItem.NextPrepDate      = (_DataReader["NextPrepDate"] == DBNull.Value) ? System.DateTime.Now.Date : Convert.ToDateTime(_DataReader["NextPrepDate"]).Date;
                    _DataItem.ReminderSent      = (_DataReader["ReminderSent"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["ReminderSent"]);
                    _DataItem.HadAutoFulfilItem = (_DataReader["HadAutoFulfilItem"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["HadAutoFulfilItem"]);
                    _DataItem.HadReoccurItems   = (_DataReader["HadReoccurItems"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["HadReoccurItems"]);
                    _DataItems.Add(_DataItem);
                }
                _DataReader.Close();
            }
            _TrackerDb.Close();
            return(_DataItems);
        }
예제 #15
0
        public List <CityPrepDaysTbl> GetAllByCityId(int pCityID)
        {
            string _sqlCmd = CONST_SQL_SELECTBYCITYID;
            //if (!String.IsNullOrEmpty(SortBy))
            //  _sqlCmd += " ORDER BY " + SortBy;

            TrackerDb _TrackerDb = new TrackerDb();

            _TrackerDb.AddWhereParams(pCityID, DbType.Int32);

            List <CityPrepDaysTbl> _DataItems  = new List <CityPrepDaysTbl>();
            IDataReader            _DataReader = _TrackerDb.ExecuteSQLGetDataReader(_sqlCmd);

            if (_DataReader != null)
            {
                while (_DataReader.Read())
                {
                    CityPrepDaysTbl _DataItem = new CityPrepDaysTbl();

                    _DataItem.CityID            = pCityID;
                    _DataItem.CityPrepDaysID    = (_DataReader["CityPrepDaysID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["CityPrepDaysID"]);
                    _DataItem.PrepDayOfWeekID   = (_DataReader["PrepDayOfWeekID"] == DBNull.Value) ? byte.MinValue : Convert.ToByte(_DataReader["PrepDayOfWeekID"]);
                    _DataItem.DeliveryDelayDays = (_DataReader["DeliveryDelayDays"] == DBNull.Value) ? 0 : Convert.ToInt16(_DataReader["DeliveryDelayDays"]);
                    _DataItem.DeliveryOrder     = (_DataReader["DeliveryOrder"] == DBNull.Value) ? 0 : Convert.ToInt16(_DataReader["DeliveryOrder"]);

                    _DataItems.Add(_DataItem);
                }
                _DataReader.Close();
            }
            _TrackerDb.Close();
            return(_DataItems);
        }
예제 #16
0
        public string UpdateRepair(TrackerDotNet.control.RepairsTbl RepairItem, int orig_RepairID)
        {
            string    _result    = String.Empty;
            TrackerDb _TrackerDb = new TrackerDb();

            _TrackerDb.AddParams(RepairItem.CustomerID, DbType.Int64);
            _TrackerDb.AddParams(RepairItem.ContactName, DbType.String);
            _TrackerDb.AddParams(RepairItem.ContactEmail, DbType.String);
            _TrackerDb.AddParams(RepairItem.JobCardNumber, DbType.String);
            _TrackerDb.AddParams(RepairItem.DateLogged, DbType.Date);
            _TrackerDb.AddParams(RepairItem.LastStatusChange, DbType.Date);
            _TrackerDb.AddParams(RepairItem.MachineTypeID, DbType.Int32);
            _TrackerDb.AddParams(RepairItem.MachineSerialNumber, DbType.String);
            _TrackerDb.AddParams(RepairItem.SwopOutMachineID, DbType.Int32);
            _TrackerDb.AddParams(RepairItem.MachineConditionID, DbType.Int32);
            _TrackerDb.AddParams(RepairItem.TakenFrother, DbType.Boolean);
            _TrackerDb.AddParams(RepairItem.TakenBeanLid, DbType.Boolean);
            _TrackerDb.AddParams(RepairItem.TakenWaterLid, DbType.Boolean);
            _TrackerDb.AddParams(RepairItem.BrokenFrother, DbType.Boolean);
            _TrackerDb.AddParams(RepairItem.BrokenBeanLid, DbType.Boolean);
            _TrackerDb.AddParams(RepairItem.BrokenWaterLid, DbType.Boolean);
            _TrackerDb.AddParams(RepairItem.RepairFaultID, DbType.Int32);
            _TrackerDb.AddParams(RepairItem.RepairFaultDesc, DbType.String);
            _TrackerDb.AddParams(RepairItem.RepairStatusID, DbType.Int32);
            _TrackerDb.AddParams(RepairItem.RelatedOrderID, DbType.Int64);
            _TrackerDb.AddParams(RepairItem.Notes, DbType.String);

            _TrackerDb.AddWhereParams(orig_RepairID, DbType.Int32);

            _result = _TrackerDb.ExecuteNonQuerySQL(CONST_SQL_UPDATE);
            _TrackerDb.Close();

            return(_result);
        }
예제 #17
0
/*
 *    string _connectionStr = ConfigurationManager.ConnectionStrings[CONST_CONSTRING].ConnectionString;
 *
 *    using (OleDbConnection _conn = new OleDbConnection(_connectionStr))
 *    {
 *      string _sqlCmd = CONST_SQL_SELECT;
 *      if (!String.IsNullOrEmpty(SortBy)) _sqlCmd += " ORDER BY " + SortBy;     // Add order by string
 *      OleDbCommand _cmd = new OleDbCommand(_sqlCmd, _conn);                    // run the query we have built
 *      _conn.Open();
 *      OleDbDataReader _DataReader = _cmd.ExecuteReader();
 *      while (_DataReader.Read())
 *      {
 *        CustomerTrackedServiceItemsData _DataItem = new CustomerTrackedServiceItemsData();
 *
 *        _DataItem.CustomerTrackedServiceItemsID = (_DataReader["CustomerTrackedServiceItemsID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["CustomerTrackedServiceItemsID"]);
 *        _DataItem.CustomerTypeID = (_DataReader["CustomerTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["CustomerTypeID"]);
 *        _DataItem.ServiceTypeID = (_DataReader["ServiceTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ServiceTypeID"]);
 *        _DataItem.Notes = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString();
 *        _DataItems.Add(_DataItem);
 *      }
 *    }
 *    return _DataItems;
 *  }
 */
        public List <CustomerTrackedServiceItemsData> GetAllByCustomerTypeID(int pCustomerTypeID)
        {
            List <CustomerTrackedServiceItemsData> _DataItems = new List <CustomerTrackedServiceItemsData>();
            TrackerDb _TDB = new TrackerDb();

            _TDB.AddWhereParams(pCustomerTypeID, DbType.Int32, "@CustomerTypeID");
            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(CONST_SQL_SELECT_FORCUSTOMERTYPE);

            if (_DataReader != null)
            {
                while (_DataReader.Read())
                {
                    CustomerTrackedServiceItemsData _DataItem = new CustomerTrackedServiceItemsData();

                    _DataItem.CustomerTrackedServiceItemsID = (_DataReader["CustomerTrackedServiceItemsID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["CustomerTrackedServiceItemsID"]);
                    _DataItem.CustomerTypeID = pCustomerTypeID;
                    _DataItem.ServiceTypeID  = (_DataReader["ServiceTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ServiceTypeID"]);
                    _DataItem.Notes          = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString();

                    _DataItems.Add(_DataItem);
                }
                _DataReader.Close();
            }
            _TDB.Close();
            return(_DataItems);
        }
예제 #18
0
        public List <ItemGroupTbl> GetAllByGroupItemTypeID(int pGroupItemID, string SortBy)
        {
            List <ItemGroupTbl> _DataItems = new List <ItemGroupTbl>();

            if (!pGroupItemID.Equals(TrackerDb.CONST_INVALIDID))
            {
                TrackerDb _TDB    = new TrackerDb();
                string    _sqlCmd = CONST_SQL_SELECTBYGOUPITEMID;                                        //        = "SELECT ItemGroupID, GroupItemTypeID, ItemTypeID, ItemTypeSortPos, Enabled, Notes FROM ItemGroupTbl WHERE GroupItemTypeID=?";
                _sqlCmd += " ORDER BY " + ((String.IsNullOrEmpty(SortBy)) ? "ItemTypeSortPos" : SortBy); // Add order by string
                // params would go here if need
                _TDB.AddWhereParams(pGroupItemID, DbType.Int32, "@GroupItemTypeID");
                IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(_sqlCmd);
                if (_DataReader != null)
                {
                    while (_DataReader.Read())
                    {
                        ItemGroupTbl _DataItem = new ItemGroupTbl();

                        #region StoreThisDataItem
                        _DataItem.ItemGroupID     = (_DataReader["ItemGroupID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ItemGroupID"]);
                        _DataItem.GroupItemTypeID = (_DataReader["GroupItemTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["GroupItemTypeID"]);
                        _DataItem.ItemTypeID      = (_DataReader["ItemTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ItemTypeID"]);
                        _DataItem.ItemTypeSortPos = (_DataReader["ItemTypeSortPos"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ItemTypeSortPos"]);
                        _DataItem.Enabled         = (_DataReader["Enabled"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["Enabled"]);
                        _DataItem.Notes           = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString();
                        #endregion
                        _DataItems.Add(_DataItem);
                    }
                    _DataReader.Close();
                }
                _TDB.Close();
            }
            return(_DataItems);
        }
예제 #19
0
        public string DeleteByCityPrepDayID(int pCityPrepDayID)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            _TDB.AddWhereParams(pCityPrepDayID, DbType.Int32, "@CityPrepDayID");
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_DELETEBYID);
            _TDB.Close();
            return(_result);
        }
예제 #20
0
        public string Delete(int pPriceLevelID)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            _TDB.AddWhereParams(pPriceLevelID, DbType.Int32, "@PriceLevelID");
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_DELETE);
            _TDB.Close();
            return(_result);
        }
예제 #21
0
        public CustomersAccInfoTbl GetByCustomerID(long pCustomerID)
        {
            CustomersAccInfoTbl _DataItem = new CustomersAccInfoTbl();

            _DataItem.CustomerID = pCustomerID; // assing it to non zero so we can do error checking
            string    _sql = CONST_SQL_SELECTBYCUSTID;
            TrackerDb _TDB = new TrackerDb();

            // params would go here if need
            _TDB.AddWhereParams(pCustomerID, DbType.Int64, "@CustomerID");
            // _sql = _sql.Replace("?", pCustomerID.ToString());
            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(_sql);

            if (_DataReader != null)
            {
                if (_DataReader.Read())
                {
                    #region StoreThisDataItem
                    _DataItem.CustomersAccInfoID = (_DataReader["CustomersAccInfoID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["CustomersAccInfoID"]);
                    _DataItem.RequiresPurchOrder = (_DataReader["RequiresPurchOrder"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["RequiresPurchOrder"]);
                    _DataItem.CustomerVATNo      = (_DataReader["CustomerVATNo"] == DBNull.Value) ? string.Empty : _DataReader["CustomerVATNo"].ToString();
                    _DataItem.BillAddr1          = (_DataReader["BillAddr1"] == DBNull.Value) ? string.Empty : _DataReader["BillAddr1"].ToString();
                    _DataItem.BillAddr2          = (_DataReader["BillAddr2"] == DBNull.Value) ? string.Empty : _DataReader["BillAddr2"].ToString();
                    _DataItem.BillAddr3          = (_DataReader["BillAddr3"] == DBNull.Value) ? string.Empty : _DataReader["BillAddr3"].ToString();
                    _DataItem.BillAddr4          = (_DataReader["BillAddr4"] == DBNull.Value) ? string.Empty : _DataReader["BillAddr4"].ToString();
                    _DataItem.BillAddr5          = (_DataReader["BillAddr5"] == DBNull.Value) ? string.Empty : _DataReader["BillAddr5"].ToString();
                    _DataItem.ShipAddr1          = (_DataReader["ShipAddr1"] == DBNull.Value) ? string.Empty : _DataReader["ShipAddr1"].ToString();
                    _DataItem.ShipAddr2          = (_DataReader["ShipAddr2"] == DBNull.Value) ? string.Empty : _DataReader["ShipAddr2"].ToString();
                    _DataItem.ShipAddr3          = (_DataReader["ShipAddr3"] == DBNull.Value) ? string.Empty : _DataReader["ShipAddr3"].ToString();
                    _DataItem.ShipAddr4          = (_DataReader["ShipAddr4"] == DBNull.Value) ? string.Empty : _DataReader["ShipAddr4"].ToString();
                    _DataItem.ShipAddr5          = (_DataReader["ShipAddr5"] == DBNull.Value) ? string.Empty : _DataReader["ShipAddr5"].ToString();
                    _DataItem.AccEmail           = (_DataReader["AccEmail"] == DBNull.Value) ? string.Empty : _DataReader["AccEmail"].ToString();
                    _DataItem.AltAccEmail        = (_DataReader["AltAccEmail"] == DBNull.Value) ? string.Empty : _DataReader["AltAccEmail"].ToString();
                    _DataItem.PaymentTermID      = (_DataReader["PaymentTermID"] == DBNull.Value) ? _DataItem.PaymentTermID : Convert.ToInt32(_DataReader["PaymentTermID"]);
                    _DataItem.Limit           = (_DataReader["Limit"] == DBNull.Value) ? 0.0 : Convert.ToDouble(_DataReader["Limit"]);
                    _DataItem.FullCoName      = (_DataReader["FullCoName"] == DBNull.Value) ? string.Empty : _DataReader["FullCoName"].ToString();
                    _DataItem.AccFirstName    = (_DataReader["AccFirstName"] == DBNull.Value) ? string.Empty : _DataReader["AccFirstName"].ToString();
                    _DataItem.AccLastName     = (_DataReader["AccLastName"] == DBNull.Value) ? string.Empty : _DataReader["AccLastName"].ToString();
                    _DataItem.AltAccFirstName = (_DataReader["AltAccFirstName"] == DBNull.Value) ? string.Empty : _DataReader["AltAccFirstName"].ToString();
                    _DataItem.AltAccLastName  = (_DataReader["AltAccLastName"] == DBNull.Value) ? string.Empty : _DataReader["AltAccLastName"].ToString();
                    _DataItem.PriceLevelID    = (_DataReader["PriceLevelID"] == DBNull.Value) ? _DataItem.PriceLevelID : Convert.ToInt32(_DataReader["PriceLevelID"]);
                    _DataItem.InvoiceTypeID   = (_DataReader["InvoiceTypeID"] == DBNull.Value) ? _DataItem.InvoiceTypeID : Convert.ToInt32(_DataReader["InvoiceTypeID"]);
                    _DataItem.RegNo           = (_DataReader["RegNo"] == DBNull.Value) ? string.Empty : _DataReader["RegNo"].ToString();
                    _DataItem.BankAccNo       = (_DataReader["BankAccNo"] == DBNull.Value) ? string.Empty : _DataReader["BankAccNo"].ToString();
                    _DataItem.BankBranch      = (_DataReader["BankBranch"] == DBNull.Value) ? string.Empty : _DataReader["BankBranch"].ToString();
                    _DataItem.Enabled         = (_DataReader["Enabled"] == DBNull.Value) ? true : Convert.ToBoolean(_DataReader["Enabled"]);
                    _DataItem.Notes           = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString();
                    #endregion
                }
                _DataReader.Close();
            }
            _TDB.Close();
            return(_DataItem);
        }
예제 #22
0
        public List <OrderDetailData> LoadOrderDetailData(Int64 CustomerId, DateTime DeliveryDate, String Notes, int MaximumRows, int StartRowIndex)
        {
            List <OrderDetailData> oDetails = new List <OrderDetailData>();
            TrackerDb _TDB    = new TrackerDb();
            string    _sqlCmd = "SELECT [ItemTypeID], [QuantityOrdered], [PackagingID], [OrderID] FROM [OrdersTbl] WHERE ";

            if (CustomerId == CustomersTbl.CONST_CUSTOMERID_GENERALOROTHER)
            {
                _sqlCmd += "([CustomerId] = " + CustomersTbl.CONST_STR_CUSTOMERID_GENERALOROTHER + ") AND ([RequiredByDate] = ?) AND ([Notes] = ?)";

                _TDB.AddWhereParams(DeliveryDate, DbType.Date, "@RequiredByDate");
                _TDB.AddWhereParams(Notes, DbType.String, "@Notes");
            }
            else
            {
                _sqlCmd += "([CustomerId] = ?) AND ([RequiredByDate] = ?)";
                _TDB.AddWhereParams(CustomerId, DbType.Int64, "@CustomerId");
                _TDB.AddWhereParams(DeliveryDate, DbType.Date, "@RequiredByDate");
            }
            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(_sqlCmd);

            if (_DataReader != null)
            {
                while (_DataReader.Read())
                {
                    OrderDetailData od = new OrderDetailData();

                    od.ItemTypeID      = (_DataReader["ItemTypeID"] == DBNull.Value) ? 0 : (Int32)_DataReader["ItemTypeID"];
                    od.PackagingID     = (_DataReader["PackagingID"] == DBNull.Value) ? 0 : (Int32)_DataReader["PackagingID"];
                    od.OrderID         = (Int32)_DataReader["OrderId"]; // this is the PK cannot be null
                    od.QuantityOrdered = (_DataReader["QuantityOrdered"] == DBNull.Value) ? 1 : Math.Round(Convert.ToDouble(_DataReader["QuantityOrdered"]), 2);

                    oDetails.Add(od);
                }
                _DataReader.Close();
            }
            _TDB.Close();

            return(oDetails);
        }
예제 #23
0
/*
 *    OleDbConnection _conn = new OleDbConnection(_connectionString);
 *
 *    // add parameters in the order they appear in the update command
 *    OleDbCommand _cmd = new OleDbCommand(_sqlCmd, _conn);
 *    // first summary data
 *    _cmd.Parameters.Add(new OleDbParameter { Value = CustomerID });
 *    _cmd.Parameters.Add(new OleDbParameter { Value = OrderDate });
 *    _cmd.Parameters.Add(new OleDbParameter { Value = RoastDate });
 *    _cmd.Parameters.Add(new OleDbParameter { Value = RequiredByDate });
 *    _cmd.Parameters.Add(new OleDbParameter { Value = ToBeDeliveredBy });
 *    _cmd.Parameters.Add(new OleDbParameter { Value = Confirmed });
 *    _cmd.Parameters.Add(new OleDbParameter { Value = Done });
 *    _cmd.Parameters.Add(new OleDbParameter { Value = Notes });
 *
 *    // Now line data
 *    _cmd.Parameters.Add(new OleDbParameter { Value = ItemTypeID });
 *    _cmd.Parameters.Add(new OleDbParameter { Value = Math.Round(QuantityOrdered,2) });
 *    _cmd.Parameters.Add(new OleDbParameter { Value = PackagingID });
 *
 *    try
 *    {
 *      _conn.Open();
 *      if (_cmd.ExecuteNonQuery() > 0)
 *        return false;
 *    }
 *    catch (OleDbException ex)
 *    {
 *      return ex.Message == "";        // Handle exception.
 *    }
 *    finally
 *    {
 *      _conn.Close();
 *    }
 *
 *    return true;
 *  }
 */
        public bool DeleteOrderDetails(string OrderID)
        {
            string    _sqlDeleteCmd = "DELETE FROM OrdersTbl WHERE (OrderID = ?)";
            bool      _Success      = false;
            TrackerDb _TDB          = new TrackerDb();

            _TDB.AddWhereParams(OrderID, DbType.String, "@OrderID");

            _Success = String.IsNullOrEmpty(_TDB.ExecuteNonQuerySQL(_sqlDeleteCmd));
            _TDB.Close();

            return(_Success);
        }
예제 #24
0
        protected void gvOrderLines_OnItemDelete(object sender, EventArgs e)
        {
            CommandEventArgs cea           = (CommandEventArgs)e;
            string           _OrderId      = cea.CommandArgument.ToString();
            string           _sqlDeleteCmd = "DELETE FROM OrdersTbl WHERE (OrderID = ?)";
            TrackerDb        _TDB          = new TrackerDb();

            _TDB.AddWhereParams(_OrderId, DbType.String, "@OrderID");
            string _ErrorStr = _TDB.ExecuteNonQuerySQL(_sqlDeleteCmd);

            _TDB.Close();
            ltrlStatus.Text = (string.IsNullOrEmpty(_ErrorStr) ? "Item Deleted" : "Error deleting item: " + _ErrorStr);
        }
예제 #25
0
        public static void UpdateTransaction(TransactionTypesTbl pTransactionType, int pOrignal_TransactionID)
        {
            TrackerDb _TDB = new TrackerDb();

            _TDB.AddParams(pTransactionType.TransactionType);
            _TDB.AddParams(pTransactionType.Notes);

            if (pOrignal_TransactionID > 0)
            {
                _TDB.AddWhereParams(pOrignal_TransactionID, DbType.Int32);
            }
            else
            {
                _TDB.AddWhereParams(pTransactionType.TransactionID, DbType.Int32);
            }

            string _Result = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATE);

            _TDB.Close();

            // return _Result;
        }
예제 #26
0
        public int ChangeItemIDToGroupIfItWas(long pContactID, int pItemID, DateTime pDeliveryDate)
        {
            TrackerDb _TDB = new TrackerDb();

            _TDB.AddWhereParams(pContactID, DbType.Int64, "@ContactID");
            _TDB.AddWhereParams(pItemID, DbType.Int32, "@LastItemTypeID");
            _TDB.AddWhereParams(pDeliveryDate, DbType.Date, "@LastItemDateChanged ");

            //"SELECT UsedItemGroupID, GroupItemTypeID, LastItemTypeSortPos, Notes FROM UsedItemGroupTbl WHERE ContactID = ? AND LastItemTypeID = ? AND LastItemDateChanged = ?";
            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(CONST_SELECTLASTUSEDITEMID);

            if (_DataReader != null)
            {
                if (_DataReader.Read())
                {
                    pItemID = (_DataReader["GroupItemTypeID"] == DBNull.Value) ? TrackerDb.CONST_INVALIDID : Convert.ToInt32(_DataReader["GroupItemTypeID"]);
                }
                _DataReader.Close();
            }
            _TDB.Close();

            return(pItemID);
        }
예제 #27
0
        public string UpdateContact(ContactType pContact)
        {
            string _Err = String.Empty;

            TrackerDb _TDB = new TrackerDb();

            _TDB.AddParams(pContact.CustomerTypeID, DbType.Int32);
            _TDB.AddParams(pContact.PredictionDisabled, DbType.Boolean);
            _TDB.AddWhereParams(pContact.CustomerID, DbType.Int64);
            // CONST_SQL_UPDATE

            _Err = _TDB.ExecuteNonQuerySQLWithParams(CONST_SQL_UPDATE, _TDB.Params, _TDB.WhereParams);
            _TDB.Close();
            return(_Err);
        }
예제 #28
0
        public List <OrderCheckData> GetSimilarItemInOrders(long pCustomerID, int pItemTypeID, DateTime pStartDate, DateTime pEndDate)
        {
            List <OrderCheckData> _DataItems = null;
            TrackerDb             _TDB       = new TrackerDb();

            ///
            _TDB.AddWhereParams(pCustomerID, DbType.Int64, "@CustomerID");
            _TDB.AddWhereParams(pStartDate, DbType.Date, "@RequiredStartDate");
            _TDB.AddWhereParams(pEndDate, DbType.Date, "@RequiredEndDate");
            _TDB.AddWhereParams(pItemTypeID, DbType.Int32, "@ItemTypeID");

            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(CONST_SELECT_ORDERITEMSWITHSAMESERVICETYPEEXISTS);

            if ((_DataReader != null))
            {
                while (_DataReader.Read())
                {
                    OrderCheckData _DataItem = new OrderCheckData();

                    _DataItem.OrderID        = (_DataReader["OrderID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["OrderID"]);
                    _DataItem.CustomerID     = (_DataReader["CustomerID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["CustomerID"]);
                    _DataItem.ItemTypeID     = (_DataReader["ItemTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ItemTypeID"]);
                    _DataItem.RequiredByDate = (_DataReader["RequiredByDate"] == DBNull.Value) ? System.DateTime.Now.Date : Convert.ToDateTime(_DataReader["RequiredByDate"]).Date;

                    if (_DataItems == null)
                    {
                        _DataItems = new List <OrderCheckData>();
                    }

                    _DataItems.Add(_DataItem);
                }
                _DataReader.Close();
            }
            _TDB.Close();
            return(_DataItems);
        }
예제 #29
0
        /// <summary>
        /// Get the item that is in sort pos passed
        /// </summary>
        /// <param name="pGroupItemTypeID">The group id</param>
        /// <param name="pSortPos">the post selected</param>
        /// <returns>the item id</returns>
        public int GetSortPosItemInGroup(int pGroupItemTypeID, int pSortPos)
        {
            int _ItemTypeID = TrackerDb.CONST_INVALIDID;

            TrackerDb _TDB = new TrackerDb();

            _TDB.AddWhereParams(pGroupItemTypeID, DbType.Int32, "GroupItemTypeID");
            _TDB.AddWhereParams(pSortPos, DbType.Int32, "ItemTypeSortPos");

            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(CONST_SELECT_SORTPOSINGROUP); // "SELECT ItemTypeID, ItemTypeSortPos FROM ItemGroupTbl WHERE (GroupItemTypeID = ?) AND (ItemTypeSortPos = ?)";

            if (_DataReader != null)
            {
                if (_DataReader.Read())
                {
                    _ItemTypeID = (_DataReader["ItemTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ItemTypeID"]);
                }

                _DataReader.Close();
            }
            _TDB.Close();

            return(_ItemTypeID);
        }
예제 #30
0
        public RepairsTbl GetRepairById(int pRepairID)
        {
            RepairsTbl _DataItem = null;

            if (pRepairID > 0)
            {
                TrackerDb _TrackerDb = new TrackerDb();
                // params would go here if need
                _TrackerDb.AddWhereParams(pRepairID, DbType.Int32);
                IDataReader _DataReader = _TrackerDb.ExecuteSQLGetDataReader(CONST_SQL_SELECTBYREPAIRID);

                if (_DataReader != null)
                {
                    if (_DataReader.Read())
                    {
                        _DataItem = new RepairsTbl();

                        _DataItem.RepairID            = pRepairID;
                        _DataItem.CustomerID          = (_DataReader["CustomerID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["CustomerID"]);
                        _DataItem.ContactName         = (_DataReader["ContactName"] == DBNull.Value) ? string.Empty : _DataReader["ContactName"].ToString();
                        _DataItem.ContactEmail        = (_DataReader["ContactEmail"] == DBNull.Value) ? string.Empty : _DataReader["ContactEmail"].ToString();
                        _DataItem.JobCardNumber       = (_DataReader["JobCardNumber"] == DBNull.Value) ? string.Empty : _DataReader["JobCardNumber"].ToString();
                        _DataItem.DateLogged          = (_DataReader["DateLogged"] == DBNull.Value) ? System.DateTime.Now.Date : Convert.ToDateTime(_DataReader["DateLogged"]).Date;
                        _DataItem.LastStatusChange    = (_DataReader["LastStatusChange"] == DBNull.Value) ? System.DateTime.Now.Date : Convert.ToDateTime(_DataReader["LastStatusChange"]).Date;
                        _DataItem.MachineTypeID       = (_DataReader["MachineTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["MachineTypeID"]);
                        _DataItem.MachineSerialNumber = (_DataReader["MachineSerialNumber"] == DBNull.Value) ? string.Empty : _DataReader["MachineSerialNumber"].ToString();
                        _DataItem.SwopOutMachineID    = (_DataReader["SwopOutMachineID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["SwopOutMachineID"]);
                        _DataItem.MachineConditionID  = (_DataReader["MachineConditionID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["MachineConditionID"]);
                        _DataItem.TakenFrother        = (_DataReader["TakenFrother"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TakenFrother"]);
                        _DataItem.TakenBeanLid        = (_DataReader["TakenBeanLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TakenBeanLid"]);
                        _DataItem.TakenWaterLid       = (_DataReader["TakenWaterLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TakenWaterLid"]);
                        _DataItem.BrokenFrother       = (_DataReader["BrokenFrother"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["BrokenFrother"]);
                        _DataItem.BrokenBeanLid       = (_DataReader["BrokenBeanLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["BrokenBeanLid"]);
                        _DataItem.BrokenWaterLid      = (_DataReader["BrokenWaterLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["BrokenWaterLid"]);
                        _DataItem.RepairFaultID       = (_DataReader["RepairFaultID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["RepairFaultID"]);
                        _DataItem.RepairFaultDesc     = (_DataReader["RepairFaultDesc"] == DBNull.Value) ? string.Empty : _DataReader["RepairFaultDesc"].ToString();
                        _DataItem.RepairStatusID      = (_DataReader["RepairStatusID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["RepairStatusID"]);
                        _DataItem.RelatedOrderID      = (_DataReader["RelatedOrderID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["RelatedOrderID"]);
                        _DataItem.Notes = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString();
                    }
                    _DataReader.Close();
                }
                _TrackerDb.Close();
            }
            return(_DataItem);
        }