Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string        mainconn = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            SqlConnection sqlconn  = new SqlConnection(mainconn);

            sqlconn.Open();
            SqlCommand sqlcomm  = new SqlCommand();
            string     sqlquery = "Select [UzimaInventory].[Id], [DrugName], [Status], [LocationName], [DateOrdered], [ExpirationDate] " +
                                  "From[UzimaDrug], [UzimaInventory], [UzimaStatus], [UzimaLocations] " +
                                  "Where[UzimaDrug].[Id] = [UzimaInventory].[DrugId] AND[UzimaStatus].[Id] = [UzimaInventory].[StatusId] AND [UzimaInventory].[CurrentLocationId] = [UzimaLocations].[Id] AND [StatusID] = 0";

            sqlcomm.CommandText = sqlquery;
            sqlcomm.Connection  = sqlconn;
            DataTable      dt  = new DataTable();
            SqlDataAdapter sda = new SqlDataAdapter(sqlcomm);

            sda.Fill(dt);
            InventoryGridview.DataSource = dt;
            InventoryGridview.DataBind();
        }
Example #2
0
        protected void DownloadInventory_Click(object sender, EventArgs e)
        {
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=Inventory.pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            InventoryGridview.RenderControl(hw);
            StringReader sr     = new StringReader(sw.ToString());
            Document     pdfdoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
            PdfWriter    writer = PdfWriter.GetInstance(pdfdoc, Response.OutputStream);

            pdfdoc.Open();
            XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfdoc, sr);
            pdfdoc.Close();
            Response.Write(pdfdoc);
            Response.End();
            InventoryGridview.AllowPaging = true;
            InventoryGridview.DataBind();
        }
Example #3
0
        protected void InventoryGridview_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            InventoryGridview.PageIndex = e.NewPageIndex;
            string        mainconn = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            SqlConnection sqlconn  = new SqlConnection(mainconn);

            sqlconn.Open();
            SqlCommand sqlcomm  = new SqlCommand();
            string     sqlquery = "Select [DrugName], [Status], [LocationName], [DateOrdered], [ExpirationDate], [UzimaInventory].[Id]" +
                                  "From[UzimaDrug], [UzimaInventory], [UzimaStatus], [UzimaLocations] " +
                                  "Where[UzimaDrug].[Id] = [UzimaInventory].[DrugId] AND[UzimaStatus].[Id] = [UzimaInventory].[StatusId] AND[UzimaInventory].[CurrentLocationId] = [UzimaLocations].[Id] AND [StatusID] = 0";

            sqlcomm.Parameters.AddWithValue("DrugName", InventorySearch.Text);
            sqlcomm.CommandText = sqlquery;
            sqlcomm.Connection  = sqlconn;
            DataTable      dt  = new DataTable();
            SqlDataAdapter sda = new SqlDataAdapter(sqlcomm);

            sda.Fill(dt);
            InventoryGridview.DataSource = dt;
            InventoryGridview.DataBind();
        }
Example #4
0
        private void BindInventoryGrid()
        {
            string sqlQuery;

            if (Site1.UserLoginType == "Admin")
            {
                sqlQuery = "Select * from DonationInventory where ArticleSold IS NULL;";
            }
            else if (Site1.UserLoginType == null)
            {
                sqlQuery = "Select * from DonationInventory where ArticleSold IS NULL;";
            }
            else
            {
                sqlQuery = "Select * from DonationInventory where ArticleLocationID = '" + Site1.UserLoginLocation + "' and ArticleSold IS NULL;";
            }

            string constr = ConfigurationManager.ConnectionStrings["CARESconnection"].ConnectionString;

            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand(sqlQuery))
                {
                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        cmd.Connection    = con;
                        sda.SelectCommand = cmd;
                        using (DataTable dt = new DataTable())
                        {
                            sda.Fill(dt);
                            InventoryGridview.DataSource = dt;
                            InventoryGridview.DataBind();
                        }
                    }
                }
            }
        }