Пример #1
0
  protected void Button1_Click(object sender, EventArgs e)
  {
      DataSet dt1 = new DataSet();

      dt1 = obj.investigation_byopd(Session["opd_code"].ToString());
      if (dt1.Tables[0].Rows.Count == 0)
      {
          String path_id = obj.getpath_id();
          pop.path_id = path_id;
          if (Session["external"] == null)
          {
              pop.ref_by = Convert.ToString(Session["emp_code"]);
          }
          else
          {
              pop.ref_by = Convert.ToString(Session["external"]);
          }
          pop.opd_code     = Convert.ToString(Session["opd_code"]);
          pop.patient_code = Convert.ToString(Session["pateint_code"]);
          pop.inserted_by  = Convert.ToString(Session["emp_code"]);
          pop.inserted_on  = DateTime.Today;
          pop.is_done      = "Not Completed";
          rt.palm_opd_pathlogies.InsertOnSubmit(pop);
          rt.SubmitChanges();
          pop              = rt.palm_opd_pathlogies.Single(palm_opd_pathlogy => palm_opd_pathlogy.opd_code == Convert.ToString(Session["opd_code"]));
          pop1.path_id     = pop.path_id;;
          pop1.test_name   = DropDownList1.SelectedItem.Text;
          pop1.description = TextBox2.Text;
          pop1.date        = DateTime.Now.ToString();;
          pop1.is_done     = "Not Completed";
          ; rt.palm_opd_pathlogy_slaves.InsertOnSubmit(pop1);
          rt.SubmitChanges();
      }
      else
      {
          pop1.path_id     = dt1.Tables[0].Rows[0]["path_id"].ToString();
          pop1.test_name   = DropDownList1.SelectedItem.Text;
          pop1.description = TextBox2.Text;
          pop1.date        = DateTime.Now.ToString();
          pop1.is_done     = "Not Completed";
          ; rt.palm_opd_pathlogy_slaves.InsertOnSubmit(pop1);
          rt.SubmitChanges();
      }

      // bill section
      DataSet dt = new DataSet();

      dt = obj.getbillstatus(Session["opd_code"].ToString());
      palm_opd_pathlogy_billm pob = new palm_opd_pathlogy_billm();
      palm_opd_pathlogy_bill  pos = new palm_opd_pathlogy_bill();
      pathology_test_report   ptr = new pathology_test_report();

      dt1 = obj.pathologybill_byopd(Session["opd_code"].ToString());
      if (dt.Tables[0].Rows.Count == 0)
      {
          string cashmemo = obj.getlast_pathology_cashmemo();
          pob.memo         = cashmemo;
          pob.opd_code     = Session["opd_code"].ToString();
          pob.patient_code = Session["pateint_code"].ToString();
          pob.inserted_by  = Session["emp_code"].ToString();
          pob.inserted_on  = DateTime.Now.ToString();
          rt.palm_opd_pathlogy_billms.InsertOnSubmit(pob);
          rt.SubmitChanges();

          //pathology save

          pos.memo         = cashmemo;
          pos.patient_code = Session["pateint_code"].ToString();
          pos.test_name    = DropDownList1.SelectedItem.Text;
          ptr        = rt.pathology_test_reports.Single(pathology_test_report => pathology_test_report.test_code == DropDownList1.SelectedValue);
          pos.charge = ptr.test_rate;
          rt.palm_opd_pathlogy_bills.InsertOnSubmit(pos);
          rt.SubmitChanges();
      }
      else
      {
          int i = dt.Tables[0].Rows.Count - 1;
          if (dt.Tables[0].Rows[i]["total"].ToString() != "")
          {
              string cashmemo = obj.getlast_pathology_cashmemo();
              pob.memo         = cashmemo;
              pob.opd_code     = Session["opd_code"].ToString();
              pob.patient_code = Session["pateint_code"].ToString();
              pob.inserted_by  = Session["emp_code"].ToString();
              pob.inserted_on  = DateTime.Now.ToString();
              rt.palm_opd_pathlogy_billms.InsertOnSubmit(pob);
              rt.SubmitChanges();

              //pathology save

              pos.memo         = cashmemo;
              pos.patient_code = Session["pateint_code"].ToString();
              pos.test_name    = DropDownList1.SelectedItem.Text;
              ptr        = rt.pathology_test_reports.Single(pathology_test_report => pathology_test_report.test_code == DropDownList1.SelectedValue);
              pos.charge = ptr.test_rate;
              rt.palm_opd_pathlogy_bills.InsertOnSubmit(pos);
              rt.SubmitChanges();
          }

          else
          {
              // pob = rt.palm_opd_pathlogy_billms.Single(palm_opd_pathlogy_billm => palm_opd_pathlogy_billm.opd_code == Session["opd_code"].ToString());
              DataSet ds = new DataSet();
              ds               = obj.getactivememo(Session["opd_code"].ToString());
              pos.memo         = ds.Tables[0].Rows[0]["memo"].ToString();
              pos.patient_code = Session["pateint_code"].ToString();
              pos.test_name    = DropDownList1.SelectedItem.Text;
              ptr              = rt.pathology_test_reports.Single(pathology_test_report => pathology_test_report.test_code == DropDownList1.SelectedValue);
              pos.charge       = ptr.test_rate;
              rt.palm_opd_pathlogy_bills.InsertOnSubmit(pos);
              rt.SubmitChanges();
          }
      }
      BindData();
  }