コード例 #1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            SqlConnection  con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\my project\drugs control board\day14\Dcsd-ka-171\New folder\database\drugsControlBoard.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
            SqlDataAdapter sda = new SqlDataAdapter("Select Type from Login where UserName='******'and PassWord='******'", con);
            DataTable      dt  = new System.Data.DataTable();

            sda.Fill(dt);

            if (dt.Rows.Count == 1)
            {
                string b1;

                b1 = dt.Rows[0][0].ToString();

                if (b1 == "maneger")
                {
                    value = 1;
                }
                else if (b1 == "counsiler")
                {
                    value = 2;
                }
                else if (b1 == "Data Entry")
                {
                    value = 3;
                }
                else
                {
                    value = 4;
                }


                Home b = new Home(bh, type, value);
                b.ShowDialog();
                this.Hide();
            }
            else
            {
                label3.Text = "Wrong UserName Password";
            }
        }
コード例 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            SaveFileDialog s = new SaveFileDialog();

            s.Filter = "png files(*.png)|*.png|jpg files(*.jpg)|*.jpg|All files(*.*)|*.* ";
            string newguid = "p" + DateTime.Now.ToString("hhmmss");



            pictureBox2.Image.Save("E:\\New folder\\day14\\New folder\\client photos\\" + newguid + ".png");

            string path = "E:\\New folder\\day14\\New folder\\client photos\\" + newguid + ".png";


            MessageBox.Show(" save completed");


            if (pictureBox2.Image != null)
            {
                if (videoSource.IsRunning == true)
                {
                    videoSource.Stop();
                    this.Close();
                }

                this.Close();



                Home r = new Home(path, type, type34);

                r.ShowDialog();
            }
            else
            {
                label2.Text = "First take a Photo";
            }
        }
コード例 #3
0
        private void btnempreg_Click(object sender, EventArgs e)
        {
            if (txtclientName.Text == "" || txtcnic.Text == "" || txtcaddrees.Text == "" || txtcphone.Text == "" || rdoMale.Checked == false && rdoFemale.Checked == false || cmbcdrug.Text == "" || cmbccounciller.Text == "" || txtcjob.Text == "" || txtcguardian.Text == "" || rdopayment.Checked == false && rdonunpayment.Checked == false)
            {
                MessageBox.Show("Please check the form again");

                if (txtclientName.Text == "")
                {
                    pnlfullname.Show();
                }
                if (txtcnic.Text == "")
                {
                    pnlcNic.Show();
                }
                if (txtcaddrees.Text == "")
                {
                    pnlcaddress.Show();
                }
                if (txtcphone.Text == "")
                {
                    pnlcPhone.Show();
                }
                if (rdoMale.Checked == false && rdoFemale.Checked == false)
                {
                    pnlcGender.Show();
                }
                if (cmbcdrug.Text == "")
                {
                    pnlcDrug.Show();
                }
                if (cmbccounciller.Text == "")
                {
                    pnlccounciller.Show();
                }
                if (txtcjob.Text == "")
                {
                    pnlcJob.Show();
                }
                if (txtcguardian.Text == "")
                {
                    pnlcGuardian.Show();
                }
                if (rdopayment.Checked == false && rdonunpayment.Checked == false)
                {
                    pnlrdopaymentorNon.Show();
                }
            }
            else
            {
                if (rdopayment.Checked == true || rdonunpayment.Checked == true)
                {
                    if (rdopayment.Checked == true)
                    {
                        clienttotal = "15000";

                        if (txtcpayment.Text == "")
                        {
                            MessageBox.Show("please check the form again");

                            pnlcPay.Show();
                        }
                        else
                        {
                            SqlDataAdapter adt = new SqlDataAdapter("select count(*) from ClientRegistation where NIC='" + txtcnic.Text + "'", con);
                            DataTable      dt  = new DataTable();
                            adt.Fill(dt);

                            if (dt.Rows[0][0].ToString() == "1")
                            {
                                MessageBox.Show("Already complete the Registation");
                            }


                            else
                            {
                                byte[] im = null;

                                FileStream   streem = new FileStream(imagelocation3, FileMode.Open, FileAccess.Read);
                                BinaryReader brs    = new BinaryReader(streem);
                                im = brs.ReadBytes((int)streem.Length);


                                con.Open();

                                SqlCommand cmd = new SqlCommand("INSERT INTO ClientRegistation(ClientID,FullName,Address,NIC,PhoneNumber,Birthday,Gender,MainDrug,Counciller,Job,GuardianName,JoinDate,PaymentOrNot,Total,Payment,DischargeDate,ClientPhoto)VALUES('" + clientId + "','" + txtclientName.Text + "','" + txtcaddrees.Text + "','" + txtcnic.Text + "','" + txtcphone.Text + "','" + dtpcbirth.Text + "','" + Gender + "','" + cmbcdrug.Text + "','" + cmbccounciller.Text + "','" + txtcjob.Text + "','" + txtcguardian.Text + "','" + Jdate + "','" + paymentNot + "','" + clienttotal + "','" + txtcpayment.Text + "','" + discharge + "',@im)", con);



                                cmd.Parameters.Add(new SqlParameter("@im", im));
                                cmd.ExecuteNonQuery();
                                con.Close();

                                MessageBox.Show("Save completed");

                                selectClient();

                                this.Close();

                                Home r = new Home(para, para2, typerec);

                                r.ShowDialog();
                            }
                        }
                    }
                    if (rdonunpayment.Checked == true)
                    {
                        clienttotal = "0";
                        SqlDataAdapter adt2 = new SqlDataAdapter("select count(*) from ClientRegistation where NIC='" + txtcnic.Text + "'", con);
                        DataTable      dt2  = new DataTable();
                        adt2.Fill(dt2);

                        if (dt2.Rows[0][0].ToString() == "1")
                        {
                            MessageBox.Show("Already complete the Registation");
                        }

                        else
                        {
                            byte[] img = null;

                            FileStream   streem = new FileStream(imagelocation3, FileMode.Open, FileAccess.Read);
                            BinaryReader brs    = new BinaryReader(streem);
                            img = brs.ReadBytes((int)streem.Length);


                            con.Open();

                            SqlCommand cmd = new SqlCommand("INSERT INTO ClientRegistation(ClientID,FullName,Address,NIC,PhoneNumber,Birthday,Gender,MainDrug,Counciller,Job,GuardianName,JoinDate,PaymentOrNot,Total,Payment,DischargeDate,ClientPhoto)VALUES('" + clientId + "','" + txtclientName.Text + "','" + txtcaddrees.Text + "','" + txtcnic.Text + "','" + txtcphone.Text + "','" + dtpcbirth.Text + "','" + Gender + "','" + cmbcdrug.Text + "','" + cmbccounciller.Text + "','" + txtcjob.Text + "','" + txtcguardian.Text + "','" + Jdate + "','" + paymentNot + "','" + clienttotal + "','" + txtcpayment.Text + "','" + discharge + "',@img)", con);



                            cmd.Parameters.Add(new SqlParameter("@img", img));
                            cmd.ExecuteNonQuery();
                            con.Close();

                            MessageBox.Show("Save completed");

                            selectClient();

                            this.Close();

                            Home r = new Home(para, para2, typerec);

                            r.ShowDialog();
                        }
                    }
                }
            }
        }