Beispiel #1
0
        public static Repairs GetOutstandingRepairs(int EstateID)
        {
            string q = "select core.Repairs.ID, core.Repairs.ReportID, core.Repairs.RepairTitle, " +
                       "core.Repairs.RepairDetails, core.Repairs.RaisedDate, " +
                       "core.Repairs.TargetCompletionDate,  core.RepairStatus.RepairStatus " +
                       "from core.Repairs inner join core.RepairStatus on core.Repairs.RepairStatusID " +
                       "= core.RepairStatus.id where core.repairs.EstateID = " + EstateID.ToString() +
                       " and  core.Repairs.RepairStatusId = 1 " +
                       " order by core.repairs.raisedDate Asc";

            DBConnectionObject db = GlobalVariables.GetConnection();

            DataTable dt      = db.Connection.GetDataTable(q);
            Repairs   repairs = new Repairs();

            repairs.AllRepairs = new List <Repairs>();

            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                if (row[0].ToString() != "Error")
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        //raised date
                        DateTime raised = new DateTime();
                        if (dr[4] != DBNull.Value)
                        {
                            raised = Convert.ToDateTime(dr[4]);
                        }

                        //Target Completion
                        DateTime target = new DateTime();
                        if (dr[5] != DBNull.Value)
                        {
                            target = Convert.ToDateTime(dr[5]);
                        }


                        repairs.AllRepairs.Add(new Repairs {
                            ID            = Convert.ToInt32(dr[0]),
                            Title         = dr[2].ToString(),
                            Details       = dr[3].ToString(),
                            RaisedDate    = raised,
                            RaisedDatestr = Controls.DateString(raised),
                            TargetDate    = target,
                            TargetDatestr = Controls.DateString(target),
                            Status        = dr[6].ToString()
                        });
                    }
                }
            }

            return(repairs);
        }
Beispiel #2
0
        public static Repairs GetAllRepairDetails(int repairID)
        {
            string q = "select core.Repairs.RepairTitle, core.Repairs.RepairDetails, " +
                       "core.Repairs.RaisedDate, core.Repairs.TargetCompletionDate, " +
                       "core.Repairs.ScheduleName, core.Repairs.QupteID, core.RepairStatus.RepairStatus, " +
                       "core.Repairs.HeadAssetID, core.Repairs.SubAssetID, " +
                       "core.PurchaseOrders.EstCost, core.PurchaseOrders.ID from core.Repairs inner join core.RepairStatus on " +
                       "core.Repairs.RepairStatusID = core.RepairStatus.id " +
                       "inner join core.PurchaseOrders on " +
                       "core.Repairs.PONumber = core.PurchaseOrders.id where core.Repairs.ID = " + repairID.ToString();


            DBConnectionObject db = GlobalVariables.GetConnection();
            DataTable          dt = db.Connection.GetDataTable(q);
            Repairs            c  = new Repairs();

            if (dt.Rows.Count > 0)
            {
                DataRow d = dt.Rows[0];
                if (d[0].ToString() != "Error")
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        //raised date
                        DateTime raised = new DateTime();
                        if (dr[2] != DBNull.Value)
                        {
                            raised = Convert.ToDateTime(dr[2]);
                        }

                        //Target Completion
                        DateTime target = new DateTime();
                        if (dr[3] != DBNull.Value)
                        {
                            target = Convert.ToDateTime(dr[3]);
                        }

                        //Estiated Cost
                        double est = 0;
                        if (dr[9] != DBNull.Value)
                        {
                            est = Convert.ToDouble(dr[9]);
                        }
                        string eststr = Controls.CurrencyString(est);

                        //po number
                        int po = 0;
                        if (dr[10] != DBNull.Value)
                        {
                            po = Convert.ToInt32(dr[10]);
                        }

                        Repairs r = new Repairs
                        {
                            Title            = dr[0].ToString(),
                            Details          = dr[1].ToString(),
                            RaisedDate       = raised,
                            RaisedDatestr    = Controls.DateString(raised),
                            TargetDate       = target,
                            TargetDatestr    = Controls.DateString(target),
                            Status           = dr[6].ToString(),
                            EstimatedCostStr = eststr,
                            HeadAssetID      = Convert.ToInt32(dr[7]),
                            SubAssetID       = Convert.ToInt32(dr[8]),
                            PONumber         = po
                        };
                        c = r;
                    }

                    //Get Asset Details
                    if (c.HeadAssetID != 0)
                    {
                        q = "Select AssetName, AssetLocation from core.headassets where id = " + c.HeadAssetID.ToString();

                        DataTable dt1 = db.Connection.GetDataTable(q);
                        if (dt1.Rows.Count > 0)
                        {
                            if (dt1.Rows[0][0] != DBNull.Value || dt1.Rows[0][0].ToString() != "Error")
                            {
                                c.HeadAssetName     = dt1.Rows[0][0].ToString();
                                c.HeadAssetLocation = dt1.Rows[0][1].ToString();
                            }
                        }
                    }


                    if (c.SubAssetID != 0)
                    {
                        q = "Select AssetName, AssetLocation from core.subassets where id = " + c.SubAssetID.ToString();

                        DataTable dt1 = db.Connection.GetDataTable(q);
                        if (dt1.Rows.Count > 0)
                        {
                            if (dt1.Rows[0][0] != DBNull.Value || dt1.Rows[0][0].ToString() != "Error")
                            {
                                c.SubAssetName     = dt1.Rows[0][0].ToString();
                                c.SubAssetLocation = dt1.Rows[0][1].ToString();
                            }
                        }
                    }

                    //sets head asset location to null if sub asset location present.
                    //view only needs one of the asset locations to be visible.
                    if (c.SubAssetLocation != null && c.SubAssetLocation != "")
                    {
                        c.HeadAssetLocation = null;
                    }
                }
            }

            //if quote id is not 0 get quote details


            return(c);
        }