Example #1
0
        /// <summary>
        /// Fills SupplierCode From
        /// </summary>
        private void FillSuppFromList()
        {
            string[] orderBy = { "SupplierCode" };
            string   sql     = " Retired = 0";

            SupplierEx.LoadCombo(ref cboSuppFrom, "SupplierCode", false, false, "", sql, orderBy);
        }
Example #2
0
        private bool IsValid()
        {
            bool result = true;

            #region Supplier Code 唔可以吉
            errorProvider.SetError(txtSupplierCode, string.Empty);
            if (txtSupplierCode.Text.Length == 0)
            {
                errorProvider.SetError(txtSupplierCode, "Cannot be blank!");
                errorProvider.SetIconAlignment(txtSupplierCode, ErrorIconAlignment.TopLeft);
                return(false);
            }
            #endregion

            #region 新增,要 check Supplier Code 係咪 in use
            errorProvider.SetError(txtSupplierCode, string.Empty);
            if (_SupplierId == Guid.Empty)
            {
                if (SupplierEx.IsSupplierCodeInUse(txtSupplierCode.Text.Trim()))
                {
                    errorProvider.SetError(txtSupplierCode, "Supplier Code in use");
                    errorProvider.SetIconAlignment(txtSupplierCode, ErrorIconAlignment.TopLeft);
                    return(false);
                }
            }
            #endregion

            return(result);
        }
Example #3
0
        /// <summary>
        /// Fills the supplier to list.
        /// </summary>
        private void FillToList()
        {
            string[] orderBy = { "SupplierCode" };
            string   sql     = " Retired = 0 ";

            SupplierEx.LoadCombo(ref cboTo, "SupplierCode", false, false, "", sql, orderBy);
            cboTo.SelectedIndex = cboTo.Items.Count - 1;
        }
        /// <summary>
        /// Fills SupplierNumber To
        /// </summary>
        private void FillSuppToList()
        {
            SupplierEx.LoadCombo(ref cboSupplierTo, "SupplierCode", false, false, string.Empty, " Retired = 0");

            if (cboSupplierTo.Items.Count > 0)
            {
                cboSupplierTo.SelectedIndex = cboSupplierTo.Items.Count - 1;
            }
        }
Example #5
0
 private void FillComboBox()
 {
     SupplierEx.LoadCombo(ref cmbFrom, "SupplierCode", false);
     SupplierEx.LoadCombo(ref cmbTo, "SupplierCode", false);
     cmbTo.SelectedIndex = cmbTo.Items.Count - 1;
 }
Example #6
0
 private void FillSupplierList()
 {
     SupplierEx.LoadCombo(ref cboSupplier, "SupplierCode", false);
 }
 /// <summary>
 /// Fills SupplierCode From
 /// </summary>
 private void FillSuppFromList()
 {
     SupplierEx.LoadCombo(ref cboSupplierFrom, "SupplierCode", false, false, string.Empty, " Retired = 0");
 }
Example #8
0
        private int Import()
        {
            int result = 0;

            using (var ctx = new EF6.RT2020Entities())
            {
                using (var scope = ctx.Database.BeginTransaction())
                {
                    try
                    {
                        for (int i = 0; i < md.Length; i++)
                        {
                            string txNumber = SystemInfoHelper.Settings.QueuingTxNumber(EnumHelper.TxType.CAP);

                            #region Guid headerId = ImportCAPHeader(md[i].Master as CAPTxtIEMaster, txNumber);
                            CAPTxtIEMaster master = md[i].Master as CAPTxtIEMaster;

                            var oHeader = new EF6.InvtBatchCAP_Header();
                            oHeader.HeaderId     = Guid.NewGuid();
                            oHeader.TxType       = EnumHelper.TxType.CAP.ToString();
                            oHeader.TxNumber     = txNumber;
                            oHeader.TxDate       = master.RecvDate;
                            oHeader.WorkplaceId  = WorkplaceEx.GetWorkplaceIdByCode(master.Location);
                            oHeader.StaffId      = StaffEx.GetStaffIdByStaffNumber(master.Operator);
                            oHeader.SupplierId   = SupplierEx.GetSupplierIdBySupplierCode(master.Supplier);
                            oHeader.Status       = Convert.ToInt32(EnumHelper.Status.Draft.ToString("d"));
                            oHeader.Reference    = master.RefNumber;
                            oHeader.Remarks      = master.Remarks;
                            oHeader.CurrencyCode = "HKD";
                            oHeader.ExchangeRate = (decimal)1;

                            oHeader.CreatedBy  = ConfigHelper.CurrentUserId;
                            oHeader.CreatedOn  = DateTime.Now;
                            oHeader.ModifiedBy = ConfigHelper.CurrentUserId;
                            oHeader.ModifiedOn = DateTime.Now;

                            ctx.InvtBatchCAP_Header.Add(oHeader);
                            ctx.SaveChanges();

                            Guid headerId = oHeader.HeaderId;
                            #endregion

                            decimal ttlAmt = 0;
                            #region decimal ttlAmt = ImportCAPDetails(md[i].Details, headerId, txNumber);
                            object[] details = md[i].Details;
                            if (details != null)
                            {
                                for (int j = 0; j < details.Length; j++)
                                {
                                    CAPTxtIEDetails detail = details[j] as CAPTxtIEDetails;
                                    Guid            prodId = GetProductId(detail);

                                    if (prodId != Guid.Empty)
                                    {
                                        var oDetail = new EF6.InvtBatchCAP_Details();
                                        oDetail.DetailsId  = Guid.NewGuid();
                                        oDetail.ProductId  = prodId;
                                        oDetail.HeaderId   = headerId;
                                        oDetail.LineNumber = j + 1;
                                        oDetail.TxNumber   = txNumber;
                                        oDetail.TxType     = EnumHelper.TxType.CAP.ToString();
                                        oDetail.Qty        = detail.ReceivedQty;
                                        oDetail.UnitAmount = detail.ReceivedUnitAmount;
                                        oDetail.UnitAmountInForeignCurrency = detail.ReceivedUnitAmount;

                                        ctx.InvtBatchCAP_Details.Add(oDetail);
                                        ctx.SaveChanges();

                                        ttlAmt += oDetail.Qty.Value * oDetail.UnitAmount.Value;
                                    }
                                    else
                                    {
                                        string skippedProduct = String.Format("?{0} {1} {2} {3}",
                                                                              detail.StockCode, detail.Appendix1, detail.Appendix2, detail.Appendix3);
                                        skippedList.Add(skippedProduct);
                                    }
                                }
                            }
                            #endregion

                            oHeader = ctx.InvtBatchCAP_Header.Find(headerId);
                            if (oHeader != null)
                            {
                                oHeader.TotalAmount = ttlAmt;
                                ctx.SaveChanges();

                                UpdateListView(i, txNumber);

                                skippedList.Clear();
                            }

                            result++;
                        }
                        scope.Commit();
                    }
                    catch (Exception ex)
                    {
                        scope.Rollback();
                    }
                }
            }

            return(result);
        }