Esempio n. 1
0
        Int64 IMDItemGroupItemCategoryMapDataAccess.Add(MDItemGroupItemCategoryMapEntity mDItemGroupItemCategoryMapEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void lstBxItemGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            String fe = SqlExpressionBuilder.PrepareFilterExpression(MDItemGroupItemCategoryMapEntity.FLD_NAME_ItemGroupID, lstBxItemGroup.SelectedValue.ToString(), SQLMatchType.Equal);
            IList <MDItemGroupItemCategoryMapEntity> ItemCategoryList = FCCMDItemGroupItemCategoryMap.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);

            _CurrentItemGroupItemCategoryMapList = ItemCategoryList;

            if (ItemCategoryList != null && ItemCategoryList.Count > 0)
            {
                foreach (MDItemGroupItemCategoryMapEntity ent in ItemCategoryList)
                {
                    foreach (ListItem chbxItem in chbxItemCategroy.Items)
                    {
                        if (ent.ItemCategoryID.ToString() == chbxItem.Value.ToString())
                        {
                            chbxItem.Selected = true;
                            break;
                        }
                    }
                }
                IList <MDItemGroupItemCategoryMapEntity> TempitemGroupList = new List <MDItemGroupItemCategoryMapEntity>();
                if (_CurrentItemCategoryList != null && _CurrentItemCategoryList.Count > 0)
                {
                    foreach (MDItemCategoryEntity ent in _CurrentItemCategoryList)
                    {
                        MDItemGroupItemCategoryMapEntity mDItemGroupEntity = new MDItemGroupItemCategoryMapEntity();
                        mDItemGroupEntity.ItemCategoryID = ent.ItemCategoryID;
                        TempitemGroupList.Add(mDItemGroupEntity);
                    }

                    IList <MDItemGroupItemCategoryMapEntity> uncheckedList = TempitemGroupList.Except(_CurrentItemGroupItemCategoryMapList, new CustomerComparerAnother()).ToList();

                    if (uncheckedList != null && uncheckedList.Count > 0)
                    {
                        foreach (MDItemGroupItemCategoryMapEntity ent in uncheckedList)
                        {
                            foreach (ListItem chbxItem in chbxItemCategroy.Items)
                            {
                                if (ent.ItemCategoryID.ToString() == chbxItem.Value.ToString())
                                {
                                    chbxItem.Selected = false;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (ListItem chbxItem in chbxItemCategroy.Items)
                {
                    chbxItem.Selected = false;
                }
            }
        }
Esempio n. 3
0
        private Int64 UpdateTran(MDItemGroupItemCategoryMapEntity mDItemGroupItemCategoryMapEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.MDItemGroupItemCategoryMap_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, "@ItemGroupItemCategoryMapID", DbType.Int64, mDItemGroupItemCategoryMapEntity.ItemGroupItemCategoryMapID);
                db.AddInParameter(cmd, "@ItemGroupID", DbType.Int64, mDItemGroupItemCategoryMapEntity.ItemGroupID);
                db.AddInParameter(cmd, "@ItemCategoryID", DbType.Int64, mDItemGroupItemCategoryMapEntity.ItemCategoryID);

                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);
        }
        private void UpdateMDItemGroupItemCategoryMapEntity()
        {
            if (IsValid)
            {
                try
                {
                    IList <MDItemGroupItemCategoryMapEntity> newMappedItems = new List <MDItemGroupItemCategoryMapEntity>();

                    foreach (ListItem chbxItem in chbxItemCategroy.Items)
                    {
                        if (chbxItem.Selected)
                        {
                            MDItemGroupItemCategoryMapEntity mDItemGroupItemCategoryMapEntity = new MDItemGroupItemCategoryMapEntity();
                            mDItemGroupItemCategoryMapEntity.ItemGroupID    = Int64.Parse(lstBxItemGroup.SelectedValue.ToString());
                            mDItemGroupItemCategoryMapEntity.ItemCategoryID = Int64.Parse(chbxItem.Value.ToString());
                            newMappedItems.Add(mDItemGroupItemCategoryMapEntity);
                        }
                    }

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

                    if (deleteList != null && deleteList.Count > 0)
                    {
                        foreach (MDItemGroupItemCategoryMapEntity ent in deleteList)
                        {
                            String fe1 = SqlExpressionBuilder.PrepareFilterExpression(MDItemGroupItemCategoryMapEntity.FLD_NAME_ItemCategoryID, ent.ItemCategoryID.ToString(), SQLMatchType.Equal);
                            String fe2 = SqlExpressionBuilder.PrepareFilterExpression(MDItemGroupItemCategoryMapEntity.FLD_NAME_ItemGroupID, ent.ItemGroupID.ToString(), SQLMatchType.Equal);
                            String fe  = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2);

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

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

                    MiscUtil.ShowMessage(lblMessage, "Item Group Item Category Map Information has been updated successfully.", false);
                    _CurrentItemGroupItemCategoryMapList = new List <MDItemGroupItemCategoryMapEntity>();
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Esempio n. 5
0
        private Int64 Update(MDItemGroupItemCategoryMapEntity mDItemGroupItemCategoryMapEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.MDItemGroupItemCategoryMap_SET";

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

                Database.AddInParameter(cmd, "@ItemGroupItemCategoryMapID", DbType.Int64, mDItemGroupItemCategoryMapEntity.ItemGroupItemCategoryMapID);
                Database.AddInParameter(cmd, "@ItemGroupID", DbType.Int64, mDItemGroupItemCategoryMapEntity.ItemGroupID);
                Database.AddInParameter(cmd, "@ItemCategoryID", DbType.Int64, mDItemGroupItemCategoryMapEntity.ItemCategoryID);

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

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

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

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

            return(returnCode);
        }
        private MDItemGroupItemCategoryMapEntity BuildMDItemGroupItemCategoryMapEntity()
        {
            MDItemGroupItemCategoryMapEntity mDItemGroupItemCategoryMapEntity = CurrentMDItemGroupItemCategoryMapEntity;

            return(mDItemGroupItemCategoryMapEntity);
        }
 private void PrepareEditView()
 {
     MDItemGroupItemCategoryMapEntity mDItemGroupItemCategoryMapEntity = CurrentMDItemGroupItemCategoryMapEntity;
 }
Esempio n. 8
0
 Int64 IMDItemGroupItemCategoryMapFacade.Delete(MDItemGroupItemCategoryMapEntity mDItemGroupItemCategoryMapEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateMDItemGroupItemCategoryMapDataAccess().Delete(mDItemGroupItemCategoryMapEntity, filterExpression, option, reqTran));
 }
Esempio n. 9
0
 Int64 IMDItemGroupItemCategoryMapFacade.Add(MDItemGroupItemCategoryMapEntity mDItemGroupItemCategoryMapEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateMDItemGroupItemCategoryMapDataAccess().Add(mDItemGroupItemCategoryMapEntity, option, reqTran));
 }