예제 #1
0
        // Gets


        public List <WarshaOffersCriteria> GetOffersByWarsha_id(int warsha_id, Enums.OfferType offerType)
        {
            OfferQuery offerQuery = new OfferQuery(language);

            System.Data.DataTable dataTable = new System.Data.DataTable();

            if (offerType == Enums.OfferType.offerNotAccepted)
            {
                dataTable = conn_db.ReadTable(offerQuery.GetWorkshopOfferNotAccespted(warsha_id));
            }
            else if (offerType == Enums.OfferType.offerAccepted)
            {
                dataTable = conn_db.ReadTable(offerQuery.GetWorkshopOfferAccespted(warsha_id));
            }
            else if (offerType == Enums.OfferType.offerIsFixing)
            {
                dataTable = conn_db.ReadTable(offerQuery.GetWorkshopOfferIsFixing(warsha_id));
            }
            else if (offerType == Enums.OfferType.offerFinishFixing)
            {
                dataTable = conn_db.ReadTable(offerQuery.GetWorkshopOfferFinishFixing(warsha_id));
            }

            if (dataTable.Rows.Count == 0)
            {
                throw new EmptyViewException(language);
            }


            WarshaOffersCriteria        warshaOffersCriteria  = new WarshaOffersCriteria();
            List <WarshaOffersCriteria> warshaOffersCriterias = new List <WarshaOffersCriteria>();

            foreach (System.Data.DataRow row in dataTable.Rows)
            {
                warshaOffersCriteria             = new WarshaOffersCriteria();
                warshaOffersCriteria.offer_id    = Convert.ToInt32(row["OFFER_ID"].ToString());
                warshaOffersCriteria.workshop_id = Convert.ToInt32(row["WORKSHOP_ID"].ToString());
                warshaOffersCriteria.accident_Id = Convert.ToInt32(row["accidentId"].ToString());
                warshaOffersCriteria.Price       = row["PRICE"].ToString();
                try { warshaOffersCriteria.timeValue = Convert.ToInt32(row["timeValue"]); } catch (Exception ex) { warshaOffersCriteria.timeValue = 0; }
                try { warshaOffersCriteria.timeFlag = Convert.ToInt32(row["timeFlag"]); } catch (Exception ex) { warshaOffersCriteria.timeFlag = 0; }
                try { warshaOffersCriteria.offerDateTime = Convert.ToDateTime(row["offer_DateTime"].ToString()).ToString("dd-MM-yyyy"); }
                catch { warshaOffersCriteria.offerDateTime = "01-01-2000"; }


                //IMPORTANT
                //if(offerType == Enums.OfferType.offerIsFixing)
                //{
                //    DateTime fixingStartDate =  Convert.ToDateTime(row["WAITINGFIX_DATETIME"].ToString()).AddDays( Convert.ToInt32(warshaOffersCriteria.workDays+1) );
                //    DateTime Nowaday = DateTime.Now ;
                //    TimeSpan noOfDays = fixingStartDate -Nowaday ;
                //    if(noOfDays.Days<0)
                //    {
                //        warshaOffersCriteria.workDays = 0;
                //    }
                //    else
                //    {
                //        DateTime age = DateTime.MinValue + noOfDays;
                //        int days = age.Day - 1;
                //        warshaOffersCriteria.workDays = days;
                //    }

                //}


                warshaOffersCriteria.plateNumber  = row["plateNumber"].ToString();
                warshaOffersCriteria.Status       = Convert.ToInt32(row["Status"].ToString());
                warshaOffersCriteria.statusNameEn = row["STATUS_NAME_EN"].ToString();
                warshaOffersCriteria.statusNameAr = row["STATUS_NAME_AR"].ToString();


                warshaOffersCriterias.Add(warshaOffersCriteria);
            }
            return(warshaOffersCriterias);
        }