Beispiel #1
0
        Int64 IPRMSupplierItemCategoryMapDataAccess.Add(PRMSupplierItemCategoryMapEntity pRMSupplierItemCategoryMapEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

                switch (reqTran)
                {
                case TransactionRequired.No:
                {
                    retValues = Add(pRMSupplierItemCategoryMapEntity, option);
                    break;
                }

                case TransactionRequired.Yes:
                {
                    retValues = AddTran(pRMSupplierItemCategoryMapEntity, option);
                    break;
                }

                default:
                {
                    retValues = -99;
                    break;
                }
                }

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void SavePRMSupplierItemCategoryMapEntity()
        {
            if (IsValid)
            {
                try
                {
                    IList <PRMSupplierItemCategoryMapEntity> newMappedItems = new List <PRMSupplierItemCategoryMapEntity>();

                    foreach (ListItem chbxItem in chbxItemCategory.Items)
                    {
                        if (chbxItem.Selected)
                        {
                            PRMSupplierItemCategoryMapEntity pRMItemCategoryMapEntity = new PRMSupplierItemCategoryMapEntity();
                            pRMItemCategoryMapEntity.SupplierItemCategoryID = Int64.Parse(chbxItem.Value.ToString());
                            pRMItemCategoryMapEntity.SupplierID             = this.OverviewSupplierID;
                            newMappedItems.Add(pRMItemCategoryMapEntity);
                        }
                    }

                    IList <PRMSupplierItemCategoryMapEntity> deleteList = _CurrentSupplierItemCategoryList.Except(newMappedItems, new CustomerComparer()).ToList();
                    IList <PRMSupplierItemCategoryMapEntity> addNewList = newMappedItems.Except(_CurrentSupplierItemCategoryList, new CustomerComparer()).ToList();

                    if (deleteList != null && deleteList.Count > 0)
                    {
                        foreach (PRMSupplierItemCategoryMapEntity ent in deleteList)
                        {
                            String fe1 = SqlExpressionBuilder.PrepareFilterExpression(PRMSupplierItemCategoryMapEntity.FLD_NAME_SupplierID, ent.SupplierID.ToString(), SQLMatchType.Equal);
                            String fe2 = SqlExpressionBuilder.PrepareFilterExpression(PRMSupplierItemCategoryMapEntity.FLD_NAME_SupplierItemCategoryID, ent.SupplierItemCategoryID.ToString(), SQLMatchType.Equal);
                            String fe  = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2);

                            FCCPRMSupplierItemCategoryMap.GetFacadeCreate().Delete(ent, fe, DatabaseOperationType.Delete, TransactionRequired.No);
                        }
                    }

                    if (addNewList != null && addNewList.Count > 0)
                    {
                        foreach (PRMSupplierItemCategoryMapEntity ent in addNewList)
                        {
                            FCCPRMSupplierItemCategoryMap.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No);
                        }
                    }

                    MiscUtil.ShowMessage(lblMessage, "Vendor Item Category Map Information has been added successfully.", false);
                    BindList();
                    //_CurrentSupplierItemCategoryList = new List<PRMSupplierItemCategoryMapEntity>();
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Beispiel #3
0
        private Int64 UpdateTran(PRMSupplierItemCategoryMapEntity pRMSupplierItemCategoryMapEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMSupplierItemCategoryMap_SET";

            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand cmd = db.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option, db);
                AddOutputParameter(cmd, db);
                AddFilterExpressionParameter(cmd, filterExpression, db);

                db.AddInParameter(cmd, "@SupplierItemCategoryMapID", DbType.Int64, pRMSupplierItemCategoryMapEntity.SupplierItemCategoryMapID);
                db.AddInParameter(cmd, "@SupplierItemCategoryID", DbType.Int64, pRMSupplierItemCategoryMapEntity.SupplierItemCategoryID);
                db.AddInParameter(cmd, "@SupplierID", DbType.Int64, pRMSupplierItemCategoryMapEntity.SupplierID);

                DbConnection connection = db.CreateConnection();
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    using (IDataReader reader = db.ExecuteReader(cmd, transaction))
                    {
                        returnCode = GetReturnCodeFromParameter(cmd);
                    }

                    if (returnCode > 0)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        throw new ArgumentException("Error Code." + returnCode.ToString());
                    }
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
                finally
                {
                    transaction.Dispose();
                    connection.Close();
                    connection = null;
                }
            }

            return(returnCode);
        }
Beispiel #4
0
        private Int64 Update(PRMSupplierItemCategoryMapEntity pRMSupplierItemCategoryMapEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMSupplierItemCategoryMap_SET";

            using (DbCommand cmd = Database.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd);
                AddFilterExpressionParameter(cmd, filterExpression);

                Database.AddInParameter(cmd, "@SupplierItemCategoryMapID", DbType.Int64, pRMSupplierItemCategoryMapEntity.SupplierItemCategoryMapID);
                Database.AddInParameter(cmd, "@SupplierItemCategoryID", DbType.Int64, pRMSupplierItemCategoryMapEntity.SupplierItemCategoryID);
                Database.AddInParameter(cmd, "@SupplierID", DbType.Int64, pRMSupplierItemCategoryMapEntity.SupplierID);

                using (IDataReader reader = Database.ExecuteReader(cmd))
                {
                    returnCode = GetReturnCodeFromParameter(cmd);

                    switch (returnCode)
                    {
                    case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST:
                    {
                        throw new ArgumentException("PRMSupplierItemCategoryMapEntity already exists. Please specify another PRMSupplierItemCategoryMapEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("PRMSupplierItemCategoryMapEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("PRMSupplierItemCategoryMapEntity already exists. Please specify another PRMSupplierItemCategoryMapEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
        private PRMSupplierItemCategoryMapEntity BuildPRMSupplierItemCategoryMapEntity()
        {
            PRMSupplierItemCategoryMapEntity pRMSupplierItemCategoryMapEntity = CurrentPRMSupplierItemCategoryMapEntity;

            return(pRMSupplierItemCategoryMapEntity);
        }
 private void PrepareEditView()
 {
     PRMSupplierItemCategoryMapEntity pRMSupplierItemCategoryMapEntity = CurrentPRMSupplierItemCategoryMapEntity;
 }
 Int64 IPRMSupplierItemCategoryMapFacade.Delete(PRMSupplierItemCategoryMapEntity pRMSupplierItemCategoryMapEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreatePRMSupplierItemCategoryMapDataAccess().Delete(pRMSupplierItemCategoryMapEntity, filterExpression, option, reqTran));
 }
 Int64 IPRMSupplierItemCategoryMapFacade.Add(PRMSupplierItemCategoryMapEntity pRMSupplierItemCategoryMapEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreatePRMSupplierItemCategoryMapDataAccess().Add(pRMSupplierItemCategoryMapEntity, option, reqTran));
 }