コード例 #1
0
ファイル: frmDuocbv.cs プロジェクト: tayduivn/mdebv
        private void f_tonghop_duocbv()
        {
            Cursor = Cursors.WaitCursor;
            decimal sum = 0, st = 0;
            DataSet tmp = d.get_sotien_dbv(i_nhom, tu.Text, den.Text);

            foreach (DataRow r in ds.Tables[0].Select("ma in (3,4,5,6,7,8)"))
            {
                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;
            }
            foreach (DataRow r in tmp.Tables[0].Rows)
            {
                sum += decimal.Parse(r["sotien"].ToString());
            }
            DataRow r2 = d.getrowbyid(ds.Tables[0], "ma=1");

            if (r2 != null)
            {
                r2["soluong"] = sum / 1000;
            }
            tmp = d.get_sothuoc_dbv(i_nhom, tu.Text, den.Text);
            r2  = d.getrowbyid(ds.Tables[0], "ma=21");
            if (r2 != null)
            {
                r2["soluong"] = tmp.Tables[0].Rows.Count;
            }
            r2 = d.getrowbyid(ds.Tables[0], "ma=23");
            if (r2 != null)
            {
                r2["soluong"] = tmp.Tables[0].Select("id=1").Length;
            }
            r2 = d.getrowbyid(ds.Tables[0], "ma=24");
            if (r2 != null)
            {
                r2["soluong"] = tmp.Tables[0].Select("id=2").Length;
            }
            tmp = d.get_soluong_dichtruyen(i_nhom, tu.Text, den.Text);
            sum = 0;
            foreach (DataRow r in ds.Tables[0].Select("ma in (12,13,14)"))
            {
                st = 0;
                foreach (DataRow r1 in tmp.Tables[0].Select("stt=" + int.Parse(r["ma"].ToString())))
                {
                    st += decimal.Parse(r1["soluong"].ToString()) * decimal.Parse(d.so_chu(r1["hamluong"].ToString()));
                }
                r["soluong"] = st / 1000;
                if (r["ma"].ToString() == "14")
                {
                    sum += st;
                }
            }
            r2 = d.getrowbyid(ds.Tables[0], "ma=13");
            if (r2 != null)
            {
                r2["soluong"] = decimal.Parse(r2["soluong"].ToString()) + sum / 1000;
            }
            sum = 0;
            foreach (DataRow r in ds.Tables[0].Select("ma in (12,13)"))
            {
                sum += decimal.Parse(r["soluong"].ToString());
            }
            r2 = d.getrowbyid(ds.Tables[0], "ma=10");
            if (r2 != null)
            {
                r2["soluong"] = sum;
            }
            foreach (DataRow r in ds.Tables[0].Rows)
            {
                d.execute_data("update " + user + ".dm_07 set soluong=" + decimal.Parse(r["soluong"].ToString()) + " where ma=" + int.Parse(r["ma"].ToString()));
            }
            butKHTH.Enabled = true;
            Cursor          = Cursors.Default;
        }