Exemplo n.º 1
0
        private void LoadHeaderInfo()
        {
            if (this.HHTHeaderId != null)
            {
                using (var ctx = new EF6.RT2020Entities())
                {
                    var hhtHeader = ctx.StocktakeHeader_HHT.Where(x => x.HeaderId == this.HHTHeaderId).AsNoTracking().FirstOrDefault();
                    if (hhtHeader != null)
                    {
                        txtTxNumber.Text   = hhtHeader.TxNumber;
                        txtWorkplace.Text  = WorkplaceEx.GetWorkplaceCodeById(hhtHeader.WorkplaceId.Value);
                        txtHHTId.Text      = hhtHeader.HHTId;
                        txtUploadedOn.Text = hhtHeader.UploadedOn.Value.ToString("dd MMM yyyy HH:mm:ss");
                        txtCreatedOn.Text  = hhtHeader.CreatedOn.ToString("dd MMM yyyy HH:mm:ss");
                        txtCreatedBy.Text  = StaffEx.GetStaffNumberById(hhtHeader.CreatedBy);

                        txtTotalLine_HHTData.Text        = hhtHeader.TotalRows.Value.ToString("n0");
                        txtTotalLine_StockTake.Text      = hhtHeader.TotalRows.Value.ToString("n0");
                        txtTotalLine_MissingBarcode.Text = hhtHeader.MissingRows.Value.ToString("n0");

                        txtTotalQty_HHTData.Text        = hhtHeader.TOTALQTY.Value.ToString("n0");
                        txtTotalQty_StockTake.Text      = hhtHeader.TOTALQTY.Value.ToString("n0");
                        txtTotalQty_MissingBarcode.Text = hhtHeader.MissingQty.Value.ToString("n0");

                        LoadDetailsInfo(hhtHeader.HeaderId);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void LoadRplInfo()
        {
            var oHeader = InvtBatchRPL_HeaderEx.Get(this.RplId);

            if (oHeader != null)
            {
                txtTxNumber.Text = oHeader.TxNumber;

                cboFromLocation.Text          = oHeader.FromLocation;
                cboToLocation.Text            = oHeader.ToLocation;
                cboOperatorCode.SelectedValue = oHeader.StaffId;
                cboStatus.Text = (oHeader.Status == 0) ? "HOLD" : "POST";

                dtpTxDate.Value    = oHeader.TxDate.Value;
                dtpTxferDate.Value = oHeader.TXFOn.Value;
                dtpCompDate.Value  = oHeader.CompletedOn.Value;

                txtRemarks.Text = oHeader.Remarks;

                txtLastUpdateOn.Text = DateTimeHelper.DateTimeToString(oHeader.ModifiedOn, false);
                txtLastUpdateBy.Text = StaffEx.GetStaffNumberById(oHeader.ModifiedBy);

                txtTxConfirmed.Text    = oHeader.Confirmed ? "Y" : "N";
                txtConfirmedBy.Text    = StaffEx.GetStaffNumberById(oHeader.ConfirmedBy.Value);
                txtConfirmedOn.Text    = DateTimeHelper.DateTimeToString(oHeader.ConfirmedOn.Value, false);
                txtSpecialRequest.Text = oHeader.SpecialRequest ? "Y" : "N";

                this.tbWizardAction.Buttons[0].Enabled = !oHeader.Confirmed;
                this.tbWizardAction.Buttons[2].Enabled = !oHeader.Confirmed;
                this.tbWizardAction.Buttons[4].Enabled = !oHeader.Confirmed;

                BindRplDetailsInfo();
            }
        }
Exemplo n.º 3
0
        /**
         * private void UpdateHeaderInfo()
         * {
         *  InvtBatchCAP_Header oHeader = InvtBatchCAP_Header.Load(this.REJId);
         *  if (oHeader != null)
         *  {
         *      oHeader.TotalAmount = Convert.ToDecimal(Common.Utility.IsNumeric(txtTotalAmount.Text) ? txtTotalAmount.Text : "0");
         *      oHeader.Save();
         *
         *      // log activity (Update)
         *      RT2020.Controls.Log4net.LogInfo(RT2020.Controls.Log4net.LogAction.Update, oHeader.ToString());
         *  }
         * }
         */
        #endregion

        #region Load REJ Header Info
        private void LoadREJInfo()
        {
            var oHeader = InvtBatchCAP_HeaderEx.Get(this.REJId);

            if (oHeader != null)
            {
                txtTxNumber.Text = oHeader.TxNumber;
                txtTxType.Text   = oHeader.TxType;

                cboWorkplace.SelectedValue    = oHeader.WorkplaceId;
                cboOperatorCode.SelectedValue = oHeader.StaffId;
                cboStatus.Text = (oHeader.Status == 0) ? "HOLD" : "POST";

                dtpRecvDate.Value = oHeader.TxDate.Value;

                cboSupplierList.SelectedValue = oHeader.SupplierId;
                txtSupplierInvoice.Text       = oHeader.SupplierRefernce;
                txtRemarks.Text   = oHeader.Remarks;
                txtRefNumber.Text = oHeader.Reference;

                txtLastUpdateOn.Text = DateTimeHelper.DateTimeToString(oHeader.ModifiedOn, false);
                txtLastUpdateBy.Text = StaffEx.GetStaffNumberById(oHeader.ModifiedBy);

                txtAmendmentRetrict.Text = oHeader.ReadOnly ? "Y" : "N";
                chkAPLink.Checked        = oHeader.LinkToAP;

                txtTotalQty.Text    = InvtBatchCAP_DetailsEx.GetTotalQty(this.REJId).ToString("n0");
                txtTotalAmount.Text = InvtBatchCAP_DetailsEx.GetTotalAmount(this.REJId).ToString("n2");

                this.Text += oHeader.ReadOnly ? " (ReadOnly)" : "";

                BindREJDetailsInfo();
            }
        }
Exemplo n.º 4
0
        private void CreateADJTx(Guid headerId)
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var oBatchHeader = ctx.StockTakeHeader.Find(headerId);
                if (oBatchHeader != null)
                {
                    oBatchHeader.PostedOn = DateTime.Now;
                    ctx.SaveChanges();

                    this.UpdateProduct(oBatchHeader.HeaderId, oBatchHeader.WorkplaceId.Value);

                    // Create Ledger for TxType 'STK'
                    string txNumber_Ledger = SystemInfoHelper.Settings.QueuingTxNumber(EnumHelper.TxType.ADJ);
                    Guid   ledgerHeaderId  = CreateLedgerHeader(txNumber_Ledger, oBatchHeader);
                    CreateLedgerDetails(
                        txNumber_Ledger, ledgerHeaderId, oBatchHeader.HeaderId,
                        StaffEx.GetStaffNumberById(ConfigHelper.CurrentUserId),
                        WorkplaceEx.GetWorkplaceCodeById(oBatchHeader.WorkplaceId.Value)
                        );

                    oBatchHeader.ADJNUM = txNumber_Ledger;
                    ctx.SaveChanges();
                }
            }
        }
Exemplo n.º 5
0
        private void LoadCoreData()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var staff = ctx.Staff.Find(_StaffId);
                if (staff != null)
                {
                    txtInitial.Text             = staff.StaffCode;
                    txtFirstName.Text           = staff.FirstName;
                    txtLastName.Text            = staff.LastName;
                    txtName.Text                = staff.FullName;
                    txtNameChs.Text             = staff.FullName_Chs;
                    txtNameCht.Text             = staff.FullName_Cht;
                    txtPassword.Text            = staff.Password;
                    txtCreationDate.Text        = DateTimeHelper.DateTimeToString(staff.CreatedOn, false);
                    txtLastUpdate.Text          = DateTimeHelper.DateTimeToString(staff.ModifiedOn, false);
                    txtModified.Text            = StaffEx.GetStaffNumberById(staff.ModifiedBy);
                    txtStateOffice.Text         = "";
                    txtStateCounter.Text        = "";
                    cboPosition.SelectedValue   = staff.JobTitleId.HasValue ? staff.JobTitleId.Value : Guid.Empty;
                    cmbStaffGrade.SelectedValue = staff.GroupId.HasValue ? staff.GroupId.Value : Guid.Empty;
                    cboDeptCode.SelectedValue   = staff.DeptId.HasValue ? staff.DeptId.Value : Guid.Empty;

                    #region txtStateOffice.Text
                    if (staff.DownloadToPOS)
                    {
                        if (staff.CreatedOn.Date.Equals(staff.ModifiedOn.Date))
                        {
                            txtStateOffice.Text = "A";
                        }
                        else
                        {
                            txtStateOffice.Text = "M";
                        }
                    }
                    #endregion

                    #region txtStateCounter.Text
                    if (staff.DownloadToCounter)
                    {
                        if (staff.CreatedOn.Date.Equals(staff.ModifiedOn.Date))
                        {
                            txtStateCounter.Text = "A";
                        }
                        else
                        {
                            txtStateCounter.Text = "M";
                        }
                    }
                    #endregion
                }
            }
        }
Exemplo n.º 6
0
        private string BuildLog()
        {
            StringBuilder log = new StringBuilder();

            log.Append("COMPANY: ").Append(SystemInfoEx.CurrentInfo.Default.CompanyName).AppendLine();
            log.Append("MONTH: ").Append(SystemInfoEx.CurrentInfo.Default.CurrentSystemDate.ToString("MMMM yyyy")).AppendLine();
            log.Append("Reset Service Item's CDQty = 0: ").Append(ResetSerivceItemsCDQty ? "YES" : "NO").AppendLine();
            log.Append("USER: "******"START TIME: ").Append(StartOn.ToString("dd/MM/yyyy HH:mm:ss")).AppendLine();
            log.Append("STOP TIME: ").Append(EndOn.ToString("dd/MM/yyyy HH:mm:ss")).AppendLine();
            log.Append("RESULT: ").Append(PostedErrorMsg).AppendLine();

            return(log.ToString());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Loads this instance.
        /// </summary>
        private void LoadHeader()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var oHeader = ctx.PriceManagementBatchHeader.Find(this.HeaderId);
                if (oHeader != null)
                {
                    txtTxNumber.Text = oHeader.TxNumber;

                    dtpEffectiveDate.Value      = oHeader.EffectDate.Value;
                    cboReasonCode.SelectedValue = oHeader.ReasonId;
                    txtRemarks.Text             = oHeader.Remarks;

                    txtModifiedOn.Text = DateTimeHelper.DateTimeToString(oHeader.ModifiedOn.Value, true);
                    txtModifiedBy.Text = StaffEx.GetStaffNumberById(oHeader.ModifiedBy);
                    txtCreatedOn.Text  = DateTimeHelper.DateTimeToString(oHeader.CreatedOn.Value, true);
                }
            }
        }
Exemplo n.º 8
0
        private void LoadData()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.PromotionPaymentFactor.Find(_CampaignId);
                if (item != null)
                {
                    cboWorkplace.SelectedValue = item.WorkplaceId.HasValue ? item.WorkplaceId : Guid.Empty;
                    cboTender.SelectedValue    = item.TypeId.HasValue ? item.TypeId : Guid.Empty;
                    txtEventCode.Text          = item.EventCode;
                    txtFactorRate.Text         = item.FactorRate.ToString("n2");
                    dtpStartDate.Value         = item.StartOn.HasValue ? item.StartOn.Value : DateTimeHelper.DateZero();
                    dtpEndDate.Value           = item.EndOn.HasValue ? item.EndOn.Value : DateTimeHelper.DateZero();

                    txtCreatedOn.Text     = DateTimeHelper.DateTimeToString(item.CreatedOn, false);
                    txtLastUpdatedBy.Text = StaffEx.GetStaffNumberById(item.ModifiedBy);
                    txtLastUpdatedOn.Text = DateTimeHelper.DateTimeToString(item.ModifiedOn, false);
                }
            }
        }
Exemplo n.º 9
0
        private void LoadCoreData()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.Supplier.Find(_SupplierId);
                if (item != null)
                {
                    //txtSupplierCode.Text = oSupplier.SupplierCode;
                    txtInitial.Text = item.SupplierInitial;
                    txtName.Text    = item.SupplierName;
                    txtNameChs.Text = item.SupplierName_Chs;
                    txtNameCht.Text = item.SupplierName_Cht;
                    txtRemarks.Text = item.Remarks;

                    cboMarketSector.SelectedValue = item.MarketSectorId.HasValue ? item.MarketSectorId : Guid.Empty;

                    txtLastUpdatedBy.Text = StaffEx.GetStaffNumberById(item.ModifiedBy);
                    txtLastUpdatedOn.Text = DateTimeHelper.DateTimeToString(item.ModifiedOn, false);
                    txtCreatedon.Text     = DateTimeHelper.DateTimeToString(item.CreatedOn, false);
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates the ledger details.
        /// </summary>
        /// <param name="headerId">The header id.</param>
        /// <param name="subLedgerHeaderId">The sub ledger header id.</param>
        private void CreateLedgerDetails(Guid headerId, Guid subLedgerHeaderId, DateTime txDate, Guid workplaceId)
        {
            string query = "HeaderId = '" + subLedgerHeaderId.ToString() + "'";

            using (var ctx = new EF6.RT2020Entities())
            {
                var detailList = ctx.InvtSubLedgerADJ_Details.Where(x => x.HeaderId == subLedgerHeaderId);
                foreach (var detail in detailList)
                {
                    //InvtSubLedgerADJ_Details detail = detailList[i];
                    //if (detail != null)
                    //{
                    query = "HeaderId = '" + headerId.ToString() + "' AND ProductId = '" + detail.ProductId.ToString() + "'";
                    var objDetail = ctx.InvtLedgerDetails.Where(x => x.HeaderId == headerId && x.ProductId == detail.ProductId).FirstOrDefault();
                    if (objDetail == null)
                    {
                        objDetail             = new EF6.InvtLedgerDetails();
                        objDetail.DetailsId   = Guid.NewGuid();
                        objDetail.HeaderId    = headerId;
                        objDetail.TxType      = detail.TxType;
                        objDetail.TxNumber    = detail.TxNumber;
                        objDetail.LineNumber  = 0;
                        objDetail.ProductId   = detail.ProductId;
                        objDetail.SHOP        = WorkplaceEx.GetWorkplaceCodeById(workplaceId);
                        objDetail.TxDate      = txDate;
                        objDetail.OPERATOR    = StaffEx.GetStaffNumberById(ConfigHelper.CurrentUserId);
                        objDetail.Qty         = detail.Qty;
                        objDetail.AverageCost = detail.AverageCost;
                        objDetail.UnitAmount  = detail.AverageCost;
                        objDetail.Amount      = detail.AverageCost * detail.Qty;

                        ctx.InvtLedgerDetails.Add(objDetail);
                    }
                    //}
                }
            }
        }
Exemplo n.º 11
0
        private void LoadAppendix3()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.ProductAppendix3.Where(x => x.Appendix3Id == _AppendixId).AsNoTracking().FirstOrDefault();
                if (item != null)
                {
                    FillParentAppendixList();

                    txtCode.Text    = item.Appendix3Code;
                    txtInitial.Text = item.Appendix3Initial;
                    txtName.Text    = item.Appendix3Name;
                    txtNameChs.Text = item.Appendix3Name_Chs;
                    txtNameCht.Text = item.Appendix3Name_Cht;
                    cboParentAppendix.SelectedValue = item.ParentAppendix.HasValue ? item.ParentAppendix : Guid.Empty;

                    txtLastUpdatedOn.Text = DateTimeHelper.DateTimeToString(item.ModifiedOn, false);
                    txtCreatedOn.Text     = DateTimeHelper.DateTimeToString(item.CreatedOn, false);
                    txtLastUpdatedBy.Text = StaffEx.GetStaffNumberById(item.ModifiedBy);

                    SetCtrlEditable();
                }
            }
        }
Exemplo n.º 12
0
        private void Confirmation()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                using (var scope = ctx.Database.BeginTransaction())
                {
                    try
                    {
                        var oHeader = ctx.InvtBatchTXF_Header.Find(this.TxferId);
                        if (oHeader != null)
                        {
                            var txnumber_Batch = oHeader.TxNumber;

                            #region SaveTxferDetail();
                            foreach (ListViewItem listItem in lvDetailsList.Items)
                            {
                                Guid detailId  = Guid.Empty;
                                Guid productId = Guid.Empty;
                                if (Guid.TryParse(listItem.Text.Trim(), out detailId) && Guid.TryParse(listItem.SubItems[10].Text.Trim(), out productId))
                                {
                                    //Guid detailId = new Guid(listItem.Text.Trim());
                                    var oDetail = ctx.InvtBatchTXF_Details.Find(detailId);
                                    if (oDetail != null)
                                    {
                                        oDetail.QtyConfirmed = Convert.ToDecimal(listItem.SubItems[9].Text.Length == 0 ? "0" : listItem.SubItems[9].Text);

                                        ctx.SaveChanges();
                                    }

                                    var oLedgerDetail = ctx.InvtLedgerDetails.Find(detailId);
                                    if (oLedgerDetail != null)
                                    {
                                        oLedgerDetail.CONFIRM_TRF_QTY = Convert.ToDecimal(listItem.SubItems[9].Text.Length == 0 ? "0" : listItem.SubItems[9].Text);

                                        var oSubLedgerDetail = ctx.InvtSubLedgerTXF_Details.Find(oLedgerDetail.SubLedgerDetailsId);
                                        if (oSubLedgerDetail != null)
                                        {
                                            oSubLedgerDetail.QtyConfirmed = Convert.ToDecimal(listItem.SubItems[9].Text.Length == 0 ? "0" : listItem.SubItems[9].Text);
                                        }

                                        ctx.SaveChanges();
                                    }

                                    var oFepDetail = ctx.FepBatchDetail.Find(detailId);
                                    if (oFepDetail != null)
                                    {
                                        oFepDetail.CONFIRM_TRF_QTY = Convert.ToDecimal(listItem.SubItems[9].Text.Length == 0 ? "0" : listItem.SubItems[9].Text);

                                        ctx.SaveChanges();
                                    }

                                    if (listItem.SubItems[9].Text.Trim().CompareTo(listItem.SubItems[8].Text.Trim()) == 0)
                                    {
                                        this.IsConfirmedTransaction = "Y";
                                    }
                                    else
                                    {
                                        this.IsConfirmedTransaction = "N";
                                    }
                                }
                            }
                            #endregion

                            // Update TXF SubLedger
                            #region UpdateTXFSubLedger(oHeader.TxNumber);
                            var oSubTXF = ctx.InvtSubLedgerTXF_Header.Find(this.TxferId);
                            if (oSubTXF != null)
                            {
                                #region UpdateTXFSubLedgerDetail(oSubTXF.HeaderId);
                                var subLedgerHeaderId = oSubTXF.HeaderId;
                                foreach (ListViewItem listItem in lvDetailsList.Items)
                                {
                                    Guid    productId = Guid.Empty;
                                    decimal qty       = 0;
                                    if (Guid.TryParse(listItem.SubItems[10].Text, out productId))
                                    {
                                        //string sql = "HeaderId = '" + subledgerHeaderId.ToString() + "' AND ProductId = '" + listItem.SubItems[10].Text + "'";
                                        var oSubLedgerDetail = ctx.InvtSubLedgerTXF_Details.Where(x => x.HeaderId == subLedgerHeaderId && x.ProductId == productId).FirstOrDefault();
                                        if (oSubLedgerDetail != null)
                                        {
                                            if (decimal.TryParse(listItem.SubItems[9].Text, out qty))
                                            {
                                                oSubLedgerDetail.QtyConfirmed = qty;

                                                ctx.SaveChanges();
                                            }
                                        }
                                    }
                                }
                                #endregion

                                oSubTXF.CONFIRM_TRF            = this.IsConfirmedTransaction;
                                oSubTXF.CONFIRM_TRF_LASTUPDATE = DateTime.Now;
                                oSubTXF.CONFIRM_TRF_LASTUSER   = ConfigHelper.CurrentUserId;

                                oSubTXF.ModifiedBy = ConfigHelper.CurrentUserId;
                                oSubTXF.ModifiedOn = DateTime.Now;

                                ctx.SaveChanges();
                            }
                            #endregion

                            // Update Ledger
                            #region UpdateLedger(oHeader.TxNumber);
                            var oLedgerHeader = ctx.InvtLedgerHeader.Find(this.TxferId);
                            if (oLedgerHeader != null)
                            {
                                #region UpdateLedgerDetails(oLedgerHeader.HeaderId);
                                var ledgerHeaderId = oLedgerHeader.HeaderId;
                                foreach (ListViewItem listItem in lvDetailsList.Items)
                                {
                                    Guid    productId = Guid.Empty;
                                    decimal qty       = 0;
                                    if (Guid.TryParse(listItem.SubItems[10].Text, out productId))
                                    {
                                        //string sql = "HeaderId = '" + ledgerHeaderId.ToString() + "' AND ProductId = '" + listItem.SubItems[10].Text + "'";
                                        var oLedgerDetail = ctx.InvtLedgerDetails.Where(x => x.HeaderId == ledgerHeaderId && x.ProductId == productId).FirstOrDefault();
                                        if (oLedgerDetail != null)
                                        {
                                            if (decimal.TryParse(listItem.SubItems[9].Text, out qty))
                                            {
                                                oLedgerDetail.Qty = qty;

                                                ctx.SaveChanges();
                                            }
                                        }
                                    }
                                }
                                #endregion

                                oLedgerHeader.CONFIRM_TRF            = this.IsConfirmedTransaction;
                                oLedgerHeader.CONFIRM_TRF_LASTUPDATE = DateTime.Now;
                                oLedgerHeader.CONFIRM_TRF_LASTUSER   = StaffEx.GetStaffNumberById(ConfigHelper.CurrentUserId);

                                oLedgerHeader.ModifiedBy = ConfigHelper.CurrentUserId;
                                oLedgerHeader.ModifiedOn = DateTime.Now;
                                ctx.SaveChanges();
                            }
                            #endregion

                            // Update Product Info
                            #region UpdateProduct(oHeader);
                            var headerId = oHeader.HeaderId;
                            var fromId   = oHeader.FromLocation.Value;
                            var toId     = oHeader.ToLocation.Value;

                            //string sql = "HeaderId = '" + oBatchHeader.HeaderId.ToString() + "'";
                            var detailsList = ctx.InvtBatchTXF_Details.Where(x => x.HeaderId == headerId);
                            foreach (var detail in detailsList)
                            {
                                //InvtBatchTXF_Details detail = detailsList[i];

                                Guid    productId = detail.ProductId.Value;
                                decimal qty       = 0;
                                //Out
                                #region UpdateProductQty(detail.ProductId.Value, fromId, detail.QtyConfirmed.Value * (-1));
                                qty = detail.QtyConfirmed.Value * (-1);
                                var outPorductWorkplace = ctx.ProductWorkplace.Where(x => x.ProductId == productId && x.WorkplaceId == fromId).FirstOrDefault();
                                if (outPorductWorkplace == null)
                                {
                                    outPorductWorkplace = new EF6.ProductWorkplace();
                                    outPorductWorkplace.ProductWorkplaceId = Guid.NewGuid();
                                    outPorductWorkplace.ProductId          = productId;
                                    outPorductWorkplace.WorkplaceId        = fromId;
                                    ctx.ProductWorkplace.Add(outPorductWorkplace);
                                }
                                outPorductWorkplace.CDQTY += qty;
                                if (qty > 0)
                                {
                                    outPorductWorkplace.RECQTY += qty;
                                }
                                ctx.SaveChanges();
                                #endregion

                                //In
                                #region UpdateProductQty(detail.ProductId.Value, toId, detail.QtyConfirmed.Value);
                                qty = detail.QtyConfirmed.Value;
                                var inPorductWorkplace = ctx.ProductWorkplace.Where(x => x.ProductId == productId && x.WorkplaceId == toId).FirstOrDefault();
                                if (inPorductWorkplace == null)
                                {
                                    inPorductWorkplace = new EF6.ProductWorkplace();
                                    inPorductWorkplace.ProductWorkplaceId = Guid.NewGuid();
                                    inPorductWorkplace.ProductId          = productId;
                                    inPorductWorkplace.WorkplaceId        = fromId;
                                    ctx.ProductWorkplace.Add(inPorductWorkplace);
                                }
                                inPorductWorkplace.CDQTY += qty;
                                if (qty > 0)
                                {
                                    inPorductWorkplace.RECQTY += qty;
                                }
                                ctx.SaveChanges();
                                #endregion
                            }
                            #endregion

                            oHeader.CONFIRM_TRF            = this.IsConfirmedTransaction;
                            oHeader.CONFIRM_TRF_LASTUPDATE = DateTime.Now;
                            oHeader.CONFIRM_TRF_LASTUSER   = ConfigHelper.CurrentUserId;
                            oHeader.ModifiedBy             = ConfigHelper.CurrentUserId;
                            oHeader.ModifiedOn             = DateTime.Now;

                            ctx.SaveChanges();

                            this.TxferId = oHeader.HeaderId;
                        }
                        scope.Commit();
                    }
                    catch (Exception ex)
                    {
                        scope.Rollback();
                    }
                }
            }
        }
Exemplo n.º 13
0
        private void LoadData()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var workplace = ctx.Workplace.Find(_WorkplaceId);
                if (workplace != null)
                {
                    txtLoc.Text      = workplace.WorkplaceCode;
                    txtInitial.Text  = workplace.WorkplaceInitial;;
                    txtPassword.Text = workplace.Password;
                    txtName.Text     = workplace.WorkplaceName;
                    txtNameChs.Text  = workplace.WorkplaceName_Chs;
                    txtNameCht.Text  = workplace.WorkplaceName_Cht;
                    //txtSmartTag3.Text = workplace.AlternateWorkplaceCode;
                    txtPriority.Text        = workplace.Priority.ToString();
                    txtPhoneTag2.Text       = workplace.Email;
                    txtLastUpdate.Text      = DateTimeHelper.DateTimeToString(workplace.ModifiedOn, false);
                    txtCreationDate.Text    = DateTimeHelper.DateTimeToString(workplace.CreatedOn, false);
                    txtModified.Text        = StaffEx.GetStaffNumberById(workplace.ModifiedBy);
                    txtStatus_Office.Text   = "";
                    txtStatus_Counter.Text  = "";
                    cboLOO.SelectedValue    = workplace.LineOfOperationId.HasValue ? workplace.LineOfOperationId : Guid.Empty;
                    cboZone.SelectedValue   = workplace.ZoneId;
                    cboNature.SelectedValue = workplace.NatureId != null ? workplace.NatureId : Guid.Empty;

                    #region DownloadToPOS
                    if (workplace.DownloadToPOS)
                    {
                        if (workplace.ModifiedOn.Date.Equals(workplace.CreatedOn.Date))
                        {
                            txtStatus_Office.Text = "A";
                        }
                        else
                        {
                            txtStatus_Office.Text = "M";
                        }
                    }
                    #endregion

                    #region DownloadToCounter
                    if (workplace.DownloadToCounter)
                    {
                        if (workplace.ModifiedOn.Date.Equals(workplace.CreatedOn.Date))
                        {
                            txtStatus_Counter.Text = "A";
                        }
                        else
                        {
                            txtStatus_Counter.Text = "M";
                        }
                    }
                    #endregion

                    #region LoadWorkplaceAddress();
                    var address = ctx.WorkplaceAddress.Where(x => x.WorkplaceId == _WorkplaceId).AsNoTracking().FirstOrDefault();
                    if (address != null)
                    {
                        txtAddress.Text           = address.Address;
                        txtDistrict.Text          = address.District;
                        txtPostal.Text            = address.PostalCode;
                        cboCountry.SelectedValue  = address.CountryId.HasValue ? address.CountryId : Guid.Empty;
                        cboProvince.SelectedValue = address.ProvinceId.HasValue ? address.ProvinceId : Guid.Empty;
                        cboCity.SelectedValue     = address.CityId.HasValue ? address.CityId : Guid.Empty;
                        txtPhoneTag1.Text         = address.PhoneTag1Value;
                        txtPhoneTag3.Text         = address.Phonetage3Value;
                        txtPhoneTag4.Text         = address.PhoneTag4Value;
                    }
                    #endregion

                    #region LoadSmartTag();
                    var oTag1 = ctx.WorkplaceSmartTag.Where(x => x.WorkplaceId == _WorkplaceId && x.TagId == (Guid)txtSmartTag1.Tag).AsNoTracking().FirstOrDefault();
                    if (oTag1 != null)
                    {
                        txtSmartTag1.Text = oTag1.SmartTagValue;
                    }

                    var oTag2 = ctx.WorkplaceSmartTag.Where(x => x.WorkplaceId == _WorkplaceId && x.TagId == (Guid)txtSmartTag2.Tag).AsNoTracking().FirstOrDefault();
                    if (oTag2 != null)
                    {
                        txtSmartTag2.Text = oTag2.SmartTagValue;
                    }
                    #endregion
                }
            }
        }
Exemplo n.º 14
0
        private void BindingHoldingList()
        {
            lvPostTxList.Items.Clear();

            int    iCount = 1;
            string sql    = BuildSqlQueryString(EnumHelper.Status.Active.ToString("d"), true);

            SqlCommand cmd = new SqlCommand();

            cmd.CommandText    = sql;
            cmd.CommandTimeout = ConfigHelper.CommandTimeout;
            cmd.CommandType    = System.Data.CommandType.Text;

            using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    ListViewItem objItem = this.lvPostTxList.Items.Add(reader.GetGuid(0).ToString());                                                            // TxId
                    objItem.SubItems.Add(string.Empty);
                    objItem.SubItems.Add(iCount.ToString());                                                                                                     // Line Number
                    objItem.SubItems.Add(reader.GetString(1));                                                                                                   // TxNumber
                    objItem.SubItems.Add(DateTimeHelper.DateTimeToString(reader.GetDateTime(2), false));                                                         // TxDate
                    objItem.SubItems.Add(DateTimeHelper.DateTimeToString(reader.GetDateTime(2), false));                                                         // TxferDate
                    objItem.SubItems.Add(string.Empty);                                                                                                          // CompletedDate
                    objItem.SubItems.Add(reader.GetString(4));                                                                                                   // From Location
                    objItem.SubItems.Add(reader.GetString(5));                                                                                                   // To Location
                    objItem.SubItems.Add(DateTimeHelper.DateTimeToString(reader.GetDateTime(13), false) + " " + StaffEx.GetStaffNumberById(reader.GetGuid(14))); // Last Update

                    iCount++;
                }
            }
        }
Exemplo n.º 15
0
        private void CreateADJTx(ListViewItem listItem)
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                using (var scope = ctx.Database.BeginTransaction())
                {
                    try
                    {
                        Guid headerId = Guid.Empty;
                        if (Guid.TryParse(listItem.Text, out headerId))
                        {
                            var oBatchHeader = ctx.InvtBatchADJ_Header.Find(headerId);
                            if (oBatchHeader != null)
                            {
                                // Update Product Info
                                #region UpdateProduct(oBatchHeader.HeaderId, oBatchHeader.WorkplaceId);
                                Guid txHeaderId  = oBatchHeader.HeaderId;
                                Guid workplaceId = oBatchHeader.WorkplaceId;

                                var detailsList = ctx.InvtBatchADJ_Details.Where(x => x.HeaderId == txHeaderId);
                                foreach (var item in detailsList)
                                {
                                    Guid    productId = item.ProductId;
                                    decimal qty       = item.Qty.Value;

                                    #region UpdateProductCurrentSummary(item.ProductId, item.Qty.Value);
                                    var currProd = ctx.ProductCurrentSummary.Where(x => x.ProductId == productId).FirstOrDefault();
                                    if (currProd == null)
                                    {
                                        currProd = new EF6.ProductCurrentSummary();
                                        currProd.CurrentSummaryId = Guid.NewGuid();
                                        currProd.ProductId        = productId;
                                        ctx.ProductCurrentSummary.Add(currProd);
                                    }
                                    currProd.CDQTY += qty;
                                    #endregion

                                    #region UpdateProductQty(item.ProductId, workplaceId, item.Qty.Value);
                                    var wpProd = ctx.ProductWorkplace.Where(x => x.ProductId == productId && x.WorkplaceId == workplaceId).FirstOrDefault();
                                    if (wpProd == null)
                                    {
                                        wpProd = new EF6.ProductWorkplace();
                                        wpProd.ProductWorkplaceId = Guid.NewGuid();
                                        wpProd.ProductId          = productId;
                                        wpProd.WorkplaceId        = workplaceId;

                                        ctx.ProductWorkplace.Add(wpProd);
                                    }
                                    wpProd.CDQTY += qty;
                                    #endregion

                                    ctx.SaveChanges();
                                }
                                #endregion

                                // Create ADJ SubLedger
                                string txNumber_SubLedger = oBatchHeader.TxNumber;
                                #region Guid subLedgerHeaderId = CreateADJSubLedgerHeader(txNumber_SubLedger, oBatchHeader.TxDate, oBatchHeader.WorkplaceId, oBatchHeader.StaffId, oBatchHeader.Remarks, oBatchHeader.Reference + "\t" + oBatchHeader.TxNumber);
                                string   txnumber = txNumber_SubLedger;
                                DateTime txDate   = oBatchHeader.TxDate.Value;
                                //Guid workplaceId = oBatchHeader.WorkplaceId;
                                Guid   staffId   = oBatchHeader.StaffId;
                                string remarks   = oBatchHeader.Remarks;
                                string reference = oBatchHeader.Reference + "\t" + oBatchHeader.TxNumber;

                                var oSubADJ = new EF6.InvtSubLedgerADJ_Header();
                                oSubADJ.HeaderId    = Guid.NewGuid();
                                oSubADJ.TxNumber    = txnumber;
                                oSubADJ.TxType      = EnumHelper.TxType.ADJ.ToString();
                                oSubADJ.WorkplaceId = workplaceId;
                                oSubADJ.TxDate      = txDate;
                                oSubADJ.Reference   = reference;
                                oSubADJ.Remarks     = remarks;
                                oSubADJ.StaffId     = staffId;
                                oSubADJ.Status      = Convert.ToInt32(EnumHelper.Status.Active.ToString("d"));

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

                                ctx.InvtSubLedgerADJ_Header.Add(oSubADJ);
                                ctx.SaveChanges();

                                Guid subLedgerHeaderId = oSubADJ.HeaderId;
                                #endregion

                                #region CreateADJSubLedgerDetail(txNumber_SubLedger, oBatchHeader.HeaderId, subLedgerHeaderId);
                                //string txnumber = txNumber_SubLedger;
                                Guid batchHeaderId = oBatchHeader.HeaderId;

                                decimal  ttlAmt        = 0;
                                string   sql           = "HeaderId = '" + batchHeaderId.ToString() + "'";
                                string[] orderBy       = new string[] { "LineNumber" };
                                var      oBatchDetails = ctx.InvtBatchADJ_Details.Where(x => x.HeaderId == batchHeaderId).OrderBy(x => x.LineNumber);
                                foreach (var oBDetail in oBatchDetails)
                                {
                                    var oSubLedgerDetail = new EF6.InvtSubLedgerADJ_Details();
                                    oSubLedgerDetail.DetailsId   = Guid.NewGuid();
                                    oSubLedgerDetail.HeaderId    = subLedgerHeaderId;
                                    oSubLedgerDetail.LineNumber  = oBDetail.LineNumber.Value;
                                    oSubLedgerDetail.ProductId   = oBDetail.ProductId;
                                    oSubLedgerDetail.Qty         = oBDetail.Qty.Value;
                                    oSubLedgerDetail.TxNumber    = txnumber;
                                    oSubLedgerDetail.TxType      = EnumHelper.TxType.ADJ.ToString();
                                    oSubLedgerDetail.AverageCost = oBDetail.AverageCost.Value;
                                    oSubLedgerDetail.ReasonCode  = oBDetail.ReasonCode;
                                    oSubLedgerDetail.Remarks     = oBDetail.Remarks;

                                    ctx.InvtSubLedgerADJ_Details.Add(oSubLedgerDetail);

                                    ttlAmt += oSubLedgerDetail.Qty.Value * oSubLedgerDetail.AverageCost.Value;
                                }

                                var oSubLedgerHeader = ctx.InvtSubLedgerADJ_Header.Find(subLedgerHeaderId);
                                if (oSubLedgerHeader != null)
                                {
                                    oSubLedgerHeader.TotalAmount = ttlAmt;

                                    oSubLedgerHeader.ModifiedOn = DateTime.Now;
                                    oSubLedgerHeader.ModifiedBy = ConfigHelper.CurrentUserId;
                                }
                                ctx.SaveChanges();
                                #endregion

                                // Create Ledger for TxType 'ADJ'
                                string txNumber_Ledger = oBatchHeader.TxNumber;
                                #region Guid ledgerHeaderId = CreateLedgerHeader(txNumber_Ledger, oBatchHeader.TxDate, subLedgerHeaderId, oBatchHeader.WorkplaceId, oBatchHeader.StaffId, oBatchHeader.Reference + "\t" + txNumber_SubLedger, oBatchHeader.Remarks);
                                //string txnumber = txNumber_Ledger;
                                //DateTime txDate = oBatchHeader.TxDate.Value;
                                //Guid subLedgerHeaderId = subLedgerHeaderId;
                                //Guid workplaceId = oBatchHeader.WorkplaceId;
                                //Guid staffId = oBatchHeader.StaffId;
                                //string reference = oBatchHeader.Reference + "\t" + txNumber_SubLedger;
                                //string remarks = oBatchHeader.Remarks;

                                var oLedgerHeader = new EF6.InvtLedgerHeader();
                                oLedgerHeader.HeaderId          = Guid.NewGuid();
                                oLedgerHeader.TxNumber          = txnumber;
                                oLedgerHeader.TxType            = EnumHelper.TxType.ADJ.ToString();
                                oLedgerHeader.TxDate            = txDate;
                                oLedgerHeader.SubLedgerHeaderId = subLedgerHeaderId;
                                oLedgerHeader.WorkplaceId       = workplaceId;
                                oLedgerHeader.StaffId           = staffId;
                                oLedgerHeader.Reference         = reference;
                                oLedgerHeader.Remarks           = remarks;
                                oLedgerHeader.Status            = Convert.ToInt32(EnumHelper.Status.Active.ToString("d"));
                                oLedgerHeader.CreatedBy         = ConfigHelper.CurrentUserId;
                                oLedgerHeader.CreatedOn         = DateTime.Now;
                                oLedgerHeader.ModifiedBy        = ConfigHelper.CurrentUserId;
                                oLedgerHeader.ModifiedOn        = DateTime.Now;

                                ctx.InvtLedgerHeader.Add(oLedgerHeader);
                                ctx.SaveChanges();

                                Guid ledgerHeaderId = oLedgerHeader.HeaderId;
                                #endregion

                                #region CreateLedgerDetails(txNumber_Ledger, subLedgerHeaderId, ledgerHeaderId, oBatchHeader);
                                //string txnumber = txNumber_Ledger;
                                //Guid subledgerHeaderId = subLedgerHeaderId;
                                //Guid ledgerHeaderId = ledgerHeaderId;
                                //InvtBatchADJ_Header oBatchHeader

                                //string sql = "HeaderId = '" + subledgerHeaderId.ToString() + "'";
                                //string[] orderBy = new string[] { "LineNumber" };

                                var oSubLedgerDetails = ctx.InvtSubLedgerADJ_Details.Where(x => x.HeaderId == subLedgerHeaderId).OrderBy(x => x.LineNumber);
                                foreach (var oSDetail in oSubLedgerDetails)
                                {
                                    var oLedgerDetail = new EF6.InvtLedgerDetails();
                                    oLedgerDetail.DetailsId          = Guid.NewGuid();
                                    oLedgerDetail.HeaderId           = ledgerHeaderId;
                                    oLedgerDetail.SubLedgerDetailsId = oSDetail.DetailsId;
                                    oLedgerDetail.LineNumber         = oSDetail.LineNumber.Value;
                                    oLedgerDetail.ProductId          = oSDetail.ProductId;
                                    oLedgerDetail.Qty          = oSDetail.Qty.Value;
                                    oLedgerDetail.TxNumber     = txnumber;
                                    oLedgerDetail.TxType       = EnumHelper.TxType.ADJ.ToString();
                                    oLedgerDetail.TxDate       = oBatchHeader.TxDate.Value;
                                    oLedgerDetail.Amount       = oLedgerDetail.Qty * oLedgerDetail.AverageCost;
                                    oLedgerDetail.Notes        = string.Empty;
                                    oLedgerDetail.SerialNumber = string.Empty;
                                    oLedgerDetail.SHOP         = WorkplaceEx.GetWorkplaceCodeById(oBatchHeader.WorkplaceId);
                                    oLedgerDetail.OPERATOR     = StaffEx.GetStaffNumberById(oBatchHeader.StaffId);

                                    // Product Info
                                    var oItem = ctx.Product.Find(oSDetail.ProductId);
                                    if (oItem != null)
                                    {
                                        oLedgerDetail.BasicPrice  = oItem.RetailPrice.Value;
                                        oLedgerDetail.UnitAmount  = ProductCurrentSummaryEx.GetAverageCode(oItem.ProductId);
                                        oLedgerDetail.Discount    = oItem.NormalDiscount;
                                        oLedgerDetail.Amount      = oLedgerDetail.UnitAmount * oLedgerDetail.Qty;
                                        oLedgerDetail.AverageCost = ProductCurrentSummaryEx.GetAverageCode(oItem.ProductId);

                                        var priceTypeId = ProductPriceTypeEx.GetIdByPriceType(ProductHelper.Prices.VPRC.ToString());
                                        //sql = "ProductId = '" + oSDetail.ProductId.ToString() + "' AND PriceTypeId = '" + priceTypeId.ToString() + "'";

                                        var oPrice = ctx.ProductPrice.Where(x => x.ProductId == oSDetail.ProductId && x.PriceTypeId == priceTypeId).FirstOrDefault();
                                        if (oPrice != null)
                                        {
                                            oLedgerDetail.VendorRef = oPrice.CurrencyCode;
                                        }
                                    }
                                    ctx.InvtLedgerDetails.Add(oLedgerDetail);

                                    var oLedgerHeader2 = ctx.InvtLedgerHeader.Find(ledgerHeaderId);
                                    if (oLedgerHeader2 != null)
                                    {
                                        oLedgerHeader2.TotalAmount += oLedgerDetail.Amount;
                                    }

                                    ctx.SaveChanges();
                                }
                                #endregion

                                oBatchHeader.PostedBy   = ConfigHelper.CurrentUserId;
                                oBatchHeader.PostedOn   = DateTime.Now;
                                oBatchHeader.ModifiedBy = ConfigHelper.CurrentUserId;
                                oBatchHeader.ModifiedOn = DateTime.Now;
                                ctx.SaveChanges();

                                #region ClearBatchTransaction(oBatchHeader);
                                string query      = "HeaderId = '" + oBatchHeader.HeaderId.ToString() + "'";
                                var    detailList = ctx.InvtBatchADJ_Details.Where(x => x.HeaderId == oBatchHeader.HeaderId);
                                foreach (var detail in detailList)
                                {
                                    ctx.InvtBatchADJ_Details.Remove(detail);
                                }

                                ctx.InvtBatchADJ_Header.Remove(oBatchHeader);
                                ctx.SaveChanges();
                                #endregion
                            }
                        }
                        scope.Commit();
                    }
                    catch (Exception ex)
                    {
                        scope.Rollback();
                    }
                }
            }
        }
Exemplo n.º 16
0
        /**
         * private int CreateProducts()
         * {
         *  int iCount = 0;
         *  ListView combinList = Combin();
         *  if (combinList.Items.Count > 0)
         *  {
         *      foreach (ListViewItem oItem in combinList.Items)
         *      {
         *          CreateProducts(oItem);
         *          iCount++;
         *      }
         *  }
         *  return iCount;
         * }
         *
         * private void CreateProducts(ListViewItem listItem)
         * {
         *  if (IsValidEntries())
         *  {
         *      string a1 = listItem.SubItems[1].Text;
         *      string a2 = listItem.SubItems[2].Text;
         *      string a3 = listItem.SubItems[3].Text;
         *
         *      System.Guid a1Id = (Common.Utility.IsGUID(listItem.SubItems[4].Text)) ? new Guid(listItem.SubItems[4].Text) : System.Guid.Empty;
         *      System.Guid a2Id = (Common.Utility.IsGUID(listItem.SubItems[5].Text)) ? new Guid(listItem.SubItems[5].Text) : System.Guid.Empty;
         *      System.Guid a3Id = (Common.Utility.IsGUID(listItem.SubItems[6].Text)) ? new Guid(listItem.SubItems[6].Text) : System.Guid.Empty;
         *
         *      string prodCode = txtStkCode.Text.Trim() + a1 + a2 + a3;
         *      if (prodCode.Length <= 22)
         *      {
         *          StringBuilder sql = new StringBuilder();
         *          sql.Append(" STKCODE = '").Append(txtStkCode.Text.Trim()).Append("' ");
         *          sql.Append(" AND APPENDIX1 = '").Append(a1.Trim()).Append("' ");
         *          sql.Append(" AND APPENDIX2 = '").Append(a2.Trim()).Append("' ");
         *          sql.Append(" AND APPENDIX3 = '").Append(a3.Trim()).Append("' ");
         *
         *          var oProduct = RT2020.DAL.Product.LoadWhere(sql.ToString());
         *          if (oProduct == null)
         *          {
         *              oProduct = new RT2020.DAL.Product();
         *
         *              oProduct.STKCODE = txtStkCode.Text;
         *              oProduct.APPENDIX1 = a1;
         *              oProduct.APPENDIX2 = a2;
         *              oProduct.APPENDIX3 = a3;
         *
         *              if (cboItemStatus.Text == "HOLD")
         *              {
         *                  oProduct.Status = Convert.ToInt32(EnumHelper.Status.Draft.ToString("d"));
         *              }
         *              else if (cboItemStatus.Text == "POST")
         *              {
         *                  oProduct.Status = Convert.ToInt32(EnumHelper.Status.Active.ToString("d"));
         *              }
         *
         *              oProduct.CLASS1 = general.cboClass1.Text;
         *              oProduct.CLASS2 = general.cboClass2.Text;
         *              oProduct.CLASS3 = general.cboClass3.Text;
         *              oProduct.CLASS4 = general.cboClass4.Text;
         *              oProduct.CLASS5 = general.cboClass5.Text;
         *              oProduct.CLASS6 = general.cboClass6.Text;
         *
         *              oProduct.ProductName = general.txtProductName.Text;
         *              oProduct.ProductName_Chs = general.txtProductNameChs.Text;
         *              oProduct.ProductName_Cht = general.txtProductNameCht.Text;
         *              oProduct.Remarks = general.txtRemarks.Text;
         *
         *              oProduct.NormalDiscount = Convert.ToDecimal((general.txtRetailDiscount.Text == string.Empty) ? "0" : general.txtRetailDiscount.Text);
         *              oProduct.UOM = general.txtUnit.Text;
         *              oProduct.NatureId = new Guid(general.cboNature.SelectedValue.ToString());
         *
         *              oProduct.FixedPriceItem = false;
         *
         *              // Download Packets
         *              oProduct.DownloadToPOS = general.chkRetailItem.Checked;
         *              oProduct.DownloadToCounter = general.chkCounterItem.Checked;
         *
         *              oProduct.CreatedBy = ConfigHelper.CurrentUserId;
         *              oProduct.CreatedOn = DateTime.Now;
         *              oProduct.ModifiedBy = ConfigHelper.CurrentUserId;
         *              oProduct.ModifiedOn = DateTime.Now;
         *
         *              oProduct.Save();
         *
         *              SaveProductBarcode(oProduct.ProductId, prodCode);
         *
         *              // Appendix / Class
         *              System.Guid c1Id = (general.cboClass1.SelectedValue != null) ? new Guid(general.cboClass1.SelectedValue.ToString()) : System.Guid.Empty;
         *              System.Guid c2Id = (general.cboClass2.SelectedValue != null) ? new Guid(general.cboClass2.SelectedValue.ToString()) : System.Guid.Empty;
         *              System.Guid c3Id = (general.cboClass3.SelectedValue != null) ? new Guid(general.cboClass3.SelectedValue.ToString()) : System.Guid.Empty;
         *              System.Guid c4Id = (general.cboClass4.SelectedValue != null) ? new Guid(general.cboClass4.SelectedValue.ToString()) : System.Guid.Empty;
         *              System.Guid c5Id = (general.cboClass5.SelectedValue != null) ? new Guid(general.cboClass5.SelectedValue.ToString()) : System.Guid.Empty;
         *              System.Guid c6Id = (general.cboClass6.SelectedValue != null) ? new Guid(general.cboClass6.SelectedValue.ToString()) : System.Guid.Empty;
         *              SaveProductCode(oProduct.ProductId, a1Id, a2Id, a3Id, c1Id, c2Id, c3Id, c4Id, c5Id, c6Id);
         *
         *              // Product Price
         *              SaveProductSupplement(oProduct.ProductId);
         *              SaveProductPrice(oProduct.ProductId);
         *
         *              // Remarks
         *              SaveProductRemarks(oProduct.ProductId);
         *
         *              SaveCurrentSummary(oProduct.ProductId);
         *          }
         *      }
         *  }
         * }
         *
         * private void SaveCurrentSummary(Guid productId)
         * {
         *  string where = "ProductId = '" + productId.ToString() + "'";
         *
         *  using (var ctx = new EF6.RT2020Entities())
         *  {
         *      var oCurrSummary = ctx.ProductCurrentSummary.Where(x => x.ProductId == productId).FirstOrDefault();
         *      if (oCurrSummary == null)
         *      {
         *          oCurrSummary = new EF6.ProductCurrentSummary();
         *          oCurrSummary.CurrentSummaryId = Guid.NewGuid();
         *          oCurrSummary.ProductId = productId;
         *          oCurrSummary.CDQTY = 0;
         *          oCurrSummary.LastPurchasedOn = new DateTime(1900, 1, 1);
         *          oCurrSummary.LastSoldOn = new DateTime(1900, 1, 1);
         *
         *          ctx.ProductCurrentSummary.Add(oCurrSummary);
         *          ctx.SaveChanges();
         *      }
         *  }
         * }
         *
         * private void SaveProductBarcode(Guid productid, string barcode)
         * {
         *  using (var ctx = new EF6.RT2020Entities())
         *  {
         *      //string sql = "ProductId = '" + productid.ToString() + "' AND Barcode = '" + barcode + "'";
         *      var oBarcode = ctx.ProductBarcode.Where(x => x.ProductId == productid && x.Barcode == barcode).FirstOrDefault();
         *      if (oBarcode == null)
         *      {
         *          oBarcode = new EF6.ProductBarcode();
         *          oBarcode.ProductBarcodeId = Guid.NewGuid();
         *          oBarcode.ProductId = productid;
         *          oBarcode.Barcode = barcode;
         *          oBarcode.BarcodeType = "INTER";
         *          oBarcode.PrimaryBarcode = true;
         *          oBarcode.DownloadToPOS = general.chkRetailItem.Checked;
         *          oBarcode.DownloadToCounter = general.chkCounterItem.Checked;
         *
         *          ctx.ProductBarcode.Add(oBarcode);
         *          ctx.SaveChanges();
         *      }
         *  }
         * }
         *
         * private void SaveProductCode(Guid productId, Guid a1Id, Guid a2Id, Guid a3Id, Guid c1Id, Guid c2Id, Guid c3Id, Guid c4Id, Guid c5Id, Guid c6Id)
         * {
         *  using (var ctx = new EF6.RT2020Entities())
         *  {
         *      //string sql = "ProductId = '" + productId.ToString() + "'";
         *      var oCode = ctx.ProductCode.Where(x => x.ProductId == productId).FirstOrDefault();
         *      if (oCode == null)
         *      {
         *          oCode = new EF6.ProductCode();
         *          oCode.CodeId = Guid.NewGuid();
         *          oCode.ProductId = productId;
         *          oCode.Appendix1Id = a1Id;
         *          oCode.Appendix2Id = a2Id;
         *          oCode.Appendix3Id = a3Id;
         *
         *          ctx.ProductCode.Add(oCode);
         *      }
         *      oCode.Class1Id = c1Id;
         *      oCode.Class2Id = c2Id;
         *      oCode.Class3Id = c3Id;
         *      oCode.Class4Id = c4Id;
         *      oCode.Class5Id = c5Id;
         *      oCode.Class6Id = c6Id;
         *
         *      ctx.SaveChanges();
         *  }
         * }
         *
         * private void SaveProductSupplement(Guid productId)
         * {
         *  using (var ctx = new EF6.RT2020Entities())
         *  {
         *      string sql = "ProductId = '" + productId.ToString() + "'";
         *      var oProdSupp = ctx.ProductSupplement.Where(x => x.ProductId == productId).FirstOrDefault();
         *      if (oProdSupp == null)
         *      {
         *          oProdSupp = new EF6.ProductSupplement();
         *          oProdSupp.SupplementId = Guid.NewGuid();
         *          oProdSupp.ProductId = productId;
         *
         *          ctx.ProductSupplement.Add(oProdSupp);
         *      }
         *      oProdSupp.VendorCurrencyCode = general.cboVendorCurrency.Text;
         *      oProdSupp.VendorPrice = Convert.ToDecimal((general.txtVendorPrice.Text == string.Empty) ? "0" : general.txtVendorPrice.Text);
         *      oProdSupp.ProductName_Memo = general.txtMemo.Text;
         *      oProdSupp.ProductName_Pole = general.txtPole.Text;
         *
         *      //oProdSupp.VipDiscount_FixedItem = Convert.ToDecimal((txtDiscount1_FixPriceItem.Text == string.Empty) ? "0" : txtDiscount1_FixPriceItem.Text);
         *      //oProdSupp.VipDiscount_DiscountItem = Convert.ToDecimal((txtDiscount2_DiscountItem.Text == string.Empty) ? "0" : txtDiscount2_DiscountItem.Text);
         *      //oProdSupp.VipDiscount_NoDiscountItem = Convert.ToDecimal((txtDiscount3_NoDiscountItem.Text == string.Empty) ? "0" : txtDiscount3_NoDiscountItem.Text);
         *      //oProdSupp.StaffDiscount = Convert.ToDecimal((txtStaffDiscount.Text == string.Empty) ? "0" : txtStaffDiscount.Text);
         *
         *      ctx.SaveChanges();
         *  }
         * }
         *
         * private void SaveProductPrice(Guid productId)
         * {
         *  SaveProductPrice(productId, EnumHelper.ProductPriceType.BASPRC.ToString(), general.txtCurrentRetailCurrency.Text, general.txtCurrentRetailPrice.Text);
         *  SaveProductPrice(productId, EnumHelper.ProductPriceType.ORIPRC.ToString(), general.txtOriginalRetailCurrency.Text, general.txtOriginalRetailPrice.Text);
         *  SaveProductPrice(productId, EnumHelper.ProductPriceType.VPRC.ToString(), general.cboVendorCurrency.Text, general.txtVendorPrice.Text);
         *  SaveProductPrice(productId, EnumHelper.ProductPriceType.WHLPRC.ToString(), general.txtWholesalesCurrency.Text, general.txtWholesalesPrice.Text);
         * }
         *
         * private void SaveProductPrice(Guid productId, string priceType, string currencyCode, string price)
         * {
         *  using (var ctx = new EF6.RT2020Entities())
         *  {
         *      var priceTypeId = ModelEx.ProductPriceTypeEx.GetIdByPriceType(priceType);
         *      //string sql = "ProductId = '" + productId.ToString() + "' AND PriceTypeId = '" + GetPriceType(priceType).ToString() + "'";
         *
         *      var oPrice = ctx.ProductPrice.Where(x => x.ProductId == productId && x.PriceTypeId == priceTypeId).FirstOrDefault();
         *      if (oPrice == null)
         *      {
         *          oPrice = new EF6.ProductPrice();
         *          oPrice.ProductPriceId = Guid.NewGuid();
         *          oPrice.ProductId = productId;
         *
         *          ctx.ProductPrice.Add(oPrice);
         *      }
         *      oPrice.PriceTypeId = priceTypeId;
         *      oPrice.CurrencyCode = currencyCode;
         *      oPrice.Price = Convert.ToDecimal((price == string.Empty) ? "0" : price);
         *
         *      ctx.SaveChanges();
         *  }
         * }
         *
         * private void SaveProductRemarks(Guid productId)
         * {
         *  using (var ctx = new EF6.RT2020Entities())
         *  {
         *      //string sql = "ProductId = '" + productId.ToString() + "'";
         *      var oRemarks = ctx.ProductRemarks.Where(x => x.ProductId == productId).FirstOrDefault();
         *      if (oRemarks == null)
         *      {
         *          oRemarks = new EF6.ProductRemarks();
         *          oRemarks.ProductRemarksId = Guid.NewGuid();
         *          oRemarks.ProductId = productId;
         *
         *          ctx.ProductRemarks.Add(oRemarks);
         *      }
         *      oRemarks.BinX = general.txtBin_X.Text;
         *      oRemarks.BinY = general.txtBin_Y.Text;
         *      oRemarks.BinZ = general.txtBin_Z.Text;
         *
         *      oRemarks.DownloadToShop = general.chkRetailItem.Checked;
         *      oRemarks.OffDisplayItem = general.chkOffDisplayItem.Checked;
         *      oRemarks.DownloadToCounter = general.chkCounterItem.Checked;
         *
         *      oRemarks.REMARK1 = general.txtRemarks1.Text;
         *      oRemarks.REMARK2 = general.txtRemarks2.Text;
         *      oRemarks.REMARK3 = general.txtRemarks3.Text;
         *      oRemarks.REMARK4 = general.txtRemarks4.Text;
         *      oRemarks.REMARK5 = general.txtRemarks5.Text;
         *      oRemarks.REMARK6 = general.txtRemarks6.Text;
         *
         *      ctx.SaveChanges();
         *  }
         * }
         */
        #endregion

        #region Save Product Batch
        private void SaveProductBatch()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var oBatch = ctx.ProductBatch.Find(this.ProductBatchId);
                if (oBatch == null)
                {
                    oBatch         = new EF6.ProductBatch();
                    oBatch.BatchId = Guid.NewGuid();
                    ctx.ProductBatch.Add(oBatch);
                }
                oBatch.STKCODE          = txtStkCode.Text;
                oBatch.APP1_COMBIN      = cboAppendix1.Text;
                oBatch.APP2_COMBIN      = cboAppendix2.Text;
                oBatch.APP3_COMBIN      = cboAppendix3.Text;
                oBatch.CLASS1           = general.cboClass1.Text;
                oBatch.CLASS2           = general.cboClass2.Text;
                oBatch.CLASS3           = general.cboClass3.Text;
                oBatch.CLASS4           = general.cboClass4.Text;
                oBatch.CLASS5           = general.cboClass5.Text;
                oBatch.CLASS6           = general.cboClass6.Text;
                oBatch.Description      = general.txtProductName.Text;
                oBatch.MAINUNIT         = general.txtUnit.Text;
                oBatch.ALTITEM          = string.Empty;
                oBatch.REMARKS          = general.txtRemarks.Text;
                oBatch.MARKUP           = 0;
                oBatch.BASPRC           = (general.txtCurrentRetailPrice.Text.Length == 0) ? 0 : Convert.ToDecimal(general.txtCurrentRetailPrice.Text);
                oBatch.WHLPRC           = (general.txtWholesalesPrice.Text.Length == 0) ? 0 : Convert.ToDecimal(general.txtWholesalesPrice.Text);
                oBatch.VCURR            = general.cboVendorCurrency.Text;
                oBatch.VPRC             = (general.txtVendorPrice.Text.Length == 0) ? 0 : Convert.ToDecimal(general.txtVendorPrice.Text);
                oBatch.NRDISC           = 0;
                oBatch.REORDLVL         = (order.txtReorderLevel.Text.Length == 0) ? 0 : Convert.ToDecimal(order.txtReorderLevel.Text);
                oBatch.REORDQTY         = (order.txtReorderQuantity.Text.Length == 0) ? 0 : Convert.ToDecimal(order.txtReorderQuantity.Text);
                oBatch.SERIALFLAG       = false;
                oBatch.NATURE           = general.cboNature.Text;
                oBatch.REMARK1          = general.txtRemarks1.Text;
                oBatch.REMARK2          = general.txtRemarks2.Text;
                oBatch.REMARK3          = general.txtRemarks3.Text;
                oBatch.REMARK4          = general.txtRemarks4.Text;
                oBatch.REMARK5          = general.txtRemarks5.Text;
                oBatch.REMARK6          = general.txtRemarks6.Text;
                oBatch.PHOTO            = misc.txtPicFileName.Text;
                oBatch.STK_MEMO         = general.txtMemo.Text;
                oBatch.STATUS           = cboItemStatus.Text;
                oBatch.DATEPOST         = new DateTime(1900, 1, 1);
                oBatch.DATECREATE       = DateTime.Now;
                oBatch.DATELCHG         = DateTime.Now;
                oBatch.USERLCHG         = StaffEx.GetStaffNumberById(ConfigHelper.CurrentUserId);
                oBatch.RETAILITEM       = general.chkRetailItem.Checked.ToString();
                oBatch.BINX             = general.txtBin_X.Text;
                oBatch.BINY             = general.txtBin_Y.Text;
                oBatch.BINZ             = general.txtBin_Z.Text;
                oBatch.DESC_MEMO        = general.txtMemo.Text;
                oBatch.DESC_POLE        = general.txtPole.Text;
                oBatch.OFF_DISPLAY_ITEM = general.chkOffDisplayItem.Checked.ToString();
                oBatch.COUNTER_ITEM     = general.chkCounterItem.Checked.ToString();
                oBatch.ORIPRC           = (general.txtOriginalRetailPrice.Text.Length == 0) ? 0 : Convert.ToDecimal(general.txtOriginalRetailPrice.Text);

                ctx.SaveChanges();

                this.ProductBatchId = oBatch.BatchId;
            }
        }
Exemplo n.º 17
0
        public void LoadData()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var oItem = ctx.Product.Where(x => x.ProductId == this.ProductId).AsNoTracking().FirstOrDefault();
                if (oItem != null)
                {
                    cboClass1.Text = oItem.CLASS1;
                    cboClass2.Text = oItem.CLASS2;
                    cboClass3.Text = oItem.CLASS3;
                    cboClass4.Text = oItem.CLASS4;
                    cboClass5.Text = oItem.CLASS5;
                    cboClass6.Text = oItem.CLASS6;

                    txtProductName.Text    = oItem.ProductName;
                    txtProductNameChs.Text = oItem.ProductName_Chs;
                    txtProductNameCht.Text = oItem.ProductName_Cht;
                    txtRemarks.Text        = oItem.Remarks;

                    txtWholesalesPrice.Text     = oItem.WholesalePrice.Value.ToString("n2");
                    txtOriginalRetailPrice.Text = oItem.OriginalRetailPrice.Value.ToString("n2");
                    txtCurrentRetailPrice.Text  = oItem.RetailPrice.Value.ToString("n2");
                    txtRetailDiscount.Text      = oItem.NormalDiscount.ToString("n2");
                    txtUnit.Text            = oItem.UOM;
                    cboNature.SelectedValue = oItem.NatureId.HasValue ? oItem.NatureId : Guid.Empty;

                    txtStatus_Counter.Text = "";
                    txtStatus_Office.Text  = "";
                    txtCreatedOn.Text      = DateTimeHelper.DateTimeToString(oItem.CreatedOn, false);
                    txtModifiedOn.Text     = DateTimeHelper.DateTimeToString(oItem.ModifiedOn, false);
                    txtModifiedBy.Text     = StaffEx.GetStaffNumberById(oItem.ModifiedBy);

                    #region LoadProductBasicPrice();
                    var priceTypeId = ProductPriceTypeEx.GetIdByPriceType(ProductHelper.Prices.BASPRC.ToString());
                    var oBPrice     = ctx.ProductPrice.Where(x => x.ProductId == this.ProductId && x.PriceTypeId == priceTypeId).AsNoTracking().FirstOrDefault();
                    if (oBPrice != null)
                    {
                        txtCurrentRetailCurrency.Text = oBPrice.CurrencyCode;
                        txtCurrentRetailPrice.Text    = oBPrice.Price.Value.ToString("n2");
                    }
                    #endregion

                    #region LoadProductOriginalPrice();
                    priceTypeId = ProductPriceTypeEx.GetIdByPriceType(ProductHelper.Prices.ORIPRC.ToString());
                    var oOPrice = ctx.ProductPrice.Where(x => x.ProductId == this.ProductId && x.PriceTypeId == priceTypeId).AsNoTracking().FirstOrDefault();
                    if (oOPrice != null)
                    {
                        txtOriginalRetailCurrency.Text = oOPrice.CurrencyCode;
                        txtOriginalRetailPrice.Text    = oOPrice.Price.Value.ToString("n2");
                    }
                    #endregion

                    #region LoadProductVendorPrice();
                    priceTypeId = ProductPriceTypeEx.GetIdByPriceType(ProductHelper.Prices.VPRC.ToString());
                    var oVPrice = ctx.ProductPrice.Where(x => x.ProductId == this.ProductId && x.PriceTypeId == priceTypeId).AsNoTracking().FirstOrDefault();
                    if (oVPrice != null)
                    {
                        cboVendorCurrency.Text = oVPrice.CurrencyCode;
                        txtVendorPrice.Text    = oVPrice.Price.Value.ToString("n2");
                    }
                    #endregion

                    #region LoadProductWholesalesPrice();
                    priceTypeId = ProductPriceTypeEx.GetIdByPriceType(ProductHelper.Prices.WHLPRC.ToString());
                    var oWPrice = ctx.ProductPrice.Where(x => x.ProductId == this.ProductId && x.PriceTypeId == priceTypeId).AsNoTracking().FirstOrDefault();
                    if (oWPrice != null)
                    {
                        txtWholesalesCurrency.Text = oWPrice.CurrencyCode;
                        txtWholesalesPrice.Text    = oWPrice.Price.Value.ToString("n2");
                    }
                    #endregion

                    txtCurrentRetailPrice.Text = oItem.RetailPrice.Value.ToString("n2");

                    #region LoadProductSupplement
                    var oProdSupp = ctx.ProductSupplement.Where(x => x.ProductId == this._ProductId).AsNoTracking().FirstOrDefault();
                    if (oProdSupp != null)
                    {
                        cboVendorCurrency.Text = oProdSupp.VendorCurrencyCode;
                        txtVendorPrice.Text    = oProdSupp.VendorPrice.Value.ToString("n2");
                        txtMemo.Text           = oProdSupp.ProductName_Memo;
                        txtPole.Text           = oProdSupp.ProductName_Pole;
                    }
                    #endregion

                    #region LoadProductRemarks
                    var oRemarks = ctx.ProductRemarks.Where(x => x.ProductId == _ProductId).AsNoTracking().FirstOrDefault();
                    if (oRemarks != null)
                    {
                        txtBin_X.Text = oRemarks.BinX;
                        txtBin_Y.Text = oRemarks.BinY;
                        txtBin_Z.Text = oRemarks.BinZ;

                        chkRetailItem.Checked     = oRemarks.DownloadToShop;
                        chkOffDisplayItem.Checked = oRemarks.OffDisplayItem;
                        chkCounterItem.Checked    = oRemarks.DownloadToCounter;

                        txtRemarks1.Text = oRemarks.REMARK1;
                        txtRemarks2.Text = oRemarks.REMARK2;
                        txtRemarks3.Text = oRemarks.REMARK3;
                        txtRemarks4.Text = oRemarks.REMARK4;
                        txtRemarks5.Text = oRemarks.REMARK5;
                        txtRemarks6.Text = oRemarks.REMARK6;
                    }
                    #endregion
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Loads the PO header info.
        /// </summary>
        private void LoadPOHeaderInfo()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var objHeader = ctx.PurchaseOrderHeader.Where(x => x.OrderHeaderId == this.OrderHeaderId).AsNoTracking().FirstOrDefault();

                if (objHeader != null)
                {
                    #region strType
                    string strType = string.Empty;
                    switch (objHeader.OrderType)
                    {
                    case 1:
                        strType = EnumHelper.POType.LPO.ToString();
                        break;

                    case 2:
                        strType = EnumHelper.POType.OPO.ToString();
                        break;

                    case 0:
                    default:
                        strType = EnumHelper.POType.FPO.ToString();
                        break;
                    }
                    #endregion

                    #region load Header
                    this.txtType.Text                   = strType;
                    this.txtPurchaseOrderNo.Text        = objHeader.OrderNumber;
                    this.txtPOOrderedQty.Text           = objHeader.TotalQty.ToString("n0");
                    this.txtOrderAmount.Text            = objHeader.TotalCost.ToString("n2");
                    this.cboSupplierCode.SelectedValue  = objHeader.SupplierId;
                    this.cboOperatorCode.SelectedValue  = objHeader.StaffId;
                    this.dtpOrderDate.Value             = objHeader.OrderOn.Value;
                    this.dtpDeliveryDate.Value          = objHeader.DeliverOn.Value;
                    this.dtpCancelDate.Value            = objHeader.CancellationOn.Value;
                    this.cboPaymentMethod.SelectedValue = objHeader.TermsId;
                    this.txtPaymentTerm.Text            = objHeader.CreditDays.ToString("n0");
                    this.txtDeposit.Text                = objHeader.DepositPercentage.ToString("n2");
                    this.txtPaymentRemark.Text          = objHeader.PaymentRemarks;

                    this.cboLocation.SelectedValue       = objHeader.WorkplaceId;
                    this.cboCurrency.Text                = objHeader.CurrencyCode;
                    this.txtGroupDiscount1.Text          = objHeader.GroupDiscount1.ToString("n2");
                    this.txtGroupDiscount2.Text          = objHeader.GroupDiscount2.ToString("n2");
                    this.txtGroupDiscount3.Text          = objHeader.GroupDiscount3.ToString("n2");
                    this.txtTypeDetail.Text              = objHeader.TYPEDTL;
                    this.cboPartialShipment.SelectedItem = objHeader.PartialShipment ? "YES" : "NO";
                    this.cboShipmentMethod.Text          = objHeader.ShipmentMethod;
                    this.txtShipmentRemark.Text          = objHeader.ShipmentRemarks;
                    this.txtLastUser.Text                = StaffEx.GetStaffNumberById(objHeader.ModifiedBy);

                    this.cboStatus.SelectedItem  = (objHeader.Status == 0) ? "HOLD" : "POST";
                    this.txtXRate.Text           = objHeader.ExchangeRate.Value.ToString("n6");
                    this.txtFreightCharge.Text   = objHeader.FreightChargePcn.ToString("n2");
                    this.txtHandlingCharge.Text  = objHeader.HandlingChargePcn.ToString("n2");
                    this.txtInsuranceCharge.Text = objHeader.InsuranceChargePcn.ToString("n2");
                    this.txtOtherCharge.Text     = objHeader.OtherChargesPcn.ToString("n2");
                    this.txtTotalQty.Text        = objHeader.TotalQty.ToString("n0");
                    this.txtNetCost.Text         = (objHeader.TotalCost - objHeader.GroupDiscount1 - objHeader.GroupDiscount2 - objHeader.GroupDiscount3 - objHeader.FreightChargeAmt - objHeader.HandlingChargeAmt - objHeader.InsuranceChargeAmt - objHeader.OtherChargesAmt).ToString("n2");
                    this.txtCoeffcient.Text      = objHeader.ChargeCoefficient.ToString("n6");
                    this.txtLastUpdate.Text      = objHeader.ModifiedOn.ToShortDateString();

                    this.txtDeliveryAddress.Text = objHeader.DeliveryAddress;
                    this.txtContactPerson.Text   = objHeader.ContactPerson;
                    this.txtContactTel.Text      = objHeader.ContactPhone;
                    this.txtPoRemark1.Text       = objHeader.Remarks1;
                    this.txtPoRemark2.Text       = objHeader.Remarks2;
                    this.txtPoRemark3.Text       = objHeader.Remarks3;
                    #endregion

                    #region load Details
                    int iCount = 0;

                    StringBuilder sql = new StringBuilder();
                    sql.Append("SELECT  DetailsId, LineNumber, STKCODE, APPENDIX1, APPENDIX2, APPENDIX3, ProductName, ");
                    sql.Append(" OrderedQty, UnitCost, DiscountPcn, Notes, ProductId ");
                    sql.Append(" FROM vwPurchaseOrderDetailsList ");
                    sql.Append(" WHERE HeaderId = '").Append(this.OrderHeaderId.ToString()).Append("'");

                    SqlCommand cmd = new SqlCommand();
                    cmd.CommandText    = sql.ToString();
                    cmd.CommandTimeout = ConfigHelper.CommandTimeout;
                    cmd.CommandType    = CommandType.Text;

                    using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(cmd))
                    {
                        while (reader.Read())
                        {
                            ListViewItem listItem = this.lvDetailsList.Items.Add(reader.GetGuid(0).ToString());  //// DetailsId
                            listItem.SubItems.Add((iCount + 1).ToString());                                      //// LN
                            listItem.SubItems.Add(string.Empty);                                                 //// Status
                            listItem.SubItems.Add(reader.GetString(2));                                          //// PLU
                            listItem.SubItems.Add(reader.GetString(3));                                          ////SERSON
                            listItem.SubItems.Add(reader.GetString(4));                                          ////COLOR
                            listItem.SubItems.Add(reader.GetString(5));                                          ////SIZE
                            listItem.SubItems.Add(reader.GetString(6));                                          ////Description
                            listItem.SubItems.Add(reader.GetDecimal(7).ToString("n0"));                          //// OrderedQty
                            listItem.SubItems.Add(reader.GetDecimal(8).ToString("n2"));                          //// UnitCost
                            listItem.SubItems.Add(reader.GetDecimal(9).ToString("n2"));                          //// DiscountPcn
                            listItem.SubItems.Add((reader.GetDecimal(7) * reader.GetDecimal(8)).ToString("n2")); //// Sub Total
                            listItem.SubItems.Add(reader.GetString(10));                                         //// Notes
                            listItem.SubItems.Add(reader.GetGuid(11).ToString());                                //// ProductId

                            iCount++;
                        }
                    }

                    this.lblLineCount.Text = iCount.ToString();
                    #endregion

                    #region load Receiving Qty
                    decimal totalReceivingQty = 0;

                    StringBuilder sql2 = new StringBuilder();
                    sql2.Append("SELECT  ReceiveDetailsId, ReceivedQty ");
                    sql2.Append(" FROM PurchaseOrderReceiveDetails a,PurchaseOrderReceiveHeader b ");
                    sql2.Append(" WHERE a.ReceiveHeaderId = b.ReceiveHeaderId and OrderHeaderId = '").Append(this.OrderHeaderId.ToString()).Append("'");

                    SqlCommand cmd2 = new SqlCommand();
                    cmd2.CommandText    = sql2.ToString();
                    cmd2.CommandTimeout = ConfigHelper.CommandTimeout;
                    cmd2.CommandType    = CommandType.Text;

                    using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(cmd2))
                    {
                        while (reader.Read())
                        {
                            totalReceivingQty += reader.GetDecimal(1);
                        }
                    }

                    this.txtPOReceivingQty.Text = totalReceivingQty.ToString("n0");
                    #endregion

                    //this.LoadPODetailInfo();
                    //this.CalReceivingQty();
                }
            }
        }
Exemplo n.º 19
0
        /**
         * private void UpdateTXFSubLedger(string txnumber_Batch)
         * {
         *  using (var ctx = new EF6.RT2020Entities())
         *  {
         *      var oSubTXF = ctx.InvtSubLedgerTXF_Header.Find(this.TxferId);
         *      if (oSubTXF != null)
         *      {
         *          UpdateTXFSubLedgerDetail(oSubTXF.HeaderId);
         *
         *          oSubTXF.CONFIRM_TRF = this.IsConfirmedTransaction;
         *          oSubTXF.CONFIRM_TRF_LASTUPDATE = DateTime.Now;
         *          oSubTXF.CONFIRM_TRF_LASTUSER = ConfigHelper.CurrentUserId;
         *
         *          oSubTXF.ModifiedBy = ConfigHelper.CurrentUserId;
         *          oSubTXF.ModifiedOn = DateTime.Now;
         *
         *          ctx.SaveChanges();
         *      }
         *  }
         * }
         *
         * private void UpdateTXFSubLedgerDetail(Guid subledgerHeaderId)
         * {
         *  foreach (ListViewItem listItem in lvDetailsList.Items)
         *  {
         *      if (Common.Utility.IsGUID(listItem.SubItems[10].Text))
         *      {
         *          string sql = "HeaderId = '" + subledgerHeaderId.ToString() + "' AND ProductId = '" + listItem.SubItems[10].Text + "'";
         *          InvtSubLedgerTXF_Details oSubLedgerDetail = InvtSubLedgerTXF_Details.LoadWhere(sql);
         *          if (oSubLedgerDetail != null)
         *          {
         *              if (Common.Utility.IsNumeric(listItem.SubItems[9].Text))
         *              {
         *                  oSubLedgerDetail.QtyConfirmed = Convert.ToDecimal(listItem.SubItems[9].Text);
         *
         *                  oSubLedgerDetail.Save();
         *              }
         *          }
         *      }
         *  }
         * }
         */
        #endregion

        #region Ledger

        /**
         * private void UpdateLedger(string txnumber_Batch)
         * {
         *  InvtLedgerHeader oLedgerHeader = InvtLedgerHeader.Load(this.TxferId);
         *  if (oLedgerHeader != null)
         *  {
         *      UpdateLedgerDetails(oLedgerHeader.HeaderId);
         *
         *      oLedgerHeader.CONFIRM_TRF = this.IsConfirmedTransaction;
         *      oLedgerHeader.CONFIRM_TRF_LASTUPDATE = DateTime.Now;
         *      oLedgerHeader.CONFIRM_TRF_LASTUSER = ModelEx.StaffEx.GetStaffNumberById(ConfigHelper.CurrentUserId);
         *
         *      oLedgerHeader.ModifiedBy = ConfigHelper.CurrentUserId;
         *      oLedgerHeader.ModifiedOn = DateTime.Now;
         *      oLedgerHeader.Save();
         *  }
         * }
         *
         * private void UpdateLedgerDetails(Guid ledgerHeaderId)
         * {
         *  foreach (ListViewItem listItem in lvDetailsList.Items)
         *  {
         *      if (Common.Utility.IsGUID(listItem.SubItems[10].Text))
         *      {
         *          string sql = "HeaderId = '" + ledgerHeaderId.ToString() + "' AND ProductId = '" + listItem.SubItems[10].Text + "'";
         *          InvtLedgerDetails oLedgerDetail = InvtLedgerDetails.LoadWhere(sql);
         *          if (oLedgerDetail != null)
         *          {
         *              if (Common.Utility.IsNumeric(listItem.SubItems[9].Text))
         *              {
         *                  oLedgerDetail.Qty = Convert.ToDecimal(listItem.SubItems[9].Text);
         *
         *                  oLedgerDetail.Save();
         *              }
         *          }
         *      }
         *  }
         * }
         */
        #endregion

        #region FEP

        /**
         * private void UpdateFEP()
         * {
         *  FepBatchHeader oFepHeader = FepBatchHeader.Load(this.TxferId);
         *  if (oFepHeader != null)
         *  {
         *      UpdateLedgerDetails(oFepHeader.HeaderId);
         *
         *      oFepHeader.CONFIRM_TRF = this.IsConfirmedTransaction;
         *      oFepHeader.CONFIRM_TRF_LASTUPDATE = DateTime.Now;
         *      oFepHeader.CONFIRM_TRF_LASTUSER = ModelEx.StaffEx.GetStaffNumberById(ConfigHelper.CurrentUserId);
         *
         *      oFepHeader.ModifiedBy = ConfigHelper.CurrentUserId;
         *      oFepHeader.ModifiedOn = DateTime.Now;
         *      oFepHeader.Save();
         *  }
         * }
         *
         * private void UpdateFepDetails(Guid fepHeaderId)
         * {
         *  foreach (ListViewItem listItem in lvDetailsList.Items)
         *  {
         *      if (Common.Utility.IsGUID(listItem.SubItems[10].Text))
         *      {
         *          string sql = "HeaderId = '" + fepHeaderId.ToString() + "' AND ProductId = '" + listItem.SubItems[10].Text + "'";
         *          FepBatchDetail oFepDetail = FepBatchDetail.LoadWhere(sql);
         *          if (oFepDetail != null)
         *          {
         *              if (Common.Utility.IsNumeric(listItem.SubItems[9].Text))
         *              {
         *                  oFepDetail.CONFIRM_TRF_QTY = Convert.ToDecimal(listItem.SubItems[9].Text);
         *
         *                  oFepDetail.Save();
         *              }
         *          }
         *      }
         *  }
         * }
         */
        #endregion

        #region Product

        /**
         * private void UpdateProduct(InvtBatchTXF_Header oBatchHeader)
         * {
         *  string sql = "HeaderId = '" + oBatchHeader.HeaderId.ToString() + "'";
         *  InvtBatchTXF_DetailsCollection detailsList = InvtBatchTXF_Details.LoadCollection(sql);
         *  for (int i = 0; i < detailsList.Count; i++)
         *  {
         *      InvtBatchTXF_Details detail = detailsList[i];
         *      //Out
         *      UpdateProductQty(detail.ProductId, oBatchHeader.FromLocation, detail.QtyConfirmed * (-1));
         *      //In
         *      UpdateProductQty(detail.ProductId, oBatchHeader.ToLocation, detail.QtyConfirmed);
         *  }
         * }
         *
         * private void UpdateProductQty(Guid productId, Guid workplaceId, decimal qty)
         * {
         *  using (var ctx = new EF6.RT2020Entities())
         *  {
         *      //string sql = "ProductId = '" + productId.ToString() + "' AND WorkplaceId = '" + workplaceId.ToString() + "'";
         *      var item = ctx.ProductWorkplace.Where(x => x.ProductId == productId && x.WorkplaceId == workplaceId).FirstOrDefault();
         *      if (item == null)
         *      {
         *          item = new EF6.ProductWorkplace();
         *          item.ProductWorkplaceId = Guid.NewGuid();
         *          item.ProductId = productId;
         *          item.WorkplaceId = workplaceId;
         *          ctx.ProductWorkplace.Add(item);
         *      }
         *      item.CDQTY += qty;
         *      if (qty > 0)
         *      {
         *          item.RECQTY += qty;
         *      }
         *      ctx.SaveChanges();
         *  }
         * }
         */
        #endregion

        #endregion

        #region Load Txfer Header Info
        private void LoadTxferInfo()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var oBatchHeader = ctx.InvtBatchTXF_Header.Find(this.TxferId);
                if (oBatchHeader != null)
                {
                    txtTxNumber.Text = oBatchHeader.TxNumber;
                    txtTxType.Text   = oBatchHeader.TxType;

                    cboFromLocation.SelectedValue = oBatchHeader.FromLocation;
                    cboToLocation.SelectedValue   = oBatchHeader.ToLocation;
                    dtpTxDate.Value = oBatchHeader.TxDate.Value;

                    txtLatestConfirmedOn.Text = DateTimeHelper.DateTimeToString(oBatchHeader.CONFIRM_TRF_LASTUPDATE.Value, false);
                    txtLatestConfirmedBy.Text = StaffEx.GetStaffNumberById(oBatchHeader.CONFIRM_TRF_LASTUSER.Value);

                    txtRecordStatus.Text = string.Format(txtRecordStatus.Text, oBatchHeader.TxType);

                    txtConfirmationStatus.Text = oBatchHeader.CONFIRM_TRF == "Y" ? "Completed" : (oBatchHeader.CONFIRM_TRF.Trim() == "" ? "Unprocessed" : "Incompleted");
                }
                else
                {
                    #region LoadTxferLedgerInfo();
                    var oLedgerHeader = ctx.InvtLedgerHeader.Find(this.TxferId);
                    if (oLedgerHeader != null)
                    {
                        txtTxNumber.Text = oLedgerHeader.TxNumber;
                        txtTxType.Text   = oLedgerHeader.TxType;

                        cboFromLocation.SelectedValue = oLedgerHeader.WorkplaceId;
                        cboToLocation.SelectedValue   = oLedgerHeader.VsLocationId;
                        dtpTxDate.Value = oLedgerHeader.TxDate.Value;

                        txtLatestConfirmedOn.Text = DateTimeHelper.DateTimeToString(oLedgerHeader.CONFIRM_TRF_LASTUPDATE.Value, false);
                        txtLatestConfirmedBy.Text = oLedgerHeader.CONFIRM_TRF_LASTUSER;

                        txtRecordStatus.Text = string.Format(txtRecordStatus.Text, oLedgerHeader.TxType);
                    }
                    #endregion

                    #region LoadTxferFepInfo();
                    var oFepHeader = ctx.FepBatchHeader.Find(this.TxferId);
                    if (oFepHeader != null)
                    {
                        txtTxNumber.Text = oFepHeader.TxNumber;
                        txtTxType.Text   = oFepHeader.TxType;

                        cboFromLocation.SelectedValue = WorkplaceEx.GetWorkplaceIdByCode(oFepHeader.SHOP);
                        cboToLocation.SelectedValue   = WorkplaceEx.GetWorkplaceIdByCode(oFepHeader.FTSHOP);
                        dtpTxDate.Value = oFepHeader.TxDate.Value;

                        txtLatestConfirmedOn.Text = DateTimeHelper.DateTimeToString(oFepHeader.CONFIRM_TRF_LASTUPDATE.Value, false);
                        txtLatestConfirmedBy.Text = oFepHeader.CONFIRM_TRF_LASTUSER;

                        txtRecordStatus.Text = string.Format(txtRecordStatus.Text, oFepHeader.TxType);
                    }
                    #endregion
                }
            }

            BindTxferDetailsInfo();
            CalcTotal();
        }
Exemplo n.º 20
0
 /// <summary>
 /// Loads the name of the staff fuff.
 /// </summary>
 private void LoadLastName()
 {
     this.txtLastUser.Text = StaffEx.GetStaffNumberById(ConfigHelper.CurrentUserId);
 }
Exemplo n.º 21
0
        private void LoadClass()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                switch (_ClassMode)
                {
                case ProductHelper.Classes.Class1:
                    #region LoadClass1();
                    var class1 = ctx.ProductClass1.Find(_ClassId);
                    if (class1 != null)
                    {
                        FillParentClassList();

                        txtCode.Text    = class1.Class1Code;
                        txtInitial.Text = class1.Class1Initial;
                        txtName.Text    = class1.Class1Name;
                        txtNameChs.Text = class1.Class1Name_Chs;
                        txtNameCht.Text = class1.Class1Name_Cht;
                        cboParentClass.SelectedValue = class1.ParentClass.HasValue ? class1.ParentClass : Guid.Empty;
                        cboAltClass.SelectedValue    = class1.AlternateClass.HasValue ? class1.AlternateClass : Guid.Empty;

                        txtLastUpdatedOn.Text = DateTimeHelper.DateTimeToString(class1.ModifiedOn, false);
                        txtCreatedOn.Text     = DateTimeHelper.DateTimeToString(class1.CreatedOn, false);
                        txtLastUpdatedBy.Text = StaffEx.GetStaffNumberById(class1.ModifiedBy);

                        SetCtrlEditable();
                    }
                    break;

                    #endregion
                case ProductHelper.Classes.Class2:
                    #region LoadClass2();
                    var class2 = ctx.ProductClass2.Find(_ClassId);
                    if (class2 != null)
                    {
                        FillParentClassList();

                        txtCode.Text    = class2.Class2Code;
                        txtInitial.Text = class2.Class2Initial;
                        txtName.Text    = class2.Class2Name;
                        txtNameChs.Text = class2.Class2Name_Chs;
                        txtNameCht.Text = class2.Class2Name_Cht;
                        cboParentClass.SelectedValue = class2.ParentClass.HasValue ? class2.ParentClass : Guid.Empty;
                        cboAltClass.SelectedValue    = class2.AlternateClass.HasValue ? class2.AlternateClass : Guid.Empty;

                        txtLastUpdatedOn.Text = DateTimeHelper.DateTimeToString(class2.ModifiedOn, false);
                        txtCreatedOn.Text     = DateTimeHelper.DateTimeToString(class2.CreatedOn, false);
                        txtLastUpdatedBy.Text = StaffEx.GetStaffNumberById(class2.ModifiedBy);

                        SetCtrlEditable();
                    }
                    break;

                    #endregion
                case ProductHelper.Classes.Class3:
                    #region LoadClass3();
                    var class3 = ctx.ProductClass3.Find(_ClassId);
                    if (class3 != null)
                    {
                        FillParentClassList();

                        txtCode.Text    = class3.Class3Code;
                        txtInitial.Text = class3.Class3Initial;
                        txtName.Text    = class3.Class3Name;
                        txtNameChs.Text = class3.Class3Name_Chs;
                        txtNameCht.Text = class3.Class3Name_Cht;
                        cboParentClass.SelectedValue = class3.ParentClass.HasValue ? class3.ParentClass : Guid.Empty;
                        cboAltClass.SelectedValue    = class3.AlternatedClass.HasValue ? class3.AlternatedClass : Guid.Empty;

                        txtLastUpdatedOn.Text = DateTimeHelper.DateTimeToString(class3.ModifiedOn, false);
                        txtCreatedOn.Text     = DateTimeHelper.DateTimeToString(class3.CreatedOn, false);
                        txtLastUpdatedBy.Text = StaffEx.GetStaffNumberById(class3.ModifiedBy);

                        SetCtrlEditable();
                    }
                    break;

                    #endregion
                case ProductHelper.Classes.Class4:
                    #region LoadClass4();
                    var class4 = ctx.ProductClass4.Find(_ClassId);
                    if (class4 != null)
                    {
                        FillParentClassList();

                        txtCode.Text    = class4.Class4Code;
                        txtInitial.Text = class4.Class4Initial;
                        txtName.Text    = class4.Class4Name;
                        txtNameChs.Text = class4.Class4Name_Chs;
                        txtNameCht.Text = class4.Class4Name_Cht;
                        cboParentClass.SelectedValue = class4.ParentClass.HasValue ? class4.ParentClass : Guid.Empty;
                        cboAltClass.SelectedValue    = class4.AlternateClass.HasValue ? class4.AlternateClass : Guid.Empty;

                        txtLastUpdatedOn.Text = DateTimeHelper.DateTimeToString(class4.ModifiedOn, false);
                        txtCreatedOn.Text     = DateTimeHelper.DateTimeToString(class4.CreatedOn, false);
                        txtLastUpdatedBy.Text = StaffEx.GetStaffNumberById(class4.ModifiedBy);

                        SetCtrlEditable();
                    }
                    break;

                    #endregion
                case ProductHelper.Classes.Class5:
                    #region LoadClass5();
                    var class5 = ctx.ProductClass5.Find(_ClassId);
                    if (class5 != null)
                    {
                        FillParentClassList();

                        txtCode.Text    = class5.Class5Code;
                        txtInitial.Text = class5.Class5Initial;
                        txtName.Text    = class5.Class5Name;
                        txtNameChs.Text = class5.Class5Name_Chs;
                        txtNameCht.Text = class5.Class5Name_Cht;
                        cboParentClass.SelectedValue = class5.ParentClass.HasValue ? class5.ParentClass : Guid.Empty;
                        cboAltClass.SelectedValue    = class5.AlternateClass.HasValue ? class5.AlternateClass : Guid.Empty;

                        txtLastUpdatedOn.Text = DateTimeHelper.DateTimeToString(class5.ModifiedOn, false);
                        txtCreatedOn.Text     = DateTimeHelper.DateTimeToString(class5.CreatedOn, false);
                        txtLastUpdatedBy.Text = StaffEx.GetStaffNumberById(class5.ModifiedBy);

                        SetCtrlEditable();
                    }
                    break;

                    #endregion
                case ProductHelper.Classes.Class6:
                    #region LoadClass6();
                    var class6 = ctx.ProductClass6.Find(_ClassId);
                    if (class6 != null)
                    {
                        FillParentClassList();

                        txtCode.Text    = class6.Class6Code;
                        txtInitial.Text = class6.Class6Initial;
                        txtName.Text    = class6.Class6Name;
                        txtNameChs.Text = class6.Class6Name_Chs;
                        txtNameCht.Text = class6.Class6Name_Cht;
                        cboParentClass.SelectedValue = class6.ParentClass.HasValue ? class6.ParentClass : Guid.Empty;
                        cboAltClass.SelectedValue    = class6.AlternateClass.HasValue ? class6.AlternateClass : Guid.Empty;

                        txtLastUpdatedOn.Text = DateTimeHelper.DateTimeToString(class6.ModifiedOn, false);
                        txtCreatedOn.Text     = DateTimeHelper.DateTimeToString(class6.CreatedOn, false);
                        txtLastUpdatedBy.Text = StaffEx.GetStaffNumberById(class6.ModifiedBy);

                        SetCtrlEditable();
                    }
                    break;
                    #endregion
                }
            }
        }