Beispiel #1
0
 private void Check()
 {
     PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
     byte[] arrImgFront = null;
     byte[] arrImgBack = null;
     frontPic.EditValue = null;
     backPic.EditValue = null;
     ImageConverter converter = new ImageConverter();
     var pk = new Execute(pkdata).GetSinglePKIn(txtRFID.Text);
     if (pk != null)
     {
         new Execute(pkdata).getImage(pk.ID, ref arrImgFront, true);
         if (arrImgFront != null)
         {
             Image tmp = (Image)converter.ConvertFrom(arrImgFront);
             frontPic.Image = tmp;
             arrImgFront = null;
         }
         new Execute(pkdata).getImage(pk.ID, ref arrImgBack, false);
         if (arrImgBack != null)
         {
             Image tmp = (Image)converter.ConvertFrom(arrImgBack);
             backPic.Image = tmp;
             arrImgBack = null;
         }
         LoadDataToControl(pk);
         btnOK.Focus();
     }
 }
Beispiel #2
0
 public Execute(PKDataContext dataContext)
 {
     _dataContext = dataContext;
     if (_dataContext.Connection.State == ConnectionState.Closed)
     {
         _dataContext.Connection.Open();
     }
 }
Beispiel #3
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
     var pkOut = new Execute(pkdata).GetSinglePKIn(txtRFID.Text);
     if (pkOut != null)
     {
         new Execute(pkdata).DeleteCard(txtRFID.Text);
         this.Close();
     }
 }
        private void navBarControl_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            DataTable dt = new DataTable();
            frmReportsFilter filter = new frmReportsFilter();
            DataColumn col1 = new DataColumn("fromDate", System.Type.GetType("System.DateTime"));
            dt.Columns.Add(col1);
            DataColumn col2 = new DataColumn("toDate", System.Type.GetType("System.DateTime"));
            dt.Columns.Add(col2);

            DataRow row = dt.NewRow();
            row["fromDate"] = filter.pubFromDate;
            row["toDate"] = filter.pubToDate;
            dt.Rows.Add(row);

            if (e.Link.Item == navItemIn)
            {
                DialogResult dialog = filter.ShowDialog();
                if (dialog == DialogResult.OK)
                {
                    PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
                    rptIn rpt = new rptIn();
                    string fromDate = String.Format("Ngày {0:dd/MM/yyyy}", filter.pubFromDate);
                    string toDate = String.Format("Ngày {0:dd/MM/yyyy}", filter.pubToDate);
                    string fromTime = String.Format("Từ {0:HH:mm}", filter.pubFromTime);
                    string toTime = String.Format("Đến {0:HH:mm}", filter.pubToTime);
                    rpt.xlbFromDate.Text = fromDate;
                    rpt.xlbToDate.Text = toDate;
                    rpt.xlbFromTime.Text = fromTime;
                    rpt.xlbToTime.Text = toTime;
                    rpt.DataSource = new Execute(pkdata).GetAll(filter.pubFromDate, filter.pubToDate);
                    printControl.PrintingSystem = rpt.PrintingSystem;
                    rpt.CreateDocument();
                }
            }
            else if (e.Link.Item == navItemTotal)
            {
                DialogResult dialog = filter.ShowDialog();
                if (dialog == DialogResult.OK)
                {
                    PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
                    rptTotalRevenua rpt = new rptTotalRevenua();
                    string fromDate = String.Format("Ngày {0:dd/MM/yyyy}", filter.pubFromDate);
                    string toDate = String.Format("Ngày {0:dd/MM/yyyy}", filter.pubToDate);
                    string fromTime = String.Format("Từ {0:HH:mm}", filter.pubFromTime);
                    string toTime = String.Format("Đến {0:HH:mm}", filter.pubToTime);
                    rpt.xlbFromDate.Text = fromDate;
                    rpt.xlbToDate.Text = toDate;
                    rpt.xlbFromTime.Text = fromTime;
                    rpt.xlbToTime.Text = toTime;
                    rpt.DataSource = new Execute(pkdata).TotalAmount(filter.pubFromDate, filter.pubToDate);
                    printControl.PrintingSystem = rpt.PrintingSystem;
                    rpt.CreateDocument();
                }
            }
        }
 public void LoadDataToCombo()
 {
     PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
     price = new Execute(pkdata).GetAllPrice();
     if (price.Length > 0)
     {
         cbbVehicleType.Properties.DataSource = price;
         cbbVehicleType.Properties.ValueMember = "ID";
         cbbVehicleType.Properties.DisplayMember = "VehicleType";
     }
 }
Beispiel #6
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     //pk_In_Out pkOut = new pk_In_Out();
     PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
     var pkOut = new Execute(pkdata).GetSinglePKIn(txtRFID.Text);
     if (pkOut != null)
     {
         //LoadDataToControl(pkOut);
         new Execute(pkdata).SavePKOut(pkOut.ID, DateTime.Now);
         LoadDataToGrid();
     }
 }
 private void btnClear_Click(object sender, EventArgs e)
 {
     DialogResult result = XtraMessageBox.Show("Bạn có muốn xóa không?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
     if (result == DialogResult.OK)
     {
         if (cameraId > 0)
         {
             PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
             new Execute(pkdata).DeleteCamera(cameraId);
             LoadDataToGrid();
         }
     }
 }
Beispiel #8
0
        private void btnCheckIDCard_Click(object sender, EventArgs e)
        {
            try
            {
                PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
                //Kiem tra xem thẻ này là thế nào
                //pk_In_Out pkIn = new pk_In_Out();
                var pkIn = new Execute(pkdata).GetSinglePKIn(txtRFID.Text);

                //pk_In_Out pkOut = new pk_In_Out();
                var pkOut = new Execute(pkdata).GetSinglePKOut(txtRFID.Text);
                if (pkIn != null)
                {
                    if (pkIn.IsOut == false)
                    {
                        decimal price = new Execute(pkdata).GetPriceByID(pkIn.VehicleTypeID ?? 0);
                        txtPrice.Text = string.Format("{0}", price);
                        txtNumber.Text = pkIn.Number;
                        teTimeIn.EditValue = pkIn.TimeIn;
                        labelControl1.Enabled = true;
                        labelControl1.Text = "Xe này chưa ra khỏi bãi";
                        btnOK.Enabled = true;
                    }
                }
                if (pkOut != null)
                {
                    if (pkOut.IsOut == true)
                    {
                        //Lấy hết dữ liệu ra --- mới vào chưa ra
                        //Nếu tồn tại ID này đã ra -- có trong danh sách xe đã ra
                        pk_Price pkPice = new pk_Price();
                        decimal price = new Execute(pkdata).GetPriceByID(pkOut.VehicleTypeID ?? 0);
                        txtPrice.Text = string.Format("{0}", price);
                        txtNumber.Text = pkOut.Number;
                        teTimeIn.EditValue = pkOut.TimeIn;
                        teTimeOut.EditValue = pkOut.TimeOut; //xe nay da ra khỏi bãi
                        labelControl1.Enabled = true;
                        labelControl1.Text = "Xe này đã ra khỏi bãi";
                        btnOK.Enabled = false;
                    }
                }

            }

            catch
            {
                MessageBox.Show("Co loi ne");
            }
        }
Beispiel #9
0
 public void LoadDataToCombo()
 {
     try
     {
         PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
         price = new Execute(pkdata).GetAllPrice();
         if (price.Length > 0)
         {
             cbbVehicleType.Properties.DataSource = price;
             cbbVehicleType.Properties.ValueMember = "ID";
             cbbVehicleType.Properties.DisplayMember = "VehicleType";
         }
     }
     catch
     {
         MessageBox.Show("Lỗi kết nối", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
 }
Beispiel #10
0
 private void LoadDataToGrid()
 {
     PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
     pk_In_Out[] PakingIn = new Execute(pkdata).GetAllPKOut(0, 20);
     grcOut.BeginUpdate();
     grcOut.DataSource = PakingIn;
     grcOut.EndUpdate();
 }
Beispiel #11
0
 private void frmLineOut_Activated(object sender, EventArgs e)
 {
     clsDeclare.eventComPort1.LfDataReceived += new LfDataReceivedEventHandler(eventComPort1_LfDataReceived);
     LoadDataToGrid();
     PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
     pk_Camera[] cams = new Execute(pkdata).GetAllCameras();
     foreach (pk_Camera cam in cams)
     {
         if (cam.areaId == 2)
         {
             string[] sourceIP = cam.source.Split(':');
             OpenCamera(cam.position, cam.login, cam.password, sourceIP[0], sourceIP[1]);
         }
     }
 }
Beispiel #12
0
 private void grvOut_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
     DataRow row = grvOut.GetDataRow(grvOut.FocusedRowHandle);
     byte[] arrImgFront = null;
     byte[] arrIgmBack = null;
     ImageConverter converter = new ImageConverter();
     if (row != null)
     {
         new Execute(pkdata).getImage((Guid)row["ID"], ref arrImgFront, true);
         new Execute(pkdata).getImage((Guid)row["ID"], ref arrIgmBack, false);
         if (arrImgFront != null)
         {
             Image tmp = (Image)converter.ConvertFrom(arrImgFront);
             frontPic.Image = tmp;
             arrImgFront = null;
         }
         else
         {
             frontPic.Image = null;
         }
         if (arrIgmBack != null)
         {
             Image tmp = (Image)converter.ConvertFrom(arrIgmBack);
             backPic.Image = tmp;
             arrIgmBack = null;
         }
         else
             backPic.Image = null;
     }
 }
Beispiel #13
0
 private void frmSearch_Load(object sender, EventArgs e)
 {
     PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
     list = new Execute(pkdata).GetAll().ToList();
     chkRFID.Checked = true;
     txtNumber.Enabled = false;
     fromDate.Enabled = false;
     fromTime.Enabled = false;
     toDate.Enabled = false;
     toTime.Enabled = false;
     fromDate.EditValue = DateTime.Now;
     toDate.EditValue = DateTime.Now;
     fromTime.EditValue = DateTime.Now;
     toTime.EditValue = DateTime.Now;
 }
Beispiel #14
0
        private void Finder(string RFID, string Number, DateTime fromDate, DateTime toDate)
        {
            PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
            var result = new Execute(pkdata).Search(RFID, Number, fromDate, toDate, isOut, isRFID, isNumber, isDate);
            grcOut.DataSource = null;
            frontPic.Image = null;
            backPic.Image = null;

            if (result != null)
            {
                LoadDataToGrid(result);
            }
        }
        private void Save()
        {
            PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
            if (txtRFIDIn.EditValue != null && cbbVehicleType.EditValue != null)
            {

                if (new Execute(pkdata).HasObject(txtRFIDIn.Text))
                {
                    MessageBox.Show("Thẻ này chưa ra ngoài", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                Guid ID = new Execute(pkdata).SavePKIn(txtRFIDIn.Text, txtNumberIn.Text, DateTime.Now, Convert.ToInt32(cbbVehicleType.EditValue));
                if (imgIn != null)
                {
                    new Execute(pkdata).setImage(ID, (byte[])imgIn, false);

                    MemoryStream ms = new MemoryStream((byte[])imgIn);
                    Image returnImage = Image.FromStream(ms);
                    picIn.Image = returnImage;
                }
                LoadDataToGrid();
            }
        }
Beispiel #16
0
        private void LoadDataToGrid()
        {
            PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
            IEnumerable<pk_Camera> cam_ = new Execute(pkdata).IECamera();
            DataTable dt = new DataTable();
            dt = clsDeclare.ObtainDataTableFromIEnumerable(cam_);
            if (dt.Rows.Count > 0)
            {
                DataView dv = new DataView(dt);
                if (dv != null)
                {
                    grcCameras.BeginUpdate();
                    grcCameras.DataSource = dv;
                    grcCameras.EndUpdate();
                }
                grvCameras.ExpandAllGroups();
            }
            else
            {
                grcCameras.BeginUpdate();
                grcCameras.DataSource = null;
                grcCameras.EndUpdate();

                cbbSize.SelectedIndex = 0;
                cbbArea.SelectedIndex = 0;
                cbbPosition.SelectedIndex = 0;
                cbbProvider.SelectedIndex = 0;
                cbbQuality.SelectedIndex = 0;
                cbbType.SelectedIndex = 0;
            }
        }
Beispiel #17
0
        private void Save()
        {
            try
            {
                if (txtRFID.EditValue != null && cbbVehicleType.EditValue != null)
                {
                    PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
                    if (new Execute(pkdata).HasObject(txtRFID.Text))
                    {
                        MessageBox.Show("Thẻ này chưa ra ngoài", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    Guid ID = new Execute(pkdata).SavePKIn(txtRFID.Text, txtNumber.Text, DateTime.Now, Convert.ToInt32(cbbVehicleType.EditValue));

                    if (imgIn != null)
                    {
                        new Execute(pkdata).setImage(ID, (byte[])imgIn, true);
                        frontPic.EditValue = ConvertToBitmap((byte[])imgIn);
                        imgIn = null;
                    }
                    if (imgOut != null)
                    {
                        new Execute(pkdata).setImage(ID, (byte[])imgOut, false);
                        backPic.EditValue = ConvertToBitmap((byte[])imgOut);
                        imgOut = null;
                    }
                    LoadDataToGrid();
                }
            }
            catch
            {
                MessageBox.Show("Lỗi kết nối", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Beispiel #18
0
 private void LoadDataToGrid()
 {
     try
     {
         PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
         pk_In_Out[] PakingIn = new Execute(pkdata).GetAllPKIn(0, 20);
         grcIn.BeginUpdate();
         grcIn.DataSource = PakingIn;
         grcIn.EndUpdate();
     }
     catch
     {
         MessageBox.Show("Lỗi kết nối", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
 }
Beispiel #19
0
 private void frmLineIn_Activated(object sender, EventArgs e)
 {
     try
     {
         PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
         clsDeclare.eventComPort1.LfDataReceived += new LfDataReceivedEventHandler(eventComPort1_LfDataReceived);
         LoadDataToGrid();
         LoadDataToCombo();
         pk_Camera[] cams = new Execute(pkdata).GetAllCameras();
         foreach (pk_Camera cam in cams)
         {
             if (cam.areaId == 1)
             {
                 string[] sourceIP = cam.source.Split(':');
                 OpenCamera(cam.position, cam.login, cam.password, sourceIP[0], sourceIP[1]);
             }
         }
     }
     catch
     {
         MessageBox.Show("Lỗi kết nối", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #20
0
 private void Save()
 {
     PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
     if (isAddNew)
     {
         string source = String.Format("{0}:{1}", txtIP.Text, txtPort.Text);
         int type = Convert.ToInt32(cbbType.EditValue);
         new Execute(pkdata).SaveCamera(txtCameraName.Text, cbbProvider.EditValue.ToString(), txtDescription.Text, source, txtUser.Text, txtPassword.Text, cbbSize.EditValue.ToString(), type.ToString(), cbbQuality.EditValue.ToString(), txtInterval.Text, Convert.ToBoolean(cbbArea.EditValue), Convert.ToBoolean(cbbPosition.EditValue), Convert.ToInt32(cbbArea.EditValue.ToString()));
         LoadDataToGrid();
     }
     else
     {
         string source = String.Format("{0}:{1}", txtIP.Text, txtPort.Text);
         int type = Convert.ToInt32(cbbType.EditValue);
         new Execute(pkdata).EditCamera(cameraId, txtCameraName.Text, cbbProvider.EditValue.ToString(), txtDescription.Text, source, txtUser.Text, txtPassword.Text, cbbSize.EditValue.ToString(), type.ToString(), cbbQuality.EditValue.ToString(), txtInterval.Text, Convert.ToBoolean(cbbArea.EditValue), Convert.ToBoolean(cbbPosition.EditValue), Convert.ToInt32(cbbArea.EditValue));
         LoadDataToGrid();
     }
     XtraMessageBox.Show("Thành công", "Thông báo");
     btnSave.Enabled = false;
     btnEdit.Enabled = true;
     btnAdd.Enabled = true;
     btnClear.Enabled = true;
 }
 private void LoadDataToGrid()
 {
     PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
     IEnumerable<pk_Price> price = new Execute(pkdata).IEPrice();
     if (price != null)
     {
         DataTable dt = new DataTable();
         dt = clsDeclare.ObtainDataTableFromIEnumerable(price);
         if (dt.Rows.Count > 0)
         {
             DataView dv = new DataView(dt);
             if (dv != null)
             {
                 grcVehicles.BeginUpdate();
                 grcVehicles.DataSource = dv;
                 grcVehicles.EndUpdate();
             }
         }
     }
 }
        private void Save()
        {
            PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
            if (txtTypeVehicles.EditValue == null || txtPrice.EditValue == null)
            {
                return;
            }
            if (isAddNew)
            {
                new Execute(pkdata).SavePrice(txtTypeVehicles.EditValue.ToString(), Convert.ToDecimal(txtPrice.EditValue), Convert.ToString(txtNote.EditValue));
                LoadDataToGrid();
            }
            else
            {
                if (ID > 0)
                {

                    new Execute(pkdata).EditPrice(ID, txtTypeVehicles.EditValue.ToString(), Convert.ToDecimal(txtPrice.EditValue), txtNote.EditValue.ToString());
                    LoadDataToGrid();
                }
            }
            btnSave.Enabled = false;
            btnEdit.Enabled = true;
            btnAdd.Enabled = true;
            btnClear.Enabled = true;
        }
 private void Check()
 {
     PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
     byte[] arrImgFront = null;
     picOut.EditValue = null;
     ImageConverter con = new ImageConverter();
     var pk = new Execute(pkdata).GetSinglePKIn(txtRFIDOut.Text);
     if (pk != null)
     {
         new Execute(pkdata).getImage(pk.ID, ref arrImgFront, false);
         if (arrImgFront != null)
         {
             Image tmp = (Image)con.ConvertFrom(arrImgFront);
             picOut.Image = tmp;
             arrImgFront = null;
         }
         txtNumberOut.Text = pk.Number.ToString();
         txtPriceOut.Text = String.Format("{0:##,##00}", pk.Price);
         teTimeIn.EditValue = pk.TimeIn;
         teTimeOut.EditValue = DateTime.Now;
     }
 }