public void UpdateFabItem(tbl_FabricAttriputes objToPost, int userIserial)
        {
            var axapta = new Axapta();

            try
            {
                using (var context = new WorkFlowManagerDBEntities())
                {
                    var credential = new NetworkCredential("bcproxy", "around1");
                    var user       = context.TblAuthUsers.FirstOrDefault(x => x.Iserial == userIserial);

                    axapta.LogonAs(user.User_Win_Login, user.User_Domain, credential, "Ccm", null, null, null);

                    axapta.TTSBegin();
                    var itemId    = objToPost.FabricID;
                    var tableName = "InventTable";

                    var axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();
                    var header = axapta.CallStaticRecordMethod("InventTable", "find", itemId, true) as AxaptaRecord;
                    header.set_Field("ItemName", objToPost.FabricDescription);

                    context.SaveChanges();
                    axapta.TTSCommit();
                }
            }
            catch (Exception ex)
            {
                axapta.TTSAbort();
                throw ex;
            }
        }
        public SearchFabricViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                Client = new CRUD_ManagerServiceClient();

                MainRowList     = new SortableCollectionView <tbl_FabricAttriputes>();
                SelectedMainRow = new tbl_FabricAttriputes();



                Client.GetTblFabricAttriputesCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        MainRowList.Add(row);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                };

                GetMaindata();
            }
        }
 public void UpdateFabAttributes(tbl_FabricAttriputes FabricAttrObj)
 {
     using (WorkFlowManagerDBEntities context = new WorkFlowManagerDBEntities())
     {
         try
         {
             tbl_FabricAttriputes temp = (from x in context.tbl_FabricAttriputes
                                          where x.FabricID == FabricAttrObj.FabricID &&
                                          x.FabricCategoryID == FabricAttrObj.FabricCategoryID
                                          select x).SingleOrDefault();
             temp.FabricDesignsID         = FabricAttrObj.FabricDesignsID;
             temp.FabricFinishesID        = FabricAttrObj.FabricFinishesID;
             temp.FabricID                = FabricAttrObj.FabricID;
             temp.FabricMaterialsID       = FabricAttrObj.FabricMaterialsID;
             temp.FabricStructuresID      = FabricAttrObj.FabricStructuresID;
             temp.FabricTypesID           = FabricAttrObj.FabricTypesID;
             temp.DyingClassificationID   = FabricAttrObj.DyingClassificationID;
             temp.ExpectedDyingLossMargin = FabricAttrObj.ExpectedDyingLossMargin;
             temp.FabricCategoryID        = FabricAttrObj.FabricCategoryID;
             temp.FabricDescription       = FabricAttrObj.FabricDescription;
             temp.HorizontalShrinkage     = FabricAttrObj.HorizontalShrinkage;
             temp.Notes             = FabricAttrObj.Notes;
             temp.Twist             = FabricAttrObj.Twist;
             temp.VerticalShrinkage = FabricAttrObj.VerticalShrinkage;
             temp.WeightPerSquarMeterAfterWashMin = FabricAttrObj.WeightPerSquarMeterAfterWashMin;
             temp.WeightPerSquarMeterAsRawMin     = FabricAttrObj.WeightPerSquarMeterAsRawMin;
             temp.WeightPerSquarMeterBeforWashMin = FabricAttrObj.WeightPerSquarMeterBeforWashMin;
             temp.WidthAsRawMin      = FabricAttrObj.WidthAsRawMin;
             temp.DyedFabricWidthMin = FabricAttrObj.DyedFabricWidthMin;
             temp.WeightPerSquarMeterAfterWashMax = FabricAttrObj.WeightPerSquarMeterAfterWashMax;
             temp.WeightPerSquarMeterAsRawMax     = FabricAttrObj.WeightPerSquarMeterAsRawMax;
             temp.WeightPerSquarMeterBeforWashMax = FabricAttrObj.WeightPerSquarMeterBeforWashMax;
             temp.WidthAsRawMax      = FabricAttrObj.WidthAsRawMax;
             temp.DyedFabricWidthMax = FabricAttrObj.DyedFabricWidthMax;
             temp.UoMID           = FabricAttrObj.UoMID;
             temp.YarnCountID     = FabricAttrObj.YarnCountID;
             temp.YarnFinishesID  = FabricAttrObj.YarnFinishesID;
             temp.GaugesID        = FabricAttrObj.GaugesID;
             temp.ThreadNumbersID = FabricAttrObj.ThreadNumbersID;
             temp.SupplierRef     = FabricAttrObj.SupplierRef;
             temp.InchesID        = FabricAttrObj.InchesID;
             temp.Status          = 3;
             context.SaveChanges();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
 public void DeleteFabAttributes(tbl_FabricAttriputes FabricAttrObj)
 {
     using (WorkFlowManagerDBEntities context = new WorkFlowManagerDBEntities())
     {
         try
         {
             context.tbl_FabricAttriputes.DeleteObject(FabricAttrObj);
             context.SaveChanges();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemple #5
0
 public bool DeleteFabAttributes(tbl_FabricAttriputes fabricAttrObj, int userIserial)
 {
     using (var context = new WorkFlowManagerDBEntities())
     {
         try
         {
             var temp = (from x in context.tbl_FabricAttriputes
                         where x.FabricID == fabricAttrObj.FabricID &&
                         x.FabricCategoryID == fabricAttrObj.FabricCategoryID
                         select x).SingleOrDefault();
             if (temp != null && !DeleteAxFabItem(temp, true, userIserial))
             {
                 context.tbl_FabricAttriputes.DeleteObject(temp);
                 context.SaveChanges();
             }
             return(DeleteAxFabItem(temp, true, userIserial));
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
        public bool DeleteAxFabItem(tbl_FabricAttriputes objToPost, bool deleteColors, int userIserial)
        {
            var axapta = new Axapta();

            try
            {
                var credential = new NetworkCredential("bcproxy", "around1");
                var user       = new TblAuthUser();
                using (var context = new WorkFlowManagerDBEntities())
                {
                    user = context.TblAuthUsers.FirstOrDefault(x => x.Iserial == userIserial);
                }

                axapta.LogonAs(user.User_Win_Login, user.User_Domain, credential, "Ccm", null, null, null);

                axapta.TTSBegin();
                var          itemId = objToPost.FabricID;
                AxaptaRecord axaptaRecord;

                var tableName = "InventTable";
                using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                {
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                    axaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.ItemId =='" + itemId + "'");
                    // If the record is found then delete the record.
                    if (axaptaRecord.Found)
                    {
                        // Start a transaction that can be committed.
                        axapta.TTSBegin();
                        if (objToPost.Notes != null)
                        {
                            axaptaRecord.set_Field("Notes", objToPost.Notes);
                        }
                        // Commit the transaction.
                        axapta.TTSCommit();
                    }
                }

                //tableName = "TblFabricDetail";
                //using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                //{
                //    axaptaRecord.Clear();
                //    axaptaRecord.InitValue();

                //    // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                //    axaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.ItemId =='" + itemId + "'");
                //    // If the record is found then delete the record.
                //    if (axaptaRecord.Found)
                //    {
                //        // Start a transaction that can be committed.
                //        axapta.TTSBegin();
                //        if (objToPost.Notes != null) axaptaRecord.set_Field("Notes", objToPost.Notes);
                //        // Commit the transaction.
                //        axapta.TTSCommit();
                //    }
                //}
                tableName = "INVENTTRANS";
                bool inventTransExists = false;
                using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                {
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                    axaptaRecord.ExecuteStmt("select  * from %1 where %1.ItemId =='" + itemId + "'");
                    // If the record is found then delete the record.
                    if (axaptaRecord.Found)
                    {
                        return(inventTransExists = true);
                    }
                }
                if (!inventTransExists)
                {
                    tableName = "InventTableModule";
                    using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                    {
                        axaptaRecord.Clear();
                        axaptaRecord.InitValue();

                        // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                        axaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.ItemId =='" + itemId + "'");
                        // If the record is found then delete the record.
                        if (axaptaRecord.Found)
                        {
                            // Start a transaction that can be committed.
                            axapta.TTSBegin();
                            axaptaRecord.Delete();
                            // Commit the transaction.
                            axapta.TTSCommit();
                        }
                    }

                    tableName = "InventItemLocation";

                    using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                    {
                        axaptaRecord.Clear();
                        axaptaRecord.InitValue();

                        // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                        axaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.ItemId =='" + itemId + "'");
                        // If the record is found then delete the record.
                        if (axaptaRecord.Found)
                        {
                            // Start a transaction that can be committed.
                            axapta.TTSBegin();
                            axaptaRecord.Delete();
                            // Commit the transaction.
                            axapta.TTSCommit();
                        }
                    }

                    if (deleteColors)
                    {
                        tableName = "ConfigTable";
                        using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                        {
                            axaptaRecord.Clear();
                            axaptaRecord.InitValue();

                            // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                            axaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.ItemId =='" + itemId + "'");
                            // If the record is found then delete the record.
                            if (axaptaRecord.Found)
                            {
                                // Start a transaction that can be committed.
                                axapta.TTSBegin();
                                axaptaRecord.Delete();
                                // Commit the transaction.
                                axapta.TTSCommit();
                            }
                        }
                    }

                    tableName = "InventTable";
                    using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                    {
                        axaptaRecord.Clear();
                        axaptaRecord.InitValue();

                        // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                        axaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.ItemId =='" + itemId + "'");
                        // If the record is found then delete the record.
                        if (axaptaRecord.Found)
                        {
                            // Start a transaction that can be committed.
                            axapta.TTSBegin();
                            axaptaRecord.Delete();
                            // Commit the transaction.
                            axapta.TTSCommit();
                        }
                    }
                    // Commit the record to the database.
                    axapta.TTSCommit();
                }
            }
            catch (Exception ex)
            {
                axapta.TTSAbort();
                throw ex;
            }
            return(false);
        }
        public void InsertFabItem(tbl_FabricAttriputes objToPost, string categoryName, string fabricType, int userIserial)
        {
            var axapta = new Axapta();

            try
            {
                using (var context = new WorkFlowManagerDBEntities())
                {
                    var credential = new NetworkCredential("bcproxy", "around1");
                    var user       = context.TblAuthUsers.FirstOrDefault(x => x.Iserial == userIserial);

                    axapta.LogonAs(user.User_Win_Login, user.User_Domain, credential, "Ccm", null, null, null);

                    axapta.TTSBegin();
                    var itemId    = objToPost.FabricID;
                    var tableName = "InventTable";

                    var axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    if (fabricType != null)
                    {
                        axaptaRecord.set_Field("ItemGroupId",
                                               fabricType.ToUpper() == "KNITTED"
                                ? "KNITTED-FABRIC"
                                : "FINISHED-FABRIC");
                    }
                    else
                    {
                        axaptaRecord.set_Field("ItemGroupId",
                                               categoryName.ToUpper() == "FINISHED"
                                ? "FINISHED-FABRIC"
                                : categoryName.ToUpper() == "RAW"
                                    ? "KNITTED-FABRIC"
                                    : categoryName == "DYINGWOVEN"
                                        ? "FINISHED-FABRIC"
                                        : categoryName == "DYINGKNITED"
                                            ? "FINISHED-FABRIC"
                                            : categoryName == "Accessories"
                                                ? "ACCESSORIES"
                                                : "YARN"
                                               );
                    }
                    if (objToPost.Notes != null)
                    {
                        axaptaRecord.set_Field("Notes", objToPost.Notes);
                    }
                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ItemName", objToPost.FabricDescription);
                    axaptaRecord.set_Field("ModelGroupID", "STD");
                    axaptaRecord.set_Field("ItemType",
                                           categoryName.ToUpper() == "FINISHED"
                            ? 0
                            : categoryName.ToUpper() == "RAW"
                                ? 1
                                : categoryName.ToUpper() == "DYINGWOVEN"
                                    ? 1
                                    : categoryName.ToUpper() == "DYINGKNITED"
                                        ? 1
                                        : 0);

                    if (objToPost.DyingClassificationID != null)
                    {
                        //DyedGroup
                        axaptaRecord.set_Field("DyedGroup", objToPost.DyingClassificationID.ToString());
                    }
                    axaptaRecord.set_Field("DimGroupId", "FABRIC");
                    //Commit the record to the database.
                    axaptaRecord.Insert();

                    tableName    = "InventTableModule";
                    axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ModuleType", 0);
                    axaptaRecord.set_Field("Price", 0.00);
                    if (objToPost.UoMID != null)
                    {
                        var tempu = context.tbl_lkp_UoM
                                    .Where(x => x.Iserial == objToPost.UoMID)
                                    .Select(x => x.Ename)
                                    .SingleOrDefault();
                        axaptaRecord.set_Field("UnitId", tempu);
                        //axaptaRecord.set_Field("PriceUnit", tempu);
                    }
                    //
                    axaptaRecord.Insert();

                    axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ModuleType", 1);
                    axaptaRecord.set_Field("Price", 0.00);
                    if (objToPost.UoMID != null)
                    {
                        var tempu = context.tbl_lkp_UoM
                                    .Where(x => x.Iserial == objToPost.UoMID)
                                    .Select(x => x.Ename)
                                    .SingleOrDefault();
                        axaptaRecord.set_Field("UnitId", tempu);
                        //axaptaRecord.set_Field("PriceUnit", tempu);
                    }
                    //
                    axaptaRecord.Insert();

                    axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ModuleType", 2);
                    axaptaRecord.set_Field("Price", 0.00);
                    if (objToPost.UoMID != null)
                    {
                        var tempu = context.tbl_lkp_UoM
                                    .Where(x => x.Iserial == objToPost.UoMID)
                                    .Select(x => x.Ename)
                                    .SingleOrDefault();
                        axaptaRecord.set_Field("UnitId", tempu);
                        //axaptaRecord.set_Field("PriceUnit", tempu);
                    }
                    //
                    axaptaRecord.Insert();

                    tableName = "InventItemLocation";

                    axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("InventDIMID", "AllBlank");
                    axaptaRecord.Insert();
                    try
                    {
                        tableName    = "ConfigTable";
                        axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                        axaptaRecord.Clear();
                        axaptaRecord.InitValue();

                        axaptaRecord.set_Field("ItemId", itemId);
                        axaptaRecord.set_Field("ConfigId", "Free");
                        axaptaRecord.set_Field("Name", "Free");
                        //Commit the record to the database.
                        axaptaRecord.Insert();
                    }
                    catch
                    {
                        //if record exists do nothing and continue
                    }

                    // Commit the record to the database.
                    var categ = (from x in context.tbl_FabricCategories
                                 where x.Iserial == objToPost.FabricCategoryID
                                 select x).FirstOrDefault();
                    if (categ != null)
                    {
                        try
                        {
                            axapta.CallStaticRecordMethod("TblFabricCategory", "findOrCreate", categ.Iserial, categ.Code,
                                                          categ.Ename, categ.Aname);
                        }
                        catch
                        {
                            //if record exists do nothing and continue
                        }
                    }

                    var temp = (from x in context.tbl_FabricAttriputes
                                .Include("tbl_lkp_FabricDesignes").Include("tbl_lkp_FabricFinish").Include("tbl_lkp_FabricMaterials")
                                .Include("tbl_lkp_FabricStructure").Include("tbl_lkp_FabricTypes").Include("tbl_lkp_Inch").Include("tbl_lkp_Gauges")
                                .Include("tbl_lkp_ThreadNumbers").Include("tbl_lkp_YarnSource").Include("tbl_lkp_YarnCount").Include("tbl_lkp_YarnFinish")
                                .Include("tbl_lkp_YarnStatus")
                                where x.FabricCategoryID == objToPost.FabricCategoryID &&
                                x.FabricID == objToPost.FabricID
                                select x).FirstOrDefault();

                    if (temp != null)
                    {
                        if (temp.tbl_lkp_FabricDesignes != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblFabricDesign", "findOrCreate", temp.tbl_lkp_FabricDesignes.Iserial, temp.tbl_lkp_FabricDesignes.Code,
                                                              temp.tbl_lkp_FabricDesignes.Ename, temp.tbl_lkp_FabricDesignes.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_FabricFinish != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblFabricFinish", "findOrCreate", temp.tbl_lkp_FabricFinish.Iserial, temp.tbl_lkp_FabricFinish.Code,
                                                              temp.tbl_lkp_FabricFinish.Ename, temp.tbl_lkp_FabricFinish.Aname);
                            }
                            catch
                            {
                            }
                        }
                        if (temp.tbl_lkp_FabricMaterials != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblFabricMaterial", "findOrCreate", temp.tbl_lkp_FabricMaterials.Iserial, temp.tbl_lkp_FabricMaterials.Code,
                                                              temp.tbl_lkp_FabricMaterials.Ename, temp.tbl_lkp_FabricMaterials.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_FabricStructure != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblFabricStructure", "findOrCreate", temp.tbl_lkp_FabricStructure.Iserial, temp.tbl_lkp_FabricStructure.Code,
                                                              temp.tbl_lkp_FabricStructure.Ename, temp.tbl_lkp_FabricStructure.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_FabricTypes != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblFabricType", "findOrCreate", temp.tbl_lkp_FabricTypes.Iserial, temp.tbl_lkp_FabricTypes.Code,
                                                              temp.tbl_lkp_FabricTypes.Ename, temp.tbl_lkp_FabricTypes.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_Inch != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblInch", "findOrCreate", temp.tbl_lkp_Inch.Iserial, temp.tbl_lkp_Inch.Code,
                                                              temp.tbl_lkp_Inch.Ename, temp.tbl_lkp_Inch.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_Gauges != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblGuage", "findOrCreate", temp.tbl_lkp_Gauges.Iserial, temp.tbl_lkp_Gauges.Code,
                                                              temp.tbl_lkp_Gauges.Ename, temp.tbl_lkp_Gauges.Aname);
                            }
                            catch
                            {
                            }
                        }
                        if (temp.tbl_lkp_ThreadNumbers != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblThread", "findOrCreate", temp.tbl_lkp_ThreadNumbers.Iserial, temp.tbl_lkp_ThreadNumbers.Code,
                                                              temp.tbl_lkp_ThreadNumbers.Ename, temp.tbl_lkp_ThreadNumbers.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_YarnSource != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblYarnSource", "findOrCreate", temp.tbl_lkp_YarnSource.Iserial, temp.tbl_lkp_YarnSource.Code,
                                                              temp.tbl_lkp_YarnSource.Ename, temp.tbl_lkp_YarnSource.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_YarnCount != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblYarnCount", "findOrCreate", temp.tbl_lkp_YarnCount.Iserial, temp.tbl_lkp_YarnCount.Code,
                                                              temp.tbl_lkp_YarnCount.Ename, temp.tbl_lkp_YarnCount.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_YarnFinish != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblYarnFinish", "findOrCreate", temp.tbl_lkp_YarnFinish.Iserial, temp.tbl_lkp_YarnFinish.Code,
                                                              temp.tbl_lkp_YarnFinish.Ename, temp.tbl_lkp_YarnFinish.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_YarnStatus != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblYarnStatus", "findOrCreate", temp.tbl_lkp_YarnStatus.Iserial, temp.tbl_lkp_YarnStatus.Code,
                                                              temp.tbl_lkp_YarnStatus.Ename, temp.tbl_lkp_YarnStatus.Aname);
                            }
                            catch
                            {
                            }
                        }

                        axapta.CallStaticRecordMethod("TblFabricDetail", "findOrCreate", temp.FabricID, temp.YarnStatusID ?? 0, temp.YarnFinishesID ?? 0, temp.YarnCountID ?? 0, temp.YarnSource ?? 0, temp.ThreadNumbersID ?? 0, temp.GaugesID ?? 0,
                                                      temp.InchesID ?? 0, temp.FabricTypesID ?? 0, temp.FabricStructuresID ?? 0, temp.FabricMaterialsID ?? 0, temp.FabricFinishesID ?? 0, temp.FabricDesignsID ?? 0, temp.FabricCategoryID
                                                      );

                        temp.Status = 2;
                    }

                    context.SaveChanges();
                    axapta.TTSCommit();
                }
            }
            catch (Exception ex)
            {
                axapta.TTSAbort();
                throw ex;
            }
        }
Exemple #8
0
        public bool UpdateWFFabAttributes(tbl_FabricAttriputes fabricAttrObj, int userIserial)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                try
                {
                    var temp = (from x in context.tbl_FabricAttriputes.Include("FabricContentsCompositions")
                                where x.FabricID == fabricAttrObj.FabricID &&
                                x.FabricCategoryID == fabricAttrObj.FabricCategoryID
                                select x).SingleOrDefault();

                    //var inventTransExists = DeleteAxFabItem(temp, true, userIserial);
                    var inventTransExists = false;
                    if (!inventTransExists)
                    {
                        foreach (var item in temp.FabricContentsCompositions.ToList())
                        {
                            context.DeleteObject(item);
                        }
                        var fabCategoryTemp =
                            fabricAttrObj.FabricCategoryID == 3 ? "FINISHED" :
                            fabricAttrObj.FabricCategoryID == 2 ? "Knited" :
                            fabricAttrObj.FabricCategoryID == 4 ? "DyingKnited" :
                            fabricAttrObj.FabricCategoryID == 5 ? "DyingWoven" :
                            "YARN";
                        var fabricMaterialsProp =
                            context.tbl_lkp_FabricMaterials.FirstOrDefault(
                                x => x.Iserial == fabricAttrObj.FabricMaterialsID);
                        temp.Status = 3;
                        if (temp.Notes != fabricAttrObj.Notes)
                        {
                            temp.Notes = fabricAttrObj.Notes;
                            fabricAttrObj.NoteUpdatedDate = DateTime.Now;

                            context.tbl_FabricAttriputesNotesLog.AddObject(new tbl_FabricAttriputesNotesLog
                            {
                                FabricID        = fabricAttrObj.FabricID,
                                NoteUpdatedDate = fabricAttrObj.NoteUpdatedDate,
                                Notes           = fabricAttrObj.Notes,
                            });
                        }

                        GenericUpdate(temp, fabricAttrObj, context);

                        context.SaveChanges();
                        //InsertFabItem(fabricAttrObj, fabCategoryTemp, fabricMaterialsProp != null ? fabricMaterialsProp.Ename : null, userIserial);
                    }
                    return(inventTransExists);

                    //temp.FabricDesignsID = FabricAttrObj.FabricDesignsID;
                    //temp.FabricFinishesID = FabricAttrObj.FabricFinishesID;
                    //temp.FabricID = FabricAttrObj.FabricID;
                    //temp.FabricMaterialsID = FabricAttrObj.FabricMaterialsID;
                    //temp.FabricStructuresID = FabricAttrObj.FabricStructuresID;
                    //temp.FabricTypesID = FabricAttrObj.FabricTypesID;
                    //temp.DyingClassificationID = FabricAttrObj.DyingClassificationID;
                    //temp.ExpectedDyingLossMargin = FabricAttrObj.ExpectedDyingLossMargin;
                    //temp.FabricCategoryID = FabricAttrObj.FabricCategoryID;
                    //temp.FabricDescription = FabricAttrObj.FabricDescription;
                    //temp.HorizontalShrinkage = FabricAttrObj.HorizontalShrinkage;
                    //temp.Notes = FabricAttrObj.Notes;
                    //temp.Twist = FabricAttrObj.Twist;
                    //temp.VerticalShrinkage = FabricAttrObj.VerticalShrinkage;
                    //temp.WeightPerSquarMeterAfterWashMin = FabricAttrObj.WeightPerSquarMeterAfterWashMin;
                    //temp.WeightPerSquarMeterAsRawMin = FabricAttrObj.WeightPerSquarMeterAsRawMin;
                    //temp.WeightPerSquarMeterBeforWashMin = FabricAttrObj.WeightPerSquarMeterBeforWashMin;
                    //temp.WidthAsRawMin = FabricAttrObj.WidthAsRawMin;
                    //temp.DyedFabricWidthMin = FabricAttrObj.DyedFabricWidthMin;
                    //temp.WeightPerSquarMeterAfterWashMax = FabricAttrObj.WeightPerSquarMeterAfterWashMax;
                    //temp.WeightPerSquarMeterAsRawMax = FabricAttrObj.WeightPerSquarMeterAsRawMax;
                    //temp.WeightPerSquarMeterBeforWashMax = FabricAttrObj.WeightPerSquarMeterBeforWashMax;
                    //temp.WidthAsRawMax = FabricAttrObj.WidthAsRawMax;
                    //temp.DyedFabricWidthMax = FabricAttrObj.DyedFabricWidthMax;
                    //temp.UoMID = FabricAttrObj.UoMID;
                    //temp.YarnCountID = FabricAttrObj.YarnCountID;
                    //temp.YarnFinishesID = FabricAttrObj.YarnFinishesID;
                    //temp.GaugesID = FabricAttrObj.GaugesID;
                    //temp.ThreadNumbersID = FabricAttrObj.ThreadNumbersID;
                    //temp.SupplierRef = FabricAttrObj.SupplierRef;
                    //temp.InchesID = FabricAttrObj.InchesID;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemple #9
0
 public string AddFabAttributes(tbl_FabricAttriputes FabricAttrObj, int _FabCategoryID, bool OverrideCheck)
 {
     using (var context = new WorkFlowManagerDBEntities())
     {
         try
         {
             var fabConfigs =
                 context.tbl_FabricCodingConfigurations.SingleOrDefault(x => x.FabricCategoryID == _FabCategoryID);
             if (_FabCategoryID == 4 || _FabCategoryID == 5)
             {
                 FabricAttrObj.FabricID = FabricAttrObj.FabricID + "D";
                 var temp = (from x in context.tbl_FabricAttriputes
                             where x.FabricCategoryID == _FabCategoryID &&
                             x.FabricID == FabricAttrObj.FabricID
                             select x).SingleOrDefault();
                 if (temp != null)
                 {
                     throw new Exception("Warning Code: FS-SIEX-1\n The data you are trying to add already exists in the database!");
                 }
             }
             else
             {
                 FabricAttrObj.FabricID = fabConfigs.NextFabID.ToString();
                 fabConfigs.NextFabID  += 1;
             }
             var tempQuery = new List <tbl_FabricAttriputes>();
             if (!OverrideCheck)
             {
                 tempQuery = (from x in context.tbl_FabricAttriputes.ToList()
                              where x.DyedFabricWidthMin == FabricAttrObj.DyedFabricWidthMin &&
                              x.DyedFabricWidthMax == FabricAttrObj.DyedFabricWidthMax &&
                              x.DyingClassificationID == FabricAttrObj.DyingClassificationID &&
                              x.ExpectedDyingLossMargin == FabricAttrObj.ExpectedDyingLossMargin &&
                              x.FabricCategoryID == _FabCategoryID &&
                              x.FabricDescription == FabricAttrObj.FabricDescription &&
                              x.FabricDesignsID == FabricAttrObj.FabricDesignsID &&
                              x.FabricFinishesID == FabricAttrObj.FabricFinishesID &&
                              x.FabricMaterialsID == FabricAttrObj.FabricMaterialsID &&
                              x.FabricStructuresID == FabricAttrObj.FabricStructuresID &&
                              x.FabricTypesID == FabricAttrObj.FabricTypesID &&
                              x.GaugesID == FabricAttrObj.GaugesID &&
                              x.HorizontalShrinkage == FabricAttrObj.HorizontalShrinkage &&
                              x.SupplierRef == FabricAttrObj.SupplierRef &&
                              x.ThreadNumbersID == FabricAttrObj.ThreadNumbersID &&
                              x.Twist == FabricAttrObj.Twist &&
                              x.UoMID == FabricAttrObj.UoMID &&
                              x.VerticalShrinkage == FabricAttrObj.VerticalShrinkage &&
                              x.WeightPerSquarMeterAfterWashMin == FabricAttrObj.WeightPerSquarMeterAfterWashMin &&
                              x.WeightPerSquarMeterAsRawMin == FabricAttrObj.WeightPerSquarMeterAsRawMin &&
                              x.WeightPerSquarMeterBeforWashMin == FabricAttrObj.WeightPerSquarMeterBeforWashMin &&
                              x.WidthAsRawMin == FabricAttrObj.WidthAsRawMin &&
                              x.WeightPerSquarMeterAfterWashMax == FabricAttrObj.WeightPerSquarMeterAfterWashMax &&
                              x.WeightPerSquarMeterAsRawMax == FabricAttrObj.WeightPerSquarMeterAsRawMax &&
                              x.WeightPerSquarMeterBeforWashMax == FabricAttrObj.WeightPerSquarMeterBeforWashMax &&
                              x.HorizontalShrinkageMax == FabricAttrObj.HorizontalShrinkageMax &&
                              x.VerticalShrinkageMax == FabricAttrObj.VerticalShrinkageMax &&
                              x.WidthAsRawMax == FabricAttrObj.WidthAsRawMax &&
                              x.YarnCountID == FabricAttrObj.YarnCountID &&
                              x.YarnFinishesID == FabricAttrObj.YarnFinishesID &&
                              x.YarnSource == FabricAttrObj.YarnSource &&
                              x.YarnStatusID == FabricAttrObj.YarnStatusID &&
                              x.SupplierRef == FabricAttrObj.SupplierRef &&
                              x.InchesID == FabricAttrObj.InchesID &&
                              x.TubularWidth == FabricAttrObj.TubularWidth &&
                              x.NoteUpdatedDate == FabricAttrObj.NoteUpdatedDate &&
                              x.IsPartialDetails == FabricAttrObj.IsPartialDetails &&
                              x.Colored == FabricAttrObj.Colored
                              select x).ToList();
             }
             if (tempQuery.Count < 1)
             {
                 FabricAttrObj.Status = 1;
                 if (FabricAttrObj.FabricMaterialsID == null)
                 {
                     FabricAttrObj.FabricMaterialsID = 5;
                 }
                 context.tbl_FabricAttriputes.AddObject(FabricAttrObj);
                 context.SaveChanges();
                 return(FabricAttrObj.FabricID);
             }
             throw new
                   Exception
                       ("Warning Code: FS-SIEX-2\nThe combination you are trying to save for this category already exists for item \""
                       + tempQuery[0].FabricID + "\"");
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }