Exemple #1
0
        private void dataGridView3_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DBManager c = new DBManager();

            try
            {
                DialogResult result = MessageBox.Show("Seguro que desea Borrar?", "Borrar Sub-Procedimiento", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    DataGridViewRow act         = dataGridView3.Rows[e.RowIndex];
                    string          description = act.Cells["ID"].Value.ToString();
                    string          query       = "DELETE FROM subprocedure WHERE id = '" + description + "'";
                    c.command3(query);

                    string query2 = "Select id as ID, idprocedure as IDProcedimiento, codeinsurance as Codigo, subprocedure as Procedimiento, tariff as Tarifa, coverage as Cobertura, difference as Diferencia, paystatus as Pago, insurance as Seguro from subprocedure where idprocedure = '" + idprocedure_txt.Text + "'";
                    c.load_dgv(dataGridView3, query2);
                    sums();
                }
                else if (result == DialogResult.No)
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
            finally
            {
            }
        }
Exemple #2
0
 private void cancel_btn_Click(object sender, EventArgs e)
 {
     try
     {
         DBManager c     = new DBManager();
         string    query = "DELETE FROM subprocedure WHERE idprocedure = '" + idprocedure_txt.Text + "'";
         c.command3(query);
         string query2 = "DELETE FROM [procedure] WHERE idpatient  is null";
         c.command3(query2);
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error al cerrar ventana. Causa " + ex.Message);
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(ep_ta_txt.Text) && string.IsNullOrEmpty(ep_cov_txt.Text))
                {
                    MessageBox.Show("No ha dijitado valores en los campos de tearifa y cobertura, favor revisar.", "Error");
                }
                else if (string.IsNullOrEmpty(ep_ta_txt.Text) == false && string.IsNullOrEmpty(ep_cov_txt.Text))
                {
                    string query = "Update subprocedure set tariff = '" + ep_ta_txt.Text + "', coverage = '0', difference = '" + ep_dif_txt.Text + "' where id = '" + ep_id_txt.Text + "'";
                    c.command3(query);
                    this.Close();
                }
                else if (string.IsNullOrEmpty(ep_ta_txt.Text) && string.IsNullOrEmpty(ep_cov_txt.Text) == false)
                {
                    string query = "Update subprocedure set tariff = '0', coverage = '" + ep_cov_txt.Text + "', difference = '" + ep_dif_txt.Text + "' where id = '" + ep_id_txt.Text + "'";
                    c.command3(query);
                    this.Close();
                }
                else if (string.IsNullOrEmpty(ep_ta_txt.Text) == false && string.IsNullOrEmpty(ep_cov_txt.Text) == false)
                {
                    string query = "Update subprocedure set tariff = '" + ep_ta_txt.Text + "', coverage = '" + ep_cov_txt.Text + "', difference = '" + ep_dif_txt.Text + "' where id = '" + ep_id_txt.Text + "'";
                    c.command3(query);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un error. Motivo: " + ex.Message, "Error");
            }

            finally
            {
                try
                {
                    addprocedure f = new addprocedure();
                    f.loadsubprocedure();
                    f.sums();
                }
                catch
                {
                    MessageBox.Show("No mando a cargar.");
                }
            }
        }
Exemple #4
0
        private void deleteclose()
        {
            DBManager c     = new DBManager();
            string    query = "DELETE FROM subprocedure WHERE idprocedure = '" + idprocedure_txt.Text + "'";

            c.command3(query);
            string query2 = "DELETE FROM [procedure] WHERE idprocedure = '" + idprocedure_txt.Text + "'";

            c.command3(query2);

            //SQLiteConnection cnx = new SQLiteConnection("Data Source=C:\\syspandemic\\db\\syspandemic.db;Version=3;");
            //try
            //        {
            //            cnx.Open();
            //            if (idprocedure_txt.Text.Length > 0)
            //            {
            //                string comando = "DELETE FROM subprocedure WHERE idprocedure = '" + idprocedure_txt.Text + "'";
            //                SQLiteCommand insertion = new SQLiteCommand(comando, cnx);
            //                if (insertion.ExecuteNonQuery() > 0)
            //                {
            //                    cnx.Close();

            //                    MessageBox.Show("Cerrado");
            //                }
            //            }
            //        }
            //        catch (Exception ex)
            //        {
            //            MessageBox.Show(ex.Message, "Delete catch");
            //        }
            //finally
            //{
            //    cnx.Close();
            //}
            Close();
        }
 private void button1_Click(object sender, EventArgs e)
 {
     if (reasondesc_txt.Text.Length < 1)
     {
         MessageBox.Show("Debe de digitar la razon antes de guardar", "Error");
         reasondesc_txt.Focus();
     }
     else
     {
         if (allpay_rbtn.Checked)
         {
             if (doctorpay_txt.Text.Length > 1 && pdoctorpay_txt.Text.Length < 1)
             {
                 decimal doctordesc = Convert.ToDecimal(doctorpay_txt.Text) * -1;
                 string  querry     = "Insert into [payrolldoctors]([iddoctor], reason, qty, date) values ('" + iddoctors.Text + "', '" + reasondesc_txt.Text + "','" + doctordesc + "','" + datedesc_dtp.Text + "')";
                 c.command(querry);
             }
             else
             {
                 MessageBox.Show("Algo no va como debe, verifique que solo el campo de texto MONTO A PAGAR DOCTOR tenga numeros", "Error");
             }
         }
         else if (porcent_rbtn.Checked)
         {
             if (doctorpay_txt.Text.Length > 1 && pdoctorpay_txt.Text.Length > 1)
             {
                 decimal doctordesc  = Convert.ToDecimal(doctorpay_txt.Text) * -1;
                 decimal pdoctordesc = Convert.ToDecimal(pdoctorpay_txt.Text) * -1;
                 string  querry      = "Insert into [payrolldoctors]([iddoctor], reason, qty, date) values ('" + iddoctors.Text + "', '" + reasondesc_txt.Text + "','" + doctordesc + "','" + datedesc_dtp.Text + "')";
                 c.command3(querry);
                 querry = "Insert into [payrolldoctors]([iddoctor], reason, qty, date) values ('1', '" + reasondesc_txt.Text + "','" + pdoctordesc + "','" + datedesc_dtp.Text + "')";
                 c.command(querry);
             }
             else
             {
                 MessageBox.Show("Algo no va como debe, verifique que los campo de texto MONTO A PAGAR DOCTOR y MONTO A PAGAR PRIN DOCTOR tenga numeros", "Error");
             }
         }
     }
 }
Exemple #6
0
        private void dataGridView4_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DBManager       c           = new DBManager();
                DataGridViewRow act         = dataGridView4.Rows[e.RowIndex];
                string          description = act.Cells["Descripcion"].Value.ToString();
                string          tariff      = act.Cells["Tarifa"].Value.ToString();
                string          coverage    = act.Cells["Cobertura"].Value.ToString();
                string          difference  = act.Cells["Diferencia"].Value.ToString();
                string          code        = act.Cells["Codigo"].Value.ToString();
                string          insurance   = act.Cells["Seguro"].Value.ToString();
                string          paystatus   = "Sin Realizar";

                string query = "INSERT INTO subprocedure(idprocedure, codeinsurance, subprocedure, tariff, coverage, difference, status, insurance) VALUES('" + idprocedure_txt.Text + "', '" + code + "','" + description + "','" + tariff + "', '" + coverage + "', '" + difference + "', '" + paystatus + "', '" + insurance + "')";
                c.command3(query);
                if (c.valor == "si")
                {
                    //MessageBox.Show("Done");
                    c.valor = "";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Insert");
            }
            finally
            {
                try
                {
                    loadsubprocedure();
                    sums();
                }
                catch
                {
                    MessageBox.Show("No mando a cargar.");
                }
            }
        }
Exemple #7
0
        private void addpay_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(typepay.Text))
            {
                MessageBox.Show("Debe de elegir un metodo de pago.", "Error");
            }
            else
            {
                if (string.IsNullOrEmpty(qtypay.Text))
                {
                    MessageBox.Show("Debe de elegir una cantidad de pago.", "Error");
                }
                else
                {
                    DBManager c     = new DBManager();
                    string    query = "INSERT INTO [transaction](ref, madebytran, reasontran, datetran, origin, entry, expenses) values('" + idsubprocedure_txt.Text + "', '" + spnamepatient_txt.Text + "', '" + sprocedure_txt.Text + "', '" + datepay.Text + "', '" + typepay.Text + "', '" + qtypay.Text + "', '0')";
                    decimal   ppay  = Convert.ToDecimal(sppricepay_txt.Text);

                    decimal qty = Convert.ToDecimal(qtypay.Text);

                    if (string.IsNullOrEmpty(nowpay_txt.Text))
                    {
                        if (ppay >= qty)
                        {
                            c.command(query);

                            //insertar en la tabla de pago a los doctores;

                            if (Convert.ToInt32(iddoctor_txt.Text) == 1)
                            {
                                string querry2 = "Insert into [payrolldoctors](iddoctor, idpatient, namepatient, idprocedure, reason, qty, date) values ('" + iddoctor_txt.Text + "', '" + sidpatient.Text + "', '" + spnamepatient_txt.Text + "', '" + idsubprocedure_txt.Text + "', '" + sprocedure_txt.Text + "', '" + qtypay.Text + "', '" + datepay.Text + "')";
                                c.command3(querry2);
                            }
                            else
                            {
                                decimal gaindoctor     = Convert.ToDecimal(gaindoctor_txt.Text) / 100;
                                decimal gainfulldoctor = 1 - gaindoctor;
                                decimal paygaindoctor  = Convert.ToDecimal(qtypay.Text) * gaindoctor;
                                decimal payfulldoctor  = Convert.ToDecimal(qtypay.Text) * gainfulldoctor;

                                string querry2 = "Insert into [payrolldoctors](iddoctor, idpatient, namepatient, idprocedure, reason, qty, date) values ('" + iddoctor_txt.Text + "', '" + sidpatient.Text + "', '" + spnamepatient_txt.Text + "',  '" + idsubprocedure_txt.Text + "', '" + sprocedure_txt.Text + "', '" + paygaindoctor + "', '" + datepay.Text + "')";
                                c.command3(querry2);

                                string querry3 = "Insert into [payrolldoctors](iddoctor, idpatient, namepatient, idprocedure, reason, qty, date) values ('1', '" + sidpatient.Text + "', '" + spnamepatient_txt.Text + "', '" + idsubprocedure_txt.Text + "', '" + sprocedure_txt.Text + "', '" + payfulldoctor + "', '" + datepay.Text + "')";
                                c.command3(querry3);
                            }



                            //Insertar en la tabla del historico del paciente
                            string hquery = "insert into patienthistory(idpatient, tooth, activity, qtypay, date) values('" + sidpatient.Text + "', '" + stooth_txt.Text + "', '" + sactivity_txt.Text + "', '" + qtypay.Text + "', '" + datepay.Text + "')";
                            c.command3(hquery);

                            loadbill();
                            string query2 = "Select top 1 * from [transaction] order by idtransactions desc";

                            string tablename = "entrybill";
                            string xml       = "entrybill.xml";
                            string report    = "entrybill.rpt";
                            c.printreport(query2, tablename, xml, report);

                            sactivity_txt.Clear();
                            qtypay.Clear();
                            typepay.Text = "";
                        }
                        else
                        {
                            MessageBox.Show("El monto ha abonar mas lo ya abonado sobrepasa el precio del procedimiento, favor verifique y reintente");
                        }
                    }
                    else
                    {
                        decimal nowpay = Convert.ToDecimal(nowpay_txt.Text);
                        if (ppay > nowpay)
                        {
                            if (ppay >= (nowpay + qty))
                            {
                                c.command(query);

                                //insertar en la tabla de pago a los doctores;

                                if (Convert.ToInt32(iddoctor_txt.Text) == 1)
                                {
                                    string querry2 = "Insert into [payrolldoctors](iddoctor, idpatient, namepatient, idprocedure, reason, qty, date) values ('" + iddoctor_txt.Text + "', '" + sidpatient.Text + "', '" + spnamepatient_txt.Text + "', '" + idsubprocedure_txt.Text + "', '" + sprocedure_txt.Text + "', '" + qtypay.Text + "', '" + datepay.Text + "')";
                                    c.command3(querry2);
                                }
                                else
                                {
                                    decimal gaindoctor     = Convert.ToDecimal(gaindoctor_txt.Text) / 100;
                                    decimal gainfulldoctor = 1 - gaindoctor;
                                    decimal paygaindoctor  = Convert.ToDecimal(qtypay.Text) * gaindoctor;
                                    decimal payfulldoctor  = Convert.ToDecimal(qtypay.Text) * gainfulldoctor;

                                    string querry2 = "Insert into [payrolldoctors](iddoctor, idpatient, namepatient, idprocedure, reason, qty, date) values ('" + iddoctor_txt.Text + "', '" + sidpatient.Text + "', '" + spnamepatient_txt.Text + "', '" + idsubprocedure_txt.Text + "', '" + sprocedure_txt.Text + "', '" + paygaindoctor + "', '" + datepay.Text + "')";
                                    c.command3(querry2);

                                    string querry3 = "Insert into [payrolldoctors](iddoctor, idpatient, namepatient, idprocedure, reason, qty, date) values ('1', '" + sidpatient.Text + "', '" + spnamepatient_txt.Text + "', '" + idsubprocedure_txt.Text + "', '" + sprocedure_txt.Text + "', '" + payfulldoctor + "', '" + datepay.Text + "')";
                                    c.command3(querry3);
                                }


                                loadbill();

                                //Insertar en la tabla del historico del paciente
                                string hquery = "insert into patienthistory(idpatient, tooth, activity, qtypay, date) values('" + sidpatient.Text + "', '" + stooth_txt.Text + "', '" + sactivity_txt.Text + "', '" + qtypay.Text + "', '" + datepay.Text + "')";
                                c.command3(hquery);

                                string query3 = "Select top 1 * from [transaction] order by idtransactions desc";

                                string tablename = "entrybill";
                                string xml       = "entrybill.xml";
                                string report    = "entrybill.rpt";
                                c.printreport(query3, tablename, xml, report);

                                sactivity_txt.Clear();
                                qtypay.Clear();
                                typepay.Text = "";
                            }
                            else
                            {
                                MessageBox.Show("El monto ha abonar mas lo ya abonado sobrepasa el precio del procedimiento, favor verifique y reintente");
                            }
                        }
                        else
                        {
                            MessageBox.Show("NO puede abonar, debido a que el procedimiento ya esta pagado.");
                        }
                    }
                }
            }
        }