Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            BloodDataContext D = new BloodDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=G:\Blood\Blood Donation\Blood.mdf;Integrated Security=True;Connect Timeout=30");

            GuestInfo pr = new GuestInfo();

            if (textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "")
            {
                pr.GName    = textBox2.Text;
                pr.GPhone   = textBox3.Text;
                pr.GAddress = textBox4.Text;
                D.GuestInfos.InsertOnSubmit(pr);
                D.SubmitChanges();

                RequestInfo rq = new RequestInfo();
                rq.DonorId = did;
                rq.Gphone  = textBox3.Text;

                var x = from a in D.GuestInfos
                        where a.GPhone.Equals(textBox3.Text)
                        select a;
                int str = x.First().Gid;

                rq.Gid = str;

                D.RequestInfos.InsertOnSubmit(rq);
                D.SubmitChanges();

                MessageBox.Show("Request Send");

                allrequest req = new allrequest();
                req.Donorid = did;
                req.Name    = textBox2.Text;
                req.Phone   = textBox3.Text;
                req.Address = textBox4.Text;

                var p = from a in D.RequestInfos
                        where a.Gphone.Equals(textBox3.Text)
                        select a;

                int stra = p.First().RequestId;

                req.requestid = stra;
                req.identity  = "Guest";

                D.allrequests.InsertOnSubmit(req);
                D.SubmitChanges();

                this.Hide();
            }
            else
            {
                MessageBox.Show("Please fill up all information");
            }
        }
Beispiel #2
0
        private void metroButton4_Click(object sender, EventArgs e)                      ///send request donor to donor
        {
            BloodDataContext D = new BloodDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=G:\Blood\Blood Donation\Blood.mdf;Integrated Security=True;Connect Timeout=30");
            int rowIndex       = metroGrid2.CurrentCell.RowIndex;

            int did = Convert.ToInt32(metroGrid2.Rows[rowIndex].Cells[0].Value);

            R rq = new R();

            rq.DonorId  = did;
            rq.Did      = m;
            rq.Phone    = metroLabel11.Text;
            rq.Identity = "Donor";

            D.Rs.InsertOnSubmit(rq);
            D.SubmitChanges();

            allrequest req = new allrequest();

            req.Donorid  = did;
            req.Name     = metroLabel4.Text;
            req.Phone    = metroLabel11.Text;
            req.Address  = metroLabel9.Text;
            req.identity = "Donor";

            var p = from a in D.Rs
                    where a.Did.Equals(m)
                    select a;

            int stra = p.First().Rid;

            req.Rid      = stra;
            req.identity = "Donor";

            D.allrequests.InsertOnSubmit(req);
            D.SubmitChanges();

            //var x = from a in D.RequestInfos
            //        where a.Gid == did
            //        select a;
            //x.First().Status = "Donated";

            //var y = from a in D.DonorInfos
            //        where a.DonorId == m
            //        select a;
            //y.First().Status = "Donated";
            //D.RequestInfos.InsertOnSubmit(rq);
            MessageBox.Show("Request Send");
            D.SubmitChanges();
        }