Esempio n. 1
0
        private void memberToolStripMenuItem_Click(object sender, EventArgs e)
        {
            loadcr._read = false;
            FAddMember fadd = new FAddMember();

            fadd.ShowDialog();
            loadcr._read = true;
        }
Esempio n. 2
0
        public void loaddsRound()
        {
            FMain fm = new FMain();

            rmess = false;
            loadmMember();
            loadrRound();
            loadsetting();

            try
            {
                loaddb.checkdb();
                int          incm  = 0;
                string       strmc = "SELECT COUNT(*) FROM DBMember WHERE IDCard= '" + cIDCard + "'";
                OleDbCommand cmdmc = new OleDbCommand(strmc, loaddb.cnn);
                incm = Convert.ToInt32(cmdmc.ExecuteScalar());
                if (incm > 0)
                {
                    loaddb.checkdb();
                    int          incr  = 0;
                    string       strrc = "SELECT COUNT(*) FROM DBRunRound WHERE IDCard= '" + cIDCard + "' AND [RTime]= '" + cTime + "'";
                    OleDbCommand cmdrc = new OleDbCommand(strrc, loaddb.cnn);
                    incr = Convert.ToInt32(cmdrc.ExecuteScalar());
                    if (incr > 0)
                    {
                        cr     = Convert.ToDouble(rRound) + 1;
                        rRound = cr.ToString();

                        cr     = Convert.ToDouble(rRound) * Convert.ToDouble(sRound);
                        ct     = ((Convert.ToDouble(sTMoney) * Convert.ToDouble(sTicket)) / 100) * Convert.ToDouble(rTicket);
                        cm     = cr + ct;
                        rMoney = cm.ToString("00.00");

                        string       strup = "UPDATE DBRunRound SET Round='" + rRound + "',RMoney='" + rMoney + "' WHERE IDCard='" + rIDCard + "' AND [RTime]='" + rTime + "' ";
                        OleDbCommand cmdu  = new OleDbCommand(strup, loaddb.cnn);
                        cmdu.ExecuteNonQuery();
                        loaddb.cnn.Dispose();
                        loaddb.cnn.Close();

                        rmess     = true;
                        checkdata = false;

                        loadrRound();
                    }
                    else
                    {
                        rRound  = "1";
                        rTicket = "0";
                        rCheck  = "ยังไม่ได้ออก";

                        cr     = Convert.ToInt32(rRound) * Convert.ToInt32(sRound);
                        ct     = ((Convert.ToInt32(sTMoney) * Convert.ToInt32(sTicket)) / 100) * Convert.ToInt32(rTicket);
                        cm     = cr + ct;
                        rMoney = cm.ToString("0.00");

                        //mIDCard mName mLName mPhone mPST mNCar
                        //rIDCard rTime rName rLName rPhone rPST rNCar rRound rMoney rCheck
                        //cTime,cIDCard
                        loaddb.checkdb();
                        string       stris = "INSERT INTO DBRunRound (IDCard,RTime,RName,RLName,RPhone,RPST,RNCar,Round,Rticket,RMoney,RCheck) VALUES ('" + mIDCard + "','" + cTime + "','" + mName + "','" + mLName + "','" + mPhone + "','" + mPST + "','" + mNCar + "','" + rRound + "','" + rTicket + "','" + rMoney + "','" + rCheck + "')";
                        OleDbCommand cmdis = new OleDbCommand();

                        cmdis.CommandText = stris;
                        cmdis.CommandType = CommandType.Text;
                        cmdis.Connection  = loaddb.cnn;
                        cmdis.ExecuteNonQuery();

                        loaddb.cnn.Dispose();
                        loaddb.cnn.Close();

                        rmess     = true;
                        checkdata = false;

                        loadrRound();
                    }
                }
                else
                {
                    read = false;
                    if (MessageBox.Show("ข้อมูลนี้ไม่มีในระบบ!! คุณต้องการเพิ่มข้อมูลหรือไม่", "คำเตือน", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        loadmMember();
                        loadrRound();
                        loadsetting();
                        FAddMember fam = new FAddMember();
                        fam.ShowDialog();
                        read = true;
                    }
                    else
                    {
                        read = true;
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "พบข้อผิดพลาด");
            }
            loaddb.cnn.Dispose();
            loaddb.cnn.Close();
        }