Пример #1
0
        public List <TenderNoticeModel> findTenders(string columnName, string value)
        {
            DbConnection.Open();
            MySqlCommand command = DbConnection.CreateCommand();

            command.CommandText = "select * from fieldlist natural join tendernotice WHERE " + columnName + "=@value order by SubDateTime";
            command.Parameters.AddWithValue("@value", value);
            MySqlDataReader          reader     = command.ExecuteReader();
            List <TenderNoticeModel> tenderList = new List <TenderNoticeModel>();

            while (reader.Read())
            {
                TenderNoticeModel tender = new TenderNoticeModel();
                tender.ExpDateTime = reader.GetDateTime("expdatetime");
                TimeSpan differnce = tender.ExpDateTime - DateTime.Now;
                if (Convert.ToDecimal(differnce.TotalMinutes) < 1)
                {
                    continue;
                }
                tender.FieldName    = reader.GetString("fieldname");
                tender.NoticeId     = reader.GetInt32("noticeId");
                tender.SubDateTime  = reader.GetDateTime("SubDateTime");
                tender.Organization = reader.GetString("organization");
                tenderList.Add(tender);
            }
            DbConnection.Close();
            return(tenderList);
        }
Пример #2
0
        public ActionResult CreateNewTender()
        {
            if (Session["isOrg"] != null)   //  if not in a session
            {
                if ((bool)Session["isOrg"]) //  If Organization session
                {
                    if (Request.HttpMethod.Equals("POST"))  //  create new tender by organization
                    {
                        TenderNoticeModel tenderModel = new TenderNoticeModel();
                        tenderModel.Organization = (String)Session["username"];
                        tenderModel.FieldName = Request.Form["select"];
                        tenderModel.ExpDateTime = Convert.ToDateTime(Request.Form["dateTime"]); //  expiring date
                        tenderModel.SubDateTime = DateTime.Now;
                        HttpPostedFileBase file = Request.Files["PDF"];     //  upload PDF

                        if (file != null && file.ContentLength > 0)
                        {
                            System.IO.Stream fileStream = file.InputStream;
                            byte[] data = new byte[file.ContentLength];
                            fileStream.Read(data, 0, data.Length);
                            fileStream.Close();
                            tenderModel.PdfDoc = data;
                        }
                        DBContext.GetInstance().createTenderNotice(tenderModel);    // create db entry
                    }
                    return View();
                }
            }
            return null;  // fo nothing if not in a session
        }
Пример #3
0
        public void createTenderNotice(TenderNoticeModel model)
        {
            DbConnection.Open();
            MySqlCommand command = DbConnection.CreateCommand();

            command.CommandText = "INSERT INTO tenderNotice (pdfDoc,organization,expdatetime,fieldname,subdatetime) values(@pdfDoc,@organization,@expdatetime,@fieldname,@subdatetime)";
            command.Parameters.AddWithValue("@pdfDoc", model.PdfDoc);
            command.Parameters.AddWithValue("@organization", model.Organization);
            command.Parameters.AddWithValue("@expdatetime", model.ExpDateTime);
            command.Parameters.AddWithValue("@fieldname", model.FieldName);
            command.Parameters.AddWithValue("@subdatetime", model.SubDateTime);
            command.ExecuteNonQuery();
            DbConnection.Close();
        }
Пример #4
0
        public List <TenderNoticeModel> findTendersOfOrg(string columnName, string value)
        {
            DbConnection.Open();
            MySqlCommand command = DbConnection.CreateCommand();

            command.CommandText = "select * from tendernotice WHERE " + columnName + "=@value order by SubDateTime desc";
            command.Parameters.AddWithValue("@value", value);
            MySqlDataReader          reader     = null;
            List <TenderNoticeModel> tenderList = new List <TenderNoticeModel>();

            try
            {
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    TenderNoticeModel tender = new TenderNoticeModel();
                    tender.ExpDateTime = reader.GetDateTime("expdatetime");
                    TimeSpan differnce = tender.ExpDateTime - DateTime.Now;
                    tender.FieldName    = reader.GetString("fieldname");
                    tender.NoticeId     = reader.GetInt32("noticeId");
                    tender.SubDateTime  = reader.GetDateTime("SubDateTime");
                    tender.Organization = reader.GetString("organization");
                    try
                    {
                        tender.AcceptedBidder   = reader.GetString("acceptedbidder");
                        tender.AcceptanceNotice = reader.GetString("acceptancenotice");
                    }
                    catch
                    {
                        tender.AcceptedBidder   = "";
                        tender.AcceptanceNotice = "";
                    }
                    tenderList.Add(tender);
                }
            }
            catch { }
            DbConnection.Close();
            return(tenderList);
        }
Пример #5
0
 public List<TenderNoticeModel> findTendersOfOrg(string columnName, string value)
 {
     DbConnection.Open();
     MySqlCommand command = DbConnection.CreateCommand();
     command.CommandText = "select * from tendernotice WHERE " + columnName + "=@value order by SubDateTime desc";
     command.Parameters.AddWithValue("@value", value);
     MySqlDataReader reader =null;
     List<TenderNoticeModel> tenderList = new List<TenderNoticeModel>();
     try
     {
         reader = command.ExecuteReader();
         while (reader.Read())
         {
             TenderNoticeModel tender = new TenderNoticeModel();
             tender.ExpDateTime = reader.GetDateTime("expdatetime");
             TimeSpan differnce = tender.ExpDateTime - DateTime.Now;
             tender.FieldName = reader.GetString("fieldname");
             tender.NoticeId = reader.GetInt32("noticeId");
             tender.SubDateTime = reader.GetDateTime("SubDateTime");
             tender.Organization = reader.GetString("organization");
             try
             {
                 tender.AcceptedBidder = reader.GetString("acceptedbidder");
                 tender.AcceptanceNotice = reader.GetString("acceptancenotice");
             }
             catch
             {
                 tender.AcceptedBidder = "";
                 tender.AcceptanceNotice = "";
             }
             tenderList.Add(tender);
         }
     }
     catch { }
     DbConnection.Close();
     return tenderList;
 }
Пример #6
0
 public List<TenderNoticeModel> findTenders(string columnName, string value)
 {
     DbConnection.Open();
     MySqlCommand command = DbConnection.CreateCommand();
     command.CommandText = "select * from fieldlist natural join tendernotice WHERE " + columnName + "=@value order by SubDateTime";
     command.Parameters.AddWithValue("@value", value);
     MySqlDataReader reader = command.ExecuteReader();
     List<TenderNoticeModel> tenderList = new List<TenderNoticeModel>();
     while (reader.Read())
     {
         TenderNoticeModel tender = new TenderNoticeModel();
         tender.ExpDateTime = reader.GetDateTime("expdatetime");
         TimeSpan differnce = tender.ExpDateTime - DateTime.Now;
         if (Convert.ToDecimal(differnce.TotalMinutes) < 1) { continue; }
         tender.FieldName = reader.GetString("fieldname");
         tender.NoticeId = reader.GetInt32("noticeId");
         tender.SubDateTime = reader.GetDateTime("SubDateTime");
         tender.Organization = reader.GetString("organization");
         tenderList.Add(tender);
     }
     DbConnection.Close();
     return tenderList;
 }
Пример #7
0
 public void createTenderNotice(TenderNoticeModel model)
 {
     DbConnection.Open();
     MySqlCommand command = DbConnection.CreateCommand();
     command.CommandText = "INSERT INTO tenderNotice (pdfDoc,organization,expdatetime,fieldname,subdatetime) values(@pdfDoc,@organization,@expdatetime,@fieldname,@subdatetime)";
     command.Parameters.AddWithValue("@pdfDoc", model.PdfDoc);
     command.Parameters.AddWithValue("@organization", model.Organization);
     command.Parameters.AddWithValue("@expdatetime", model.ExpDateTime);
     command.Parameters.AddWithValue("@fieldname", model.FieldName);
     command.Parameters.AddWithValue("@subdatetime", model.SubDateTime);
     command.ExecuteNonQuery();
     DbConnection.Close();
 }