Beispiel #1
0
        private void ins_items()
        {
            System.Data.DataTable dt = d.get_data(sql).Tables[0];
            string ten;

            if (bSothe)
            {
                decimal id = 0;
                foreach (DataRow r in dt.Select("loai=0", "id"))
                {
                    if (id != decimal.Parse(r["id"].ToString()))
                    {
                        id             = decimal.Parse(r["id"].ToString());
                        r1             = dtso.NewRow();
                        r1["id"]       = r["id"].ToString();
                        r1["ngay"]     = r["ngay"].ToString();
                        r1["sothe"]    = r["sothe"].ToString();
                        r1["hoten"]    = r["hoten"].ToString();
                        r1["congkham"] = d.Congkham(i_nhom);
                        dtso.Rows.Add(r1);
                        soluot += 1;
                    }
                }
            }
            int isophieu = 0;

            foreach (DataRow r in dt.Rows)
            {
                if (bSothe)
                {
                    sql = "sothe='" + r["sothe"].ToString() + "' and hoten='" + r["hoten"].ToString() + "'";
                }
                else
                {
                    sql = "mabn='" + r["mabn"].ToString() + "' and hoten='" + r["hoten"].ToString() + "'";
                }
                r1  = d.getrowbyid(ds.Tables[0], sql);
                ten = (r["loai"].ToString() == "0")?"thuoc":"cls";
                if (r1 == null)
                {
                    //
                    isophieu = d.get_sophieu_bhyt_userid(tu.Text, den.Text, r["mabn"].ToString(), decimal.Parse(r["mavaovien"].ToString()), r["ngayduyet"].ToString(), int.Parse(madoituong.SelectedValue.ToString()));
                    //
                    r2          = ds.Tables[0].NewRow();
                    r2["sothe"] = r["sothe"].ToString();
                    if (r["sothe"].ToString().Trim().Length > 4)
                    {
                        r2["stt"]    = (r["sothe"].ToString().Substring(2, 2) == s_thetrongtinh)?0:1;
                        r2["sothe1"] = r["sothe"].ToString().Substring(0, 2);
                        r2["sothe2"] = r["sothe"].ToString().Substring(2, 2);
                        r2["sothe3"] = r["sothe"].ToString().Substring(4);
                    }
                    r2["mabn"]     = r["mabn"].ToString();
                    r2["hoten"]    = r["hoten"].ToString();
                    r2["thuoc"]    = 0;
                    r2["cls"]      = 0;
                    r2[ten]        = r["sotien"].ToString();
                    r2["congkham"] = 0;
                    r2["sophieu"]  = isophieu;
                    r2["tongcong"] = decimal.Parse(r["sotien"].ToString()) + decimal.Parse(r["congkham"].ToString());
                    ds.Tables[0].Rows.Add(r2);
                }
                else
                {
                    dr = ds.Tables[0].Select(sql);
                    if (dr.Length > 0)
                    {
                        dr[0][ten]        = decimal.Parse(dr[0][ten].ToString()) + decimal.Parse(r["sotien"].ToString());
                        dr[0]["tongcong"] = decimal.Parse(dr[0]["tongcong"].ToString()) + decimal.Parse(r["sotien"].ToString());
                    }
                }
            }
            if (bSothe)
            {
                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    if (bSothe)
                    {
                        sql = "sothe='" + r["sothe"].ToString() + "' and hoten='" + r["hoten"].ToString() + "'";
                    }
                    else
                    {
                        sql = "mabn='" + r["mabn"].ToString() + "' and hoten='" + r["hoten"].ToString() + "'";
                    }
                    r["soluot"]   = dtso.Select(sql).Length.ToString();
                    r["congkham"] = decimal.Parse(r["soluot"].ToString()) * d.Congkham(i_nhom);
                    r["tongcong"] = decimal.Parse(r["thuoc"].ToString()) + decimal.Parse(r["cls"].ToString()) + decimal.Parse(r["congkham"].ToString());
                    dthuoc       += decimal.Parse(r["thuoc"].ToString());
                    dcls         += decimal.Parse(r["cls"].ToString());
                }
            }
            ds.AcceptChanges();
        }
Beispiel #2
0
 private void ins_items()
 {
     System.Data.DataTable dt = d.get_data(sql).Tables[0];
     if (bSothe)            // && theo.SelectedIndex==1)
     {
         decimal id = 0;
         foreach (DataRow r in dt.Select("loai=0", "id"))
         {
             if (id != decimal.Parse(r["id"].ToString()))
             {
                 id             = decimal.Parse(r["id"].ToString());
                 r1             = dtso.NewRow();
                 r1["id"]       = r["id"].ToString();
                 r1["ngay"]     = r["ngay"].ToString();
                 r1["sothe"]    = r["sothe"].ToString();
                 r1["hoten"]    = r["hoten"].ToString();
                 r1["congkham"] = d.Congkham(i_nhom);
                 dtso.Rows.Add(r1);
                 songay += i_songay;
                 soluot += i_songay;
             }
         }
     }
     foreach (DataRow r in dt.Rows)
     {
         if (theo.SelectedIndex == 0)
         {
             sql = "id=" + decimal.Parse(r["id"].ToString());
         }
         else
         {
             if (bSothe)
             {
                 sql = "sothe='" + r["sothe"].ToString() + "' and hoten='" + r["hoten"].ToString() + "'";
             }
             else
             {
                 sql = "mabn='" + r["mabn"].ToString() + "' and hoten='" + r["hoten"].ToString() + "'";
             }
         }
         r1 = d.getrowbyid(ds.Tables[0], sql);
         if (r1 == null)
         {
             r2          = ds.Tables[0].NewRow();
             r2["id"]    = r["id"].ToString();
             r2["sothe"] = r["sothe"].ToString();
             if (r["sothe"].ToString().Trim().Length > 4 && bSothe)
             {
                 r2["stt"]    = (r["sothe"].ToString().Substring(2, 2) == s_thetrongtinh)?0:1;
                 r2["sothe1"] = r["sothe"].ToString().Substring(0, 2);
                 r2["sothe2"] = r["sothe"].ToString().Substring(2, 2);
                 r2["sothe3"] = r["sothe"].ToString().Substring(4);
             }
             r2["mabn"]     = r["mabn"].ToString();
             r2["hoten"]    = r["hoten"].ToString();
             r2["diachi"]   = r["diachi"].ToString();
             r2["ngaysinh"] = r["namsinh"].ToString();
             r2["ngayvao"]  = r["ngay"].ToString();
             r2["ngayra"]   = r["ngay"].ToString();
             foreach (DataRow r4 in dtnhomvp.Rows)
             {
                 r2["st_" + r4["id"].ToString().Trim()] = 0;
             }
             r2["st_" + r["nhomvp"].ToString().Trim()] = r["sotien"].ToString();
             r2["congkham"] = 0;
             r2["tongcong"] = decimal.Parse(r["sotien"].ToString()) + decimal.Parse(r["congkham"].ToString());
             ds.Tables[0].Rows.Add(r2);
         }
         else
         {
             dr = ds.Tables[0].Select(sql);
             if (dr.Length > 0)
             {
                 dr[0]["st_" + r["nhomvp"].ToString().Trim()] = decimal.Parse(dr[0]["st_" + r["nhomvp"].ToString().Trim()].ToString()) + decimal.Parse(r["sotien"].ToString());
                 dr[0]["tongcong"] = decimal.Parse(dr[0]["tongcong"].ToString()) + decimal.Parse(r["sotien"].ToString());
             }
         }
         r3 = d.getrowbyid(dtnhomvp, "id=" + int.Parse(r["nhomvp"].ToString()));
         if (r3 != null)
         {
             r3["tc"] = decimal.Parse(r3["tc"].ToString()) + decimal.Parse(r["sotien"].ToString());
         }
     }
     if (bSothe)            // && theo.SelectedIndex==1)
     {
         foreach (DataRow r in ds.Tables[0].Rows)
         {
             if (theo.SelectedIndex == 0)
             {
                 sql = "id=" + decimal.Parse(r["id"].ToString());
             }
             else
             {
                 if (bSothe)
                 {
                     sql = "sothe='" + r["sothe"].ToString() + "' and hoten='" + r["hoten"].ToString() + "'";
                 }
                 else
                 {
                     sql = "mabn='" + r["mabn"].ToString() + "' and hoten='" + r["hoten"].ToString() + "'";
                 }
             }
             r["songay"]   = dtso.Select(sql).Length *i_songay;
             r["soluot"]   = r["songay"].ToString();
             r["congkham"] = decimal.Parse(r["soluot"].ToString()) * d.Congkham(i_nhom);
             r["tongcong"] = decimal.Parse(r["congkham"].ToString());                  //d.Congkham(i_nhom);//decimal.Parse(r["congkham"].ToString());
             foreach (DataRow r4 in dtnhomvp.Rows)
             {
                 r["tongcong"] = decimal.Parse(r["tongcong"].ToString()) + decimal.Parse(r["st_" + r4["id"].ToString().Trim()].ToString());
             }
         }
     }
     ds.AcceptChanges();
 }