Ejemplo n.º 1
0
        private void pbBack_Click(object sender, EventArgs e)
        {
            FCashierMenu fcm = new FCashierMenu();

            fcm.Show();
            this.Hide();
        }
        private void btnBack_Click(object sender, EventArgs e)
        {
            FCashierMenu fcm = new FCashierMenu();

            fcm.Show();
            this.Hide();
            File.WriteAllText(@"Data\\temprecipe.txt", string.Empty);
        }
Ejemplo n.º 3
0
        private void pbLogin_Click(object sender, EventArgs e)
        {
            string username, password;

            username = txtUser.Text;
            password = txtPass.Text;
            FileStream   fs   = new FileStream("Data\\cashierlogin.txt", FileMode.Open, FileAccess.Read);
            StreamReader sr   = new StreamReader(fs);
            string       line = sr.ReadLine();
            int          flag = 0;

            while (line != null)
            {
                if (line.Contains(username))
                {
                    string[] isi = line.Split('#');
                    if (isi[1] == username && isi[2] == password)
                    {
                        flag = 1;
                    }
                    break;
                }
                line = sr.ReadLine();
            }
            sr.Close();
            fs.Close();

            if (flag == 1)
            {
                MessageBox.Show("Welcome, " + username + ". Have a nice day :)", "Login Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FCashierMenu fcm = new FCashierMenu();
                fcm.Show();
                this.Hide();
                counter = 0;
            }
            else
            {
                counter += 1;
                if (counter < 3)
                {
                    lblError.Visible = true;
                    txtUser.Focus();
                    txtUser.Clear();
                    txtPass.Clear();
                }
                else
                {
                    MessageBox.Show("Unauthorized Access. Aborting...");
                    this.Close();
                }
            }
        }
Ejemplo n.º 4
0
        private void pbSave_Click(object sender, EventArgs e)
        {
            if (txtIdPatient.Text == "" || txtDiagnose.Text == "")
            {
                MessageBox.Show("Please fill in the data");
            }
            else
            {
                if (txtIdTreatment.Text == "full")
                {
                    MessageBox.Show("Data already meets maximum limit", "Can not store data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    FCashierMenu fcm = new FCashierMenu();
                    fcm.Show();
                    this.Hide();
                }
                else
                {
                    if (validasidokter() == 0)
                    {
                        DialogResult result = MessageBox.Show("Do you want to save record " + txtIdTreatment.Text + "?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            FileStream   fs = new FileStream("Data\\treatment.txt", FileMode.Append, FileAccess.Write);
                            StreamWriter sw = new StreamWriter(fs);

                            sw.WriteLine(txtIdTreatment.Text + "#" + txtIdPatient.Text + "#" + txtIdDoctor.Text + "#" + txtRecipe.Text + "#" + txtDiagnose.Text + "#" + txtDateTreatment.Text + "#");
                            sw.Flush();
                            sw.Close();
                            MessageBox.Show("Data saved");
                            txtDateTreatment.Clear();
                            txtDiagnose.Clear();
                            txtRecipe.Clear();
                            txtIdDoctor.Clear();
                            txtIdTreatment.Clear();
                            txtIdPatient.Clear();
                            txtIdPatient.Focus();

                            datagridview();
                            txtIdTreatment.Text   = agtreatment();
                            txtRecipe.Text        = agrecipe();
                            txtDateTreatment.Text = date;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Correct Error(s)");
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void pbSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "" || txtAddress.Text == "")
            {
                MessageBox.Show("Please fill in the data");
            }
            else
            {
                if (txtIdPatient.Text == "full")
                {
                    MessageBox.Show("Data already meets maximum limit", "Can not store data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    FCashierMenu fcm = new FCashierMenu();
                    fcm.Show();
                    this.Hide();
                }
                else
                {
                    string gender    = "";
                    bool   ischecked = rbMale.Checked;
                    if (ischecked)
                    {
                        gender = rbMale.Text;
                    }
                    else
                    {
                        gender = rbFemale.Text;
                    }
                    if (validategender() == 0)
                    {
                        DialogResult result = MessageBox.Show("Do you want to save record " + txtIdPatient.Text + " with name " + txtName.Text + "?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            FileStream   fs = new FileStream("Data\\patient.txt", FileMode.Append, FileAccess.Write);
                            StreamWriter sw = new StreamWriter(fs);


                            sw.WriteLine(txtIdPatient.Text + "#" + txtName.Text + "#" + txtDOB.Text + "#" + txtPhoneNumber.Text + "#" + gender + "#" + txtAddress.Text + "#");
                            sw.Flush();
                            sw.Close();
                            MessageBox.Show("Data saved.\nPrint Data");

                            FCashierCardPatient fccp        = new FCashierCardPatient();
                            CRCardPatient       crcp        = new CRCardPatient();
                            TextObject          toidpatient = (TextObject)crcp.ReportDefinition.Sections["Section3"].ReportObjects["IdPatient"];
                            toidpatient.Text = txtIdPatient.Text;
                            TextObject topatientname = (TextObject)crcp.ReportDefinition.Sections["Section3"].ReportObjects["PatientName"];
                            topatientname.Text = txtName.Text;
                            TextObject tophonenumber = (TextObject)crcp.ReportDefinition.Sections["Section3"].ReportObjects["PhoneNumber"];
                            tophonenumber.Text = txtPhoneNumber.Text;
                            TextObject toaddress = (TextObject)crcp.ReportDefinition.Sections["Section3"].ReportObjects["Address"];
                            toaddress.Text = txtAddress.Text;
                            fccp.crystalReportViewer1.ReportSource = crcp;
                            fccp.crystalReportViewer1.Refresh();
                            fccp.Show();
                            this.Hide();

                            txtName.Clear();
                            txtDOB.Clear();
                            txtPhoneNumber.Clear();
                            rbMale.Checked   = false;
                            rbFemale.Checked = false;
                            txtAddress.Clear();
                            txtIdPatient.Clear();
                            txtName.Focus();

                            datagridview();
                            txtIdPatient.Text = agpatient();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Correct The Error(s)");
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void pbSave_Click(object sender, EventArgs e)
        {
            if (txtDose.Text == "" || txtSubtotal.Text == "")
            {
                MessageBox.Show("Please fill the data");
            }
            else
            {
                if (txtRD.Text == "full")
                {
                    MessageBox.Show("Data already meets maximum limit", "Can not store data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    FCashierMenu fcm = new FCashierMenu();
                    fcm.Show();
                    this.Hide();
                }
                else
                {
                    if (validasidrug() == 0)
                    {
                        if (Convert.ToInt32(strqty) < Convert.ToInt32(txtQty.Text))
                        {
                            //obat kurang
                            MessageBox.Show("less drug");
                        }
                        else
                        {
                            if (expdate == date)
                            {
                                MessageBox.Show("Can not save record because drug has been expired");
                                txtDrug.Clear();
                            }
                            else
                            {
                                DialogResult result = MessageBox.Show("Do you want to save record " + txtRD.Text + "?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                                if (result == DialogResult.Yes)
                                {
                                    string[] strarray = new string[7];
                                    int      pos;
                                    string   alltext   = "";
                                    string   txtsimpan = "";
                                    string   line;

                                    FileStream   fs = new FileStream("Data\\recipedetail.txt", FileMode.Append, FileAccess.Write);
                                    StreamWriter sw = new StreamWriter(fs);
                                    sw.WriteLine(txtRD.Text + "#" + txtIdRecipe.Text + "#" + txtDrug.Text + "#" + txtDose.Text + "#" + txtQty.Text + "#" + txtSubtotal.Text + "#");
                                    sw.Flush();
                                    sw.Close();

                                    /*Temp File*/
                                    FileStream   fstemp = new FileStream("Data\\temprecipe.txt", FileMode.Append, FileAccess.Write);
                                    StreamWriter swtemp = new StreamWriter(fstemp);
                                    swtemp.WriteLine(txtRD.Text + "#" + strdrugname + "#" + txtDose.Text + "#" + txtQty.Text + "#" + txtSubtotal.Text + "#");
                                    swtemp.Flush();
                                    swtemp.Close();

                                    newstock = (Convert.ToInt32(strqty) - Convert.ToInt32(txtQty.Text));
                                    FileStream   fs1 = new FileStream("Data\\drug.txt", FileMode.Open, FileAccess.Read);
                                    StreamReader sr  = new StreamReader(fs1);
                                    while ((line = sr.ReadLine()) != null)
                                    {
                                        pos = line.IndexOf("#");
                                        string chkstr = line.Substring(0, pos);
                                        if ((txtDrug.Text.CompareTo(chkstr) == 0))
                                        {
                                            txtsimpan = txtDrug.Text + "#" + strdrugname + "#" + strdurgdtype + "#" + newstock + "#" + expdate + "#" + harga + "#" + "\n";
                                            alltext  += txtsimpan;
                                        }
                                        else
                                        {
                                            alltext = alltext + line + "\n";
                                        }
                                    }
                                    sr.Close();
                                    fs1.Close();
                                    File.WriteAllText("Data\\drug.txt", alltext);


                                    //sub = 0;
                                    txtSubtotal.Clear();
                                    txtQty.Clear();
                                    txtDose.Clear();
                                    txtDrug.Clear();
                                    txtRD.Clear();
                                    txtIdRecipe.Clear();
                                    txtDose.Focus();

                                    datagridview();
                                    txtRD.Text       = agrecipedetail();
                                    txtIdRecipe.Text = cekidrecipe();
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Correct The Error(s)");
                    }
                }
            }
        }