Ejemplo n.º 1
0
        public static Color ShadeColor(Color col, PointF coordinates, DEM dem)
        {
            if (dem != null)
            {
                float val = dem.EnsureViewGrid()[coordinates]; // scales from 0..1
                col.ToHsv(out float h, out float s, out float v);
                // we adjust the 'v', the lightness: if val=0.5 -> nothing changes
                v = Maths.Limit(v - (1.0F - val) * 0.4F, 0.1F, 1.0F);
                return(ColorExtensions.FromHsv(h, s, v));
            }

            return(col);
        }
Ejemplo n.º 2
0
        //
        //Trang 5
        //



        private void wizardControl1_FinishClick(object sender, CancelEventArgs e)
        {
            try
            {
                DEM d = (from a in db.DEMs where a.ID == "SETUP" select a).Single();
                d.COUNT = 0;
                db.SubmitChanges();
            }
            catch (Exception er)
            {
                MessageBox.Show(er.ToString());
            }

            Application.Restart();
        }
Ejemplo n.º 3
0
 private void fmDangNhap_Load(object sender, EventArgs e)
 {
     txtName.Focus();
     try
     {
         DEM check = (from a in db.DEMs where a.ID == "SETUP" select a).Single();
         if (check.COUNT == 1)
         {
             Setup f = new Setup();
             this.Hide();
             f.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("Có lỗi trong quá trình thực hiện!", "fmDangNhap_Load", MessageBoxButtons.OK, MessageBoxIcon.Error);
         log.Error(ex);
     }
 }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        this.particles = new DEMParticles();
        this.spacePartitioner = new GridSP<int>(
            boundBL, boundTR, 20, 20, new IntEqualityComparer());
        this.gravitationalForce = new GravitationalForce(new Vector2(0, -9.8f));
        this.boundaryForce = new BoundaryForce(
            kn, cn, boundBL.x, boundBL.y, boundTR.x, boundTR.y);
        this.dem = new DEM(spacePartitioner, gravitationalForce, boundaryForce);

        spheres = new GameObject[nParticles];
        for (int i = 0; i < nParticles; i++) {
            GameObject s = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            s.transform.localScale = new Vector3(diameter, diameter, diameter);
            s.transform.position = new Vector3(
                Random.Range(boundBL.x, boundTR.x),
                Random.Range(boundBL.y, boundTR.y),
                0);
            Destroy(s.collider);
            spheres[i] = s;
        }

        int length = spheres.Length;
        float[] radii = new float[length];
        float[] masses = new float[length];
        Vector2[] positions = new Vector2[length];
        Vector2[] velocities = new Vector2[length];
        for (int i = 0; i < length; i++) {
            GameObject sphere = spheres[i];
            float radius = 0.5f * sphere.transform.localScale.x;
            radii[i] = radius;
            masses[i] = mass; //(rho * Mathf.PI * radius);
            positions[i] = new Vector2(
                sphere.transform.position.x, sphere.transform.position.y);
            velocities[i] = Vector2.zero;
        }

        particles.addParticle(masses, radii, positions, velocities);
        for (int i = 0; i < length; i++) {
            spacePartitioner.add(particles.buildAABB(i), i);
        }
    }
Ejemplo n.º 5
0
        //Lưu đơn hàng
        private void btLuuDonHang_Click(object sender, EventArgs e)
        {
            if (CheckNull() == false)
            {
                //CẬP NHẬT NGƯỜI GỬI
                try
                {
                    NGUOIGUI checkNG = (from a in db.NGUOIGUIs where NGCMT.Text == a.CMND select a).SingleOrDefault();
                    if (checkNG == null)
                    {
                        NGUOIGUI NG = new NGUOIGUI();
                        NG.CMND   = NGCMT.Text;
                        NG.DIACHI = NGDiaChi.Text;
                        NG.HOTEN  = NGTen.Text;
                        NG.SDT    = NGSDT.Text;

                        db.NGUOIGUIs.InsertOnSubmit(NG);
                        db.SubmitChanges();
                    }
                    else
                    {
                        NGUOIGUI NG = (from a in db.NGUOIGUIs where NGCMT.Text == a.CMND select a).SingleOrDefault();
                        NG.DIACHI = NGDiaChi.Text;
                        NG.HOTEN  = NGTen.Text;
                        NG.SDT    = NGSDT.Text;
                        db.SubmitChanges();
                    }



                    //CẬP NHẬT NGƯỜI NHẬN
                    NGUOINHAN checkNN = (from a in db.NGUOINHANs where NNCMT.Text == a.CMND select a).SingleOrDefault();
                    if (checkNN == null)
                    {
                        NGUOINHAN NN = new NGUOINHAN();
                        NN.CMND   = NNCMT.Text;
                        NN.DIACHI = NNDiaChi.Text;
                        NN.HOTEN  = NNTen.Text;
                        NN.SDT    = NNSDT.Text;

                        db.NGUOINHANs.InsertOnSubmit(NN);
                        db.SubmitChanges();
                    }
                    else
                    {
                        NGUOINHAN NN = (from a in db.NGUOINHANs where NNCMT.Text == a.CMND select a).SingleOrDefault();
                        NN.DIACHI = NNDiaChi.Text;
                        NN.HOTEN  = NNTen.Text;
                        NN.SDT    = NNSDT.Text;
                        db.SubmitChanges();
                    }



                    //THÊM MẶT HÀNG

                    HANG mathang = new HANG();
                    mathang.MAHANG     = T2MaDonHang.Text;
                    mathang.TRONGLUONG = Convert.ToDouble(T2TrongLuong.Text);
                    mathang.DAI        = Convert.ToDouble(T2Dai.Text);
                    mathang.RONG       = Convert.ToDouble(T2Rong.Text);
                    mathang.CAO        = Convert.ToDouble(T2Cao.Text);
                    mathang.NOIDUNG    = T2Noidung.Text;
                    mathang.GHICHU     = T2Ghichu.Text;

                    db.HANGs.InsertOnSubmit(mathang);
                    db.SubmitChanges();



                    //THÊM PHÍ ĐƠN HÀNG


                    PHIGH phi = new PHIGH();
                    phi.MAPHI = T2MaDonHang.Text;
                    phi.MAPT  = (from a in db.PHUONGTIENs where a.TENPT == T2CbLoaiHinhVanTai.Text select a.MAPT).Single();
                    if (T2PhuPhi.Text != "")
                    {
                        phi.PHUPHI = double.Parse(T2PhuPhi.Text);
                    }
                    else
                    {
                        phi.PHUPHI = 0;
                    }
                    phi.TONGPHI = TinhPhi();
                    if (T2raNG.Checked)
                    {
                        phi.TTPHI = "Đã thanh toán";
                    }
                    else
                    {
                        phi.TTPHI = "Chưa thanh toán";
                    }

                    db.PHIGHs.InsertOnSubmit(phi);
                    db.SubmitChanges();



                    //THÊM HÓA ĐƠN

                    DONHANG newDonHang = new DONHANG();
                    newDonHang.MADH    = T2MaDonHang.Text;
                    newDonHang.MANV    = nv.MANV;
                    newDonHang.CMNDNG  = NGCMT.Text;
                    newDonHang.CMNDNN  = NNCMT.Text;
                    newDonHang.NGAYGUI = DateTime.Today;
                    newDonHang.MAHANG  = T2MaDonHang.Text;
                    newDonHang.MAPHI   = T2MaDonHang.Text;
                    newDonHang.TTHD    = "Chờ vận chuyển";



                    db.DONHANGs.InsertOnSubmit(newDonHang);
                    db.SubmitChanges();


                    DEM dem = (from a in db.DEMs where a.ID == "DH" select a).Single();
                    dem.COUNT++;
                    db.SubmitChanges();

                    XtraMessageBox.Show("Đã thêm đơn hàng " + newDonHang.MADH + " !", "Thêm thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    XemDonHang(true);
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show("Có lỗi trong quá trình thực hiện!", "btLuuDonHang_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    log.Error(ex);
                }
            }
        }