コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            ShipmentEntity    shipment    = new ShipmentEntity();
            ShipmentOutEntity shipmentout = new ShipmentOutEntity();

            if (String.IsNullOrWhiteSpace(txtShipment.Text) || String.IsNullOrWhiteSpace(txtShipment.Text))
            {
                MessageBox.Show("Bạn phải nhập mã đơn hàng để tìm kiếm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            try
            {
                string input = txtShipment.Text.Trim().ToUpper();
                lblTitle.Text = input;
                // Shipment out
                shipmentout = _shipmentOutServices.GetByShipmentId(input);
                if (shipmentout != null)
                {
                    lblShipment.Text = "Thông tin xuất kho: " + shipmentout.MasterBillIdString + System.Environment.NewLine + shipmentout.BoxIdString + "(" + shipmentout.DateOut.ToString("d MMM yyyy") + ")";
                }
                // Shipment in
                shipment = _repositoryShipment.GetShipment(input);
                if (shipment != null)
                {
                    lblDelivery.Text = "Thông tin đơn hàng: " + shipment.Receiver + " - " + shipment.ReceiverTel + System.Environment.NewLine + "Địa chỉ: " + shipment.Address;
                }
                // Ecuss
                if (_shipmentOutServices.GetStatusCompletion(input))
                {
                    lblEcus.ForeColor = Color.Green;
                    lblEcus.Text      = "Đã thông quan.";
                }
                else
                {
                    lblEcus.ForeColor = Color.OrangeRed;
                    lblEcus.Text      = "Chưa thông quan.";
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #2
0
        private void SaveShipment(string masterBill)
        {
            int countTotal = 0;
            List <BoxIdEntity> listBoxid = repositoryShipment.GetBoxIdByAirwaybill(masterBill);

            if (listBoxid.Count > 0)
            {
                foreach (var box in listBoxid)
                {
                    int            countBox  = 0;
                    BoxInforEntity boxEntity = _boxInforServices.GetByBoxId(box.BoxId);
                    if (boxEntity == null)
                    {
                        boxEntity                  = new BoxInforEntity();
                        boxEntity.BoxId            = box.BoxId;
                        boxEntity.DateCreated      = DateTime.Now;
                        boxEntity.EmployeeId       = currentEmployee.Id;
                        boxEntity.ShipmentQuantity = 0;
                        boxEntity.MasterBillId     = currentMasterBillId;
                        currentBoxIdInt            = _boxInforServices.CreateBoxInfor(boxEntity);
                        boxEntity.Id               = currentBoxIdInt;
                        currentBoxId               = boxEntity.BoxId;
                    }
                    else
                    {
                        currentBoxIdInt = boxEntity.Id;
                        currentBoxId    = boxEntity.BoxId;
                    }
                    List <ManifestEntity> listManifest = new List <ManifestEntity>();
                    listManifest = repositoryShipment.GetManifestByBoxId(box.BoxId);
                    listManifest = listManifest.GroupBy(t => t.ShipmentNo).Select(p => p.First()).ToList();
                    if (listManifest != null && listManifest.Count > 0)
                    {
                        List <ShipmentEntity> listShipment = new List <ShipmentEntity>();
                        foreach (var item in listManifest)
                        {
                            ShipmentEntity shipment = new ShipmentEntity();
                            shipment.Mawb        = item.MasterAirWayBill;
                            shipment.ShipmentId  = item.ShipmentNo;
                            shipment.BoxId       = currentBoxIdInt;
                            shipment.DateCreated = DateTime.Now;
                            shipment.EmployeeId  = currentEmployee.Id;
                            shipment.WarehouseId = FormLogin.mWarehouse.Id;
                            shipment.Address     = item.Address;
                            shipment.BoxIdString = item.BoxID;
                            if (_shipmentOutServices.GetStatusCompletion(item.ShipmentNo))
                            {
                                shipment.Status = "Clearance";
                            }
                            else
                            {
                                shipment.Status = "Check";
                            }
                            shipment.Content       = item.Content;
                            shipment.Country       = item.Country;
                            shipment.DeclarationNo = item.DeclarationNo;
                            shipment.Destination   = item.Destination;
                            shipment.NumberPackage = 1;
                            shipment.TotalValue    = item.TotalValue;
                            shipment.Sender        = item.CompanyName;
                            shipment.Consignee     = item.Destination;
                            shipment.Receiver      = item.ContactName;
                            shipment.Weight        = Math.Round(item.Weight, 3);
                            shipment.ReceiverTel   = item.Tel;
                            listShipment.Add(shipment);
                        }
                        countBox = repositoryShipment.CreateShipment(listShipment);
                        if (countBox > 0)
                        {
                            countTotal += countBox;
                            _boxInforServices.CreateOrUpdateByQuery(countBox, boxEntity.Id);
                        }
                    }
                }
                MessageBox.Show("Đã xác nhận đến thành công!\nTổng số đơn hàng là " + countTotal, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #3
0
        private void txtShipmentIdOut_KeyDown(object sender, KeyEventArgs e)
        {
            string         shipmentinput = txtShipmentIdOut.Text.Trim().ToUpper();
            ShipmentEntity shipment      = new ShipmentEntity();

            try
            {
                if (e.KeyCode == Keys.Tab || e.KeyCode == Keys.Enter)
                {
                    if (String.IsNullOrEmpty(shipmentinput) || String.IsNullOrWhiteSpace(txtShipmentIdOut.Text))
                    {
                        return;
                    }
                    if (startProcessing)
                    {
                        return;
                    }
                    startProcessing = true;
                    #region Kiểm tra trùng trên lưới nhập
                    if (IsExistsOnTheGridView(grvShipmentListOut, shipmentinput))
                    {
                        beep7.Play();
                        txtShipmentIdOut.Enabled = false;
                        int             rowIndex = -1;
                        DataGridViewRow row      = grvShipmentListOut.Rows
                                                   .Cast <DataGridViewRow>()
                                                   .Where(r => r.Cells[0].Value.ToString().Equals(shipmentinput))
                                                   .First();
                        rowIndex = row.Index;
                        grvShipmentListOut.Rows[rowIndex].Selected = true;
                        MessageBox.Show("TRÙNG DỮ LIỆU TRÊN LƯỚI !!!\nBạn hãy kiểm tra dữ liệu vừa nhập!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        txtShipmentIdOut.Enabled = true;
                        txtShipmentIdOut.Text    = String.Empty;
                        txtShipmentNo.Text       = "";
                        txtShipmentIdOut.Focus();
                        startProcessing = false;
                        return;
                    }
                    #endregion
                    #region Kiểm tra trùng trên thùng đã xuất
                    if (_repositoryShipment.ShipmentOutExist(shipmentinput))
                    {
                        beep7.Play();
                        txtShipmentIdOut.Enabled = false;
                        MessageBox.Show("TRÙNG DỮ LIỆU TRÊN THÙNG ĐÃ XUẤT KHO !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtShipmentIdOut.Enabled = true;
                        txtShipmentIdOut.Text    = String.Empty;
                        txtShipmentNo.Text       = "";
                        txtShipmentIdOut.Focus();
                        startProcessing = false;
                        return;
                    }
                    #endregion
                    #region Kiểm tra vị trí thùng
                    if (_repositoryShipment.ShipmentExist(shipmentinput))
                    {
                        beep7.Play();
                        manifestnew = new ManifestEntity();
                        manifestnew = _repositoryShipment.GetManifestByShipmentNo(shipmentinput);
                        if (manifestnew.BoxID != cbbBoxIdOut.Text.Trim())
                        {
                            txtShipmentIdOut.Enabled = false;
                            if (MessageBox.Show("LẠC HƯỚNG THÙNG !!! \nDữ liệu bạn nhập có thể nằm ở thùng: " + manifestnew.BoxID + "(" + manifestnew.MasterAirWayBill + ")\nBạn có muốn tiếp tục không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                            {
                                txtShipmentIdOut.Enabled = true;
                                txtShipmentIdOut.Text    = String.Empty;
                                txtShipmentNo.Text       = "";
                                startProcessing          = false;
                                return;
                            }
                        }
                    }
                    #endregion
                    #region Kiểm tra hàng thông quan
                    if (!_shipmentOutServices.GetStatusCompletion(shipmentinput))
                    {
                        beep.Play();
                        txtShipmentIdOut.BackColor = Color.Tomato;
                        if (MessageBox.Show("Hàng chưa được phép thông quan. \nBạn có muốn tiếp tục không ?", "Hàng chưa được phép thông quan", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                        {
                            txtShipmentIdOut.Enabled = true;
                            startProcessing          = false;
                            txtShipmentIdOut.Text    = "";
                            txtShipmentIdOut.Focus();
                            txtShipmentNo.Text         = "";
                            txtShipmentIdOut.BackColor = Color.LightYellow;
                            return;
                        }
                        else
                        {
                            txtShipmentIdOut.BackColor = Color.LightYellow;
                        }
                    }
                    #endregion
                    try
                    {
                        //grvShipmentListOut.Rows.Add(grvShipmentListOut.Rows.Count + 1, shipmentinput, DateTime.Now, Math.Round(manifestnew.Weight, 3));
                        grvShipmentListOut.Rows.Insert(0, shipmentinput, DateTime.Now, Math.Round(manifestnew.Weight, 3));
                        // grvShipmentListOut.FirstDisplayedScrollingRowIndex = grvShipmentListOut.RowCount - 1;
                        grvShipmentListOut.FirstDisplayedScrollingRowIndex = 0;
                        lblShipmentScanedOut.Text = "" + grvShipmentListOut.Rows.Count;
                        numberShipmentOut++;
                        grvShipmentListOut.ClearSelection();
                        grvShipmentListOut.Rows[0].Selected = true;
                        //  grvShipmentListOut.Rows[grvShipmentListOut.Rows.Count - 1].Selected = true;
                        //  AddOneShipmentToGridView(grvShipmentListOut.Rows.Count + 1, shipmentexport, grvShipmentListOut);
                    }
                    catch
                    {
                        startProcessing = false;
                    }
                    ShipmentOutEntity shipmentOut = new ShipmentOutEntity();
                    shipmentOut.ShipmentId         = shipmentinput;
                    shipmentOut.BoxIdRef           = currentBoxOut.Id;
                    shipmentOut.BoxIdString        = currentBoxOut.BoxId;
                    shipmentOut.MasterBillId       = currentMasterOut.Id;
                    shipmentOut.MasterBillIdString = currentMasterOut.MasterAirwayBill;
                    shipmentOut.DateOut            = dtpNgayXuat.Value;
                    shipmentOut.DateCreated        = DateTime.Now;
                    shipmentOut.DateInt            = _repositoryShipment.DateToInt(DateTime.Now);
                    shipmentOut.EmployeeId         = currentEmployee.Id;
                    shipmentOut.WarehouseId        = FormLogin.mWarehouse.Id;
                    shipmentOut.Weight             = Math.Round(Convert.ToDouble(manifestnew.Weight), 3);
                    shipmentOut.DeclarationNo      = _shipmentOutServices.GetDeclarationNo(shipmentinput);
                    shipmentOut.DateOfCompletion   = _shipmentOutServices.GetDateOfCompletion(shipmentinput);
                    shipmentOut.Tel         = manifestnew.Tel;
                    shipmentOut.Address     = manifestnew.Address;
                    shipmentOut.ContactName = manifestnew.ContactName;
                    shipmentOut.CompanyName = manifestnew.CompanyName;
                    shipmentOut.Content     = manifestnew.Content;
                    shipmentOut.Country     = manifestnew.Country;
                    shipmentOut.Destination = manifestnew.Destination;
                    shipmentOut.Original    = manifestnew.Original;
                    shipmentOut.Quantity    = manifestnew.Quantity;
                    shipmentOut.TotalValue  = manifestnew.TotalValue;
                    _repositoryShipment.CreateShipmentOut(shipmentOut);
                    // SaveShipmentOut(grvShipmentListOut.Rows.Count, shipmentOut);
                    ding.Play();
                    txtShipmentIdOut.Text = String.Empty;
                    startProcessing       = false;
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                Ultilities.FileHelper.WriteLog(Ultilities.ExceptionLevel.Function, "txtShipmentIdOut_KeyDown", ex);
                return;
            }
        }