private void UpdateHHtHeader(Guid headerId, int totalLine, int missingLine, decimal totalQty, decimal missingQty)
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var hhtHeader = ctx.StocktakeHeader_HHT.Find(headerId);
                if (hhtHeader != null)
                {
                    hhtHeader.TOTALQTY    = totalQty;
                    hhtHeader.TotalRows   = totalLine;
                    hhtHeader.MissingRows = missingLine;
                    hhtHeader.MissingQty  = missingQty;

                    ctx.SaveChanges();
                }
            }
        }
예제 #2
0
        public static bool SetMetadata(Guid preferenceId, string group, List <KeyValuePair <string, string> > items)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var sp = ctx.StaffPreference.Find(preferenceId);
                if (sp != null)
                {
                    try
                    {
                        if (sp.MetadataXml == string.Empty)
                        {
                            XDocument newXml = new XDocument(
                                new XDeclaration("1.0", "utf-8", "yes"),
                                new XComment("RT2020 User Proference"),
                                new XElement(group));
                            sp.MetadataXml = newXml.ToString();
                            ctx.StaffPreference.Add(sp);
                        }
                        XDocument xmlData = XDocument.Parse(sp.MetadataXml);

                        var target = xmlData.Descendants(group).FirstOrDefault();
                        if (target == null)
                        {
                            target = new XElement(group);
                            xmlData.Element(group).Add(target);
                        }
                        foreach (var item in items)
                        {
                            target.SetAttributeValue(item.Key, item.Value);
                        }

                        sp.MetadataXml = xmlData.ToString();

                        ctx.SaveChanges();
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }

            return(result);
        }
예제 #3
0
            /// <summary>
            /// Queuings the tx number.
            /// </summary>
            /// <typeparam name="T"></typeparam>
            /// <param name="typeName">Name of the type. Enums: EnumHelper.TxType, EnumHelper.POType</param>
            /// <returns>TxNumber</returns>
            public static string QueuingTxNumber <T>(T typeName)
            {
                string query       = " 1 = 1 ";
                string queuingType = string.Empty;

                switch (typeName.GetType().Name)
                {
                case "TxType":
                    EnumHelper.TxType txType = (EnumHelper.TxType)Convert.ChangeType(typeName, typeof(EnumHelper.TxType));
                    query       = "QueuingType = '" + txType.ToString() + "'";
                    queuingType = txType.ToString();
                    break;

                case "POType":
                    EnumHelper.POType poType = (EnumHelper.POType)Convert.ChangeType(typeName, typeof(EnumHelper.POType));
                    query       = "QueuingType = '" + poType.ToString() + "'";
                    queuingType = poType.ToString();
                    break;
                }

                long queuedTxNumber = 1;

                using (var ctx = new EF6.RT2020Entities())
                {
                    var oQueue = ctx.SystemQueue.SqlQuery(
                        String.Format(
                            "Select * from SystemQueue Where {0}",
                            String.IsNullOrEmpty(query) ? "1 = 1" : query
                            ))
                                 .FirstOrDefault();
                    if (oQueue == null)
                    {
                        oQueue             = new EF6.SystemQueue();
                        oQueue.QueueId     = Guid.NewGuid();
                        oQueue.QueuingType = queuingType;
                        oQueue.LastNumber  = "000000000000";
                        ctx.SystemQueue.Add(oQueue);
                    }

                    queuedTxNumber = Convert.ToInt64(oQueue.LastNumber) + 1;

                    oQueue.LastNumber = queuedTxNumber.ToString();
                    ctx.SaveChanges();
                }

                return(queuedTxNumber.ToString().PadLeft(12, '0'));
            }
예제 #4
0
        /// <summary>
        /// Deletes a EF6.EPOSSubLedgerTender object from the database.
        /// </summary>
        /// <param name="tenderId">The primary key value</param>
        public static bool Delete(Guid tenderId)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.EPOSSubLedgerTender.Find(tenderId);
                if (item != null)
                {
                    ctx.EPOSSubLedgerTender.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #5
0
        /// <summary>
        /// Deletes a EF6.PriceManagementReason object from the database.
        /// </summary>
        /// <param name="reasonId">The primary key value</param>
        public static bool Delete(Guid reasonId)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.PriceManagementReason.Find(reasonId);
                if (item != null)
                {
                    ctx.PriceManagementReason.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #6
0
        /// <summary>
        /// Deletes a EF6.ProductAppendix2 object from the database.
        /// </summary>
        /// <param name="appendix2Id">The primary key value</param>
        public static bool Delete(Guid appendix2Id)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.ProductAppendix2.Find(appendix2Id);
                if (item != null)
                {
                    ctx.ProductAppendix2.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #7
0
        /// <summary>
        /// Deletes a EF6.InvtBatchADJ_Header object from the database.
        /// </summary>
        /// <param name="headerId">The primary key value</param>
        public static bool Delete(Guid headerId)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.InvtBatchADJ_Header.Find(headerId);
                if (item != null)
                {
                    ctx.InvtBatchADJ_Header.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #8
0
        public static bool Delete(Guid id)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.SupplierSmartTag.Find(id);
                if (item != null)
                {
                    ctx.SupplierSmartTag.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #9
0
        /// <summary>
        /// Deletes a EF6.PosAnalysisCode object from the database.
        /// </summary>
        /// <param name="analysisCodeId">The primary key value</param>
        public static bool Delete(Guid analysisCodeId)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.PosAnalysisCode.Find(analysisCodeId);
                if (item != null)
                {
                    ctx.PosAnalysisCode.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #10
0
        public static bool ClearLogoInfo(Guid id)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var sys = ctx.SystemInfo.Find(id);
                if (sys != null)
                {
                    sys.LOGO = string.Empty;
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #11
0
        /// <summary>
        /// Deletes a EF6.MemberAddressType object from the database.
        /// </summary>
        /// <param name="addressTypeId">The primary key value</param>
        public static bool Delete(Guid addressTypeId)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.MemberAddressType.Find(addressTypeId);
                if (item != null)
                {
                    ctx.MemberAddressType.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
        /// <summary>
        /// Deletes a EF6.SmartTag4Workplace_Options object from the database.
        /// </summary>
        /// <param name="optionId">The primary key value</param>
        public static bool Delete(Guid optionId)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.SmartTag4Workplace_Options.Find(optionId);
                if (item != null)
                {
                    ctx.SmartTag4Workplace_Options.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #13
0
        /// <summary>
        /// Deletes a EF6.MemberVipLineOfOperation object from the database.
        /// </summary>
        /// <param name="vipLooId">The primary key value</param>
        public static bool Delete(Guid vipLooId)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.MemberVipLineOfOperation.Find(vipLooId);
                if (item != null)
                {
                    ctx.MemberVipLineOfOperation.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #14
0
        /// <summary>
        /// Deletes a EF6.InvtBatchCAP_Details object from the database.
        /// </summary>
        /// <param name="detailsId">The primary key value</param>
        public static bool Delete(Guid detailsId)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.InvtBatchCAP_Details.Find(detailsId);
                if (item != null)
                {
                    ctx.InvtBatchCAP_Details.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #15
0
        public static bool Delete(Guid userId, Guid objectId)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.UserPreference.Where(x => x.UserId == userId && x.PreferenceObjectId == objectId).FirstOrDefault();
                if (item != null)
                {
                    ctx.UserPreference.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #16
0
        /// <summary>
        /// Deletes a EF6.StaffDept object from the database.
        /// </summary>
        /// <param name="deptId">The primary key value</param>
        public static bool Delete(Guid deptId)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.StaffDept.Find(deptId);
                if (item != null)
                {
                    ctx.StaffDept.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #17
0
        /// <summary>
        /// Deletes a EF6.WorkplaceZone object from the database.
        /// </summary>
        /// <param name="zoneId">The primary key value</param>
        public static bool Delete(Guid zoneId)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.WorkplaceZone.Find(zoneId);
                if (item != null)
                {
                    ctx.WorkplaceZone.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #18
0
        /// <summary>
        /// Deletes a EF6.MarketSector object from the database.
        /// </summary>
        /// <param name="marketSectorId">The primary key value</param>
        public static bool Delete(Guid marketSectorId)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.MarketSector.Find(marketSectorId);
                if (item != null)
                {
                    ctx.MarketSector.Remove(item);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
예제 #19
0
        public static bool Delete(Guid id)
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var st = ctx.SupplierTerms.Find(id);
                if (st != null)
                {
                    ctx.SupplierTerms.Remove(st);
                    ctx.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
        private void DeleteHHTRecord(Guid headerId)
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var hhtHeader = ctx.StocktakeHeader_HHT.Find(headerId);
                //StocktakeHeader_HHT hhtHeader = StocktakeHeader_HHT.Load(headerId);
                if (hhtHeader != null)
                {
                    hhtHeader.PostedOn  = DateTime.Now;
                    hhtHeader.Status    = (int)EnumHelper.Status.Draft;
                    hhtHeader.Retired   = true;
                    hhtHeader.RetiredBy = ConfigHelper.CurrentUserId;
                    hhtHeader.RetiredOn = DateTime.Now;

                    ctx.SaveChanges();
                }
            }
        }
예제 #21
0
        private bool SaveAppendix3()
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                EF6.ProductAppendix3 item = null;
                switch (_EditMode)
                {
                case EnumHelper.EditMode.Add:
                    item               = new EF6.ProductAppendix3();
                    item.Appendix3Id   = Guid.NewGuid();
                    item.Appendix3Code = txtCode.Text;
                    item.CreatedBy     = ConfigHelper.CurrentUserId;
                    item.CreatedOn     = DateTime.Now;

                    ctx.ProductAppendix3.Add(item);
                    break;

                case EnumHelper.EditMode.Edit:
                    item = ctx.ProductAppendix3.Find(_AppendixId);
                    break;
                }
                item.Appendix3Initial  = txtInitial.Text;
                item.Appendix3Name     = txtName.Text;
                item.Appendix3Name_Chs = txtNameChs.Text;
                item.Appendix3Name_Cht = txtNameCht.Text;
                if ((Guid)cboParentAppendix.SelectedValue != Guid.Empty)
                {
                    item.ParentAppendix = (Guid)cboParentAppendix.SelectedValue;
                }

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

                ctx.SaveChanges();

                _AppendixId = item.Appendix3Id;

                result = true;
            }

            return(result);
        }
예제 #22
0
        private void DeleteConfirmationHandler(object sender, EventArgs e)
        {
            if (((Form)sender).DialogResult == DialogResult.Yes)
            {
                string picPath = Path.Combine(mstrDirectory, txtPicFileName.Text);
                imgProductPic.ImageName = Path.Combine(VWGContext.Current.Config.GetDirectory("Images"), "no_photo.jpg");

                if (File.Exists(picPath))
                {
                    try
                    {
                        File.Delete(picPath);

                        using (var ctx = new EF6.RT2020Entities())
                        {
                            //string sql = "ProductId = '" + productId.ToString() + "' AND Photo = '" + txtPicFileName.Text + "'";
                            var oRemarks = ctx.ProductRemarks.Where(x => x.ProductId == _ProductId && x.Photo == txtPicFileName.Text).FirstOrDefault();
                            if (oRemarks != null)
                            {
                                oRemarks.Photo  = oRemarks.Photo2;
                                oRemarks.Photo2 = oRemarks.Photo3;
                                oRemarks.Photo3 = oRemarks.Photo4;
                                oRemarks.Photo4 = oRemarks.Photo5;
                                oRemarks.Photo5 = string.Empty;

                                ctx.SaveChanges();

                                imgProductPic.ImageName = Path.Combine("Product", oRemarks.Photo);

                                MessageBox.Show("The picture '" + txtPicFileName.Text + "' is deleted.", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                MessageBox.Show("The picture does not exist in database.", "Delete Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.Message, "Delete Failed!");
                    }
                }
            }
        }
예제 #23
0
 private void Delete()
 {
     using (var ctx = new EF6.RT2020Entities())
     {
         var oPosTenderType = ctx.PosTenderType.Find(_TenderTypeId);
         if (oPosTenderType != null)
         {
             try
             {
                 ctx.PosTenderType.Remove(oPosTenderType);
                 ctx.SaveChanges();
             }
             catch
             {
                 MessageBox.Show("Cannot delete the record being used by other record!", "Delete Warning");
             }
         }
     }
 }
예제 #24
0
        private void ImportProductSupplement(Guid productId, StockCodeRec oRec)
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                //string sql = "ProductId = '" + productId.ToString() + "' AND VendorCurrencyCode = '" + oRec.VCURR + "'";
                var oProdSupp = ctx.ProductSupplement.Where(x => x.ProductId == productId && x.VendorCurrencyCode == oRec.VCURR).FirstOrDefault();
                if (oProdSupp == null)
                {
                    oProdSupp = new EF6.ProductSupplement();
                    oProdSupp.SupplementId       = Guid.NewGuid();
                    oProdSupp.ProductId          = productId;
                    oProdSupp.VendorCurrencyCode = oRec.VCURR;
                    oProdSupp.VendorPrice        = Convert.ToDecimal(oRec.VPRC);

                    ctx.ProductSupplement.Add(oProdSupp);
                    ctx.SaveChanges();
                }
            }
        }
예제 #25
0
 private void Delete()
 {
     using (var ctx = new EF6.RT2020Entities())
     {
         try
         {
             var zone = ctx.WorkplaceZone.Find(this.ZoneId);
             if (zone != null)
             {
                 ctx.WorkplaceZone.Remove(zone);
                 ctx.SaveChanges();
             }
         }
         catch
         {
             MessageBox.Show("Cannot delete the record...Might be in use by other record!", "Delete Warning");
         }
     }
 }
예제 #26
0
        private void CreatedStockTakeDetail(Guid stktkHeaderId, string txNumber, List <ImportDetailsInfo> detailList, Guid workplaceId, DateTime uploadedOn)
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                using (var scope = ctx.Database.BeginTransaction())
                {
                    try
                    {
                        foreach (ImportDetailsInfo detail in detailList)
                        {
                            Guid productId = ProductBarcodeEx.GetProductIdByBarcode(detail.Barcode);

                            if (!string.IsNullOrEmpty(detail.Barcode.Trim()) && productId != Guid.Empty)
                            {
                                //string sql = "HeaderId = '" + stktkHeaderId.ToString() + "' AND TxNumber = '" + txNumber + "' AND ProductId = '" + productId.ToString() + "' AND WorkplaceId = '" + workplaceId.ToString() + "'";
                                var item = ctx.StockTakeDetails.Where(x => x.HeaderId == stktkHeaderId && x.TxNumber == txNumber && x.ProductId == productId && x.WorkplaceId == workplaceId).FirstOrDefault();
                                if (item == null)
                                {
                                    item             = new EF6.StockTakeDetails();
                                    item.DetailsId   = Guid.NewGuid();
                                    item.HeaderId    = stktkHeaderId;
                                    item.TxNumber    = txNumber;
                                    item.ProductId   = productId;
                                    item.WorkplaceId = workplaceId;

                                    item.ModifiedOn = uploadedOn;
                                    item.ModifiedBy = ConfigHelper.CurrentUserId;

                                    ctx.StockTakeDetails.Add(item);
                                }

                                ctx.SaveChanges();
                            }
                        }
                        scope.Commit();
                    }
                    catch (Exception ex)
                    {
                        scope.Rollback();
                    }
                }
            }
        }
예제 #27
0
 private void Delete()
 {
     using (var ctx = new EF6.RT2020Entities())
     {
         var oMemberGroup = ctx.MemberGroup.Find(_GroupId);
         if (oMemberGroup != null)
         {
             try
             {
                 ctx.MemberGroup.Remove(oMemberGroup);
                 ctx.SaveChanges();
             }
             catch
             {
                 MessageBox.Show("Cannot delete the record being used by other record!", "Delete Warning");
             }
         }
     }
 }
예제 #28
0
 private void Delete()
 {
     using (var ctx = new EF6.RT2020Entities())
     {
         try
         {
             var m = ctx.LineOfOperation.Find(this.LineOfOperationId);
             if (m != null)
             {
                 ctx.LineOfOperation.Remove(m);
                 ctx.SaveChanges();
             }
         }
         catch
         {
             MessageBox.Show("Cannot delete the record...Might be in use by other record!", "Delete Warning");
         }
     }
 }
예제 #29
0
 private void Delete()
 {
     using (var ctx = new EF6.RT2020Entities())
     {
         try
         {
             var item = ctx.SmartTag4Staff_Options.Find(_OptionId);
             if (item != null)
             {
                 ctx.SmartTag4Staff_Options.Remove(item);
                 ctx.SaveChanges();
             }
         }
         catch
         {
             MessageBox.Show("Cannot delete the record...Might be in use by other record!", "Delete Warning");
         }
     }
 }
예제 #30
0
        public bool SaveData()
        {
            var result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.Product.Where(x => x.ProductId == _ProductId).FirstOrDefault();
                if (item != null)
                {
                    item.AlternateItem = txtVendorItemNum.Text.Trim();
                    item.ReorderLevel  = DecimalHelper.StringToDecimal(txtReorderLevel.Text);
                    item.ReorderQty    = DecimalHelper.StringToDecimal(txtReorderQuantity.Text);

                    ctx.SaveChanges();
                }
            }

            return(result);
        }