private void f_get_tongtienthuoc_nhap() { //Nhap mua moi string s_ma = "14,15,16"; DataSet tmp = d.get_sotien_nhap_dbv_angiang(i_nhom, tu.Text, den.Text); decimal st1 = 0, st2 = 0, st3 = 0, st = 0; foreach (DataRow r1 in tmp.Tables[0].Select("stt>0", "stt"))//.Rows)//.Select("stt=" + int.Parse(r["ma"].ToString()))) { if (r1["loai"].ToString() == "DNNN") { st1 += decimal.Parse(r1["sotien"].ToString()); } else { st2 += decimal.Parse(r1["sotien"].ToString()); } } foreach (DataRow r in ds.Tables[0].Select("ma in (" + s_ma + ")")) { if (r["ma"].ToString() == "14") { r["soluong"] = st1 / 1000; } else if (r["ma"].ToString() == "15") { r["soluong"] = st2 / 1000; } else if (r["ma"].ToString() == "16") { r["soluong"] = st3 / 1000; } } //ma: 18,19 s_ma = "18,19"; st1 = 0; st2 = 0; foreach (DataRow r1 in tmp.Tables[0].Select("stt>0", "stt"))//.Rows)//.Select("stt=" + int.Parse(r["ma"].ToString()))) { if (r1["idnn"].ToString() == "1") { st1 += decimal.Parse(r1["sotien"].ToString()); } else { st2 += decimal.Parse(r1["sotien"].ToString()); } } foreach (DataRow r in ds.Tables[0].Select("ma in (" + s_ma + ")")) { if (r["ma"].ToString() == "18") { r["soluong"] = st1 / 1000; } else { r["soluong"] = st2 / 1000; } } //Nhap theo nhom s_ma = "20,21,22,23,26,37"; foreach (DataRow r in ds.Tables[0].Select("ma in (" + s_ma + ")")) { st = 0; foreach (DataRow r1 in tmp.Tables[0].Select("stt=" + int.Parse(r["ma"].ToString()))) { st += decimal.Parse(r1["sotien"].ToString()); } r["soluong"] = st / 1000; } //chung loai nhap s_ma = "27,28,29"; tmp = d.get_sothuoc_dbv_angiang(i_nhom, tu.Text, den.Text); DataRow r2 = d.getrowbyid(ds.Tables[0], "ma=27");//tong chung loai thuoc if (r2 != null) { r2["soluong"] = tmp.Tables[0].Rows.Count; } r2 = d.getrowbyid(ds.Tables[0], "ma=28"); if (r2 != null) { r2["soluong"] = tmp.Tables[0].Select("id=1").Length; //thuoc noi } r2 = d.getrowbyid(ds.Tables[0], "ma=29"); if (r2 != null) { r2["soluong"] = tmp.Tables[0].Select("id<>1").Length; //thuoc ngoai } //Dich truyen tmp = d.get_soluong_dichtruyen_angiang(i_nhom, tu.Text, den.Text); st = 0; s_ma = "24,25"; foreach (DataRow r in ds.Tables[0].Select("ma in (" + s_ma + ")")) { st1 = 0; foreach (DataRow r1 in tmp.Tables[0].Select("stt=" + int.Parse(r["ma"].ToString()))) { st1 += decimal.Parse(r1["soluong"].ToString()) * decimal.Parse(d.so_chu(r1["hamluong"].ToString())); } r["soluong"] = st1 / 1000; } // ds.AcceptChanges(); }