예제 #1
0
        Int64 IINVStoreDataAccess.Add(INVStoreEntity iNVStoreEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        private void PrepareEditView()
        {
            INVStoreEntity iNVStoreEntity = CurrentINVStoreEntity;


            if (!iNVStoreEntity.IsNew)
            {
                if (ddlProjectID.Items.Count > 0 && iNVStoreEntity.ProjectID != null)
                {
                    ddlProjectID.SelectedValue = iNVStoreEntity.ProjectID.ToString();
                }

                if (ddlDepartmentID.Items.Count > 0 && iNVStoreEntity.DepartmentID != null)
                {
                    ddlDepartmentID.SelectedValue = iNVStoreEntity.DepartmentID.ToString();
                }

                if (ddlStoreInChargeEmployeeID.Items.Count > 0 && iNVStoreEntity.StoreInChargeEmployeeID != null)
                {
                    ddlStoreInChargeEmployeeID.SelectedValue = iNVStoreEntity.StoreInChargeEmployeeID.ToString();
                }

                txtName.Text             = iNVStoreEntity.Name.ToString();
                txtStoreTrackNumber.Text = iNVStoreEntity.StoreTrackNumber.ToString();
                txtLocation.Text         = iNVStoreEntity.Location.ToString();
                txtDescription.Text      = iNVStoreEntity.Description.ToString();
                txtCreateDate.Text       = iNVStoreEntity.CreateDate.ToStringDefault();
                chkIsRemoved.Checked     = iNVStoreEntity.IsRemoved;
                chkIsDefault.Checked     = iNVStoreEntity.IsDefault;

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
예제 #3
0
        public static Int64 CreateStore(Int64 projectID, Int64 departmentID, Int64 storeInChargeEmployeeID, String name, String storeTracNumber, String location, String description)
        {
            Int64 storeID = 0;

            try
            {
                INVStoreEntity ent = new INVStoreEntity();

                ent.ProjectID               = projectID;
                ent.DepartmentID            = departmentID;
                ent.StoreInChargeEmployeeID = storeInChargeEmployeeID;
                ent.Name             = name;
                ent.StoreTrackNumber = storeTracNumber;
                ent.Location         = location;
                ent.Description      = description;
                ent.CreateDate       = DateTime.Now;
                ent.IsRemoved        = false;

                storeID = FCCINVStore.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No);
            }
            catch (Exception ex)
            {
            }

            return(storeID);
        }
예제 #4
0
        Int64 IINVStoreDataAccess.Delete(INVStoreEntity iNVStoreEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

                switch (reqTran)
                {
                case TransactionRequired.No:
                {
                    retValues = Delete(iNVStoreEntity, filterExpression, option);
                    break;
                }

                case TransactionRequired.Yes:
                {
                    retValues = DeleteTran(iNVStoreEntity, filterExpression, option);
                    break;
                }

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #5
0
        private Int64 UpdateTran(INVStoreEntity iNVStoreEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.INVStore_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, "@StoreID", DbType.Int64, iNVStoreEntity.StoreID);
                db.AddInParameter(cmd, "@ProjectID", DbType.Int64, iNVStoreEntity.ProjectID);
                db.AddInParameter(cmd, "@DepartmentID", DbType.Int64, iNVStoreEntity.DepartmentID);
                db.AddInParameter(cmd, "@StoreInChargeEmployeeID", DbType.Int64, iNVStoreEntity.StoreInChargeEmployeeID);
                db.AddInParameter(cmd, "@Name", DbType.String, iNVStoreEntity.Name);
                db.AddInParameter(cmd, "@StoreTrackNumber", DbType.String, iNVStoreEntity.StoreTrackNumber);
                db.AddInParameter(cmd, "@Location", DbType.String, iNVStoreEntity.Location);
                db.AddInParameter(cmd, "@Description", DbType.String, iNVStoreEntity.Description);
                db.AddInParameter(cmd, "@CreateDate", DbType.DateTime, iNVStoreEntity.CreateDate);
                db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, iNVStoreEntity.IsRemoved);
                db.AddInParameter(cmd, "@IsDefault", DbType.Boolean, iNVStoreEntity.IsDefault);

                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);
        }
예제 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Page.Title = String.Concat("INV Test", " - ", base.Page.Title);

            // ucMDCityEntity.ContentHolderPageUrl = "~/Controls/MD/MDCity.aspx";

            if (!IsPostBack)
            {
                INVStoreEntity ent = new INVStoreEntity();
                ent.ProjectID               = 48;
                ent.DepartmentID            = 11;
                ent.StoreInChargeEmployeeID = 215;
                ent.Name             = "ProjectName+Store";
                ent.StoreTrackNumber = "TestTrackNo";
                ent.Location         = "ProjectAddress";
                ent.Description      = String.Empty;
                ent.CreateDate       = System.DateTime.Now;
                ent.IsRemoved        = false;

                Int64 storeID = INVManager.CreateStore(ent.ProjectID, ent.DepartmentID, ent.StoreInChargeEmployeeID, ent.Name, ent.StoreTrackNumber, ent.Location, ent.Description);

                //INVStoreUnitEntity entStoreUnit = new INVStoreUnitEntity();


                //entStoreUnit.ParentStoreUnitID = null;
                //entStoreUnit.c
                Int64 storeUnit = INVManager.CreateStoreUnit(storeID, 1, "UnitTrack-001", "ProjectLocation", "", null);

                //INVManager.AddStoreUnitItem(storeUnit, 1, 51, 104, 12, 116, 200);
                // INVManager.GetAllCurrentStock(storeUnit, 1, 51, 104, 12, 116, 200);
            }
        }
예제 #7
0
        private void SaveINVStoreEntity()
        {
            if (IsValid)
            {
                try
                {
                    INVStoreEntity iNVStoreEntity = BuildINVStoreEntity();

                    Int64 result = -1;

                    if (iNVStoreEntity.IsNew)
                    {
                        result = FCCINVStore.GetFacadeCreate().Add(iNVStoreEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(INVStoreEntity.FLD_NAME_StoreID, iNVStoreEntity.StoreID.ToString(), SQLMatchType.Equal);
                        result = FCCINVStore.GetFacadeCreate().Update(iNVStoreEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _StoreID        = 0;
                        _INVStoreEntity = new INVStoreEntity();
                        PrepareInitialView();
                        BindINVStoreList();

                        if (iNVStoreEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "I NVStore Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "I NVStore Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (iNVStoreEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add I NVStore Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update I NVStore Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
예제 #8
0
        private INVStoreEntity BuildINVStoreEntity()
        {
            INVStoreEntity iNVStoreEntity = CurrentINVStoreEntity;

            if (ddlProjectID.Items.Count > 0)
            {
                if (ddlProjectID.SelectedValue == "0")
                {
                }
                else
                {
                    iNVStoreEntity.ProjectID = Int64.Parse(ddlProjectID.SelectedValue);
                }
            }

            if (ddlDepartmentID.Items.Count > 0)
            {
                if (ddlDepartmentID.SelectedValue == "0")
                {
                }
                else
                {
                    iNVStoreEntity.DepartmentID = Int64.Parse(ddlDepartmentID.SelectedValue);
                }
            }

            if (ddlStoreInChargeEmployeeID.Items.Count > 0)
            {
                if (ddlStoreInChargeEmployeeID.SelectedValue == "0")
                {
                }
                else
                {
                    iNVStoreEntity.StoreInChargeEmployeeID = Int64.Parse(ddlStoreInChargeEmployeeID.SelectedValue);
                }
            }

            iNVStoreEntity.Name             = txtName.Text.Trim();
            iNVStoreEntity.StoreTrackNumber = txtStoreTrackNumber.Text.Trim();
            iNVStoreEntity.Location         = txtLocation.Text.Trim();
            iNVStoreEntity.Description      = txtDescription.Text.Trim();
            if (txtCreateDate.Text.Trim().IsNotNullOrEmpty())
            {
                iNVStoreEntity.CreateDate = MiscUtil.ParseToDateTime(txtCreateDate.Text);
            }

            iNVStoreEntity.IsRemoved = chkIsRemoved.Checked;

            iNVStoreEntity.IsDefault = chkIsDefault.Checked;


            return(iNVStoreEntity);
        }
예제 #9
0
        protected void lvINVStore_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 StoreID;

            Int64.TryParse(e.CommandArgument.ToString(), out StoreID);

            if (StoreID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                    _StoreID = StoreID;

                    PrepareEditView();

                    cpeEditor.Collapsed   = false;
                    cpeEditor.ClientState = "false";
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(INVStoreEntity.FLD_NAME_StoreID, StoreID.ToString(), SQLMatchType.Equal);

                        INVStoreEntity iNVStoreEntity = new INVStoreEntity();


                        result = FCCINVStore.GetFacadeCreate().Delete(iNVStoreEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _StoreID        = 0;
                            _INVStoreEntity = new INVStoreEntity();
                            PrepareInitialView();
                            BindINVStoreList();

                            MiscUtil.ShowMessage(lblMessage, "I NVStore has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete I NVStore.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
예제 #10
0
        public static INVStoreEntity GetStoreByID(Int64 storeID)
        {
            INVStoreEntity ent = new INVStoreEntity();

            try
            {
                ent = FCCINVStore.GetFacadeCreate().GetByID(storeID);
            }
            catch (Exception ex)
            {
            }

            return(ent);
        }
예제 #11
0
        public static Int64 CreateStore(INVStoreEntity ent)
        {
            Int64 storeID = 0;

            try
            {
                storeID = FCCINVStore.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No);
            }
            catch (Exception ex)
            {
            }

            return(storeID);
        }
예제 #12
0
        private Int64 DeleteTran(INVStoreEntity iNVStoreEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.INVStore_SET";

            Database db = DatabaseFactory.CreateDatabase();


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


                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);
        }
예제 #13
0
        private Int64 Update(INVStoreEntity iNVStoreEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.INVStore_SET";

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

                Database.AddInParameter(cmd, "@StoreID", DbType.Int64, iNVStoreEntity.StoreID);
                Database.AddInParameter(cmd, "@ProjectID", DbType.Int64, iNVStoreEntity.ProjectID);
                Database.AddInParameter(cmd, "@DepartmentID", DbType.Int64, iNVStoreEntity.DepartmentID);
                Database.AddInParameter(cmd, "@StoreInChargeEmployeeID", DbType.Int64, iNVStoreEntity.StoreInChargeEmployeeID);
                Database.AddInParameter(cmd, "@Name", DbType.String, iNVStoreEntity.Name);
                Database.AddInParameter(cmd, "@StoreTrackNumber", DbType.String, iNVStoreEntity.StoreTrackNumber);
                Database.AddInParameter(cmd, "@Location", DbType.String, iNVStoreEntity.Location);
                Database.AddInParameter(cmd, "@Description", DbType.String, iNVStoreEntity.Description);
                Database.AddInParameter(cmd, "@CreateDate", DbType.DateTime, iNVStoreEntity.CreateDate);
                Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, iNVStoreEntity.IsRemoved);
                Database.AddInParameter(cmd, "@IsDefault", DbType.Boolean, iNVStoreEntity.IsDefault);

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

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

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

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

            return(returnCode);
        }
예제 #14
0
        public static Int64 UpdateStore(INVStoreEntity ent)
        {
            Int64 storeID = 0;

            try
            {
                String fe = SqlExpressionBuilder.PrepareFilterExpression(INVStoreEntity.FLD_NAME_StoreID, ent.StoreID.ToString(), SQLMatchType.Equal);

                storeID = FCCINVStore.GetFacadeCreate().Update(ent, fe, DatabaseOperationType.Update, TransactionRequired.No);
            }
            catch (Exception ex)
            {
            }

            return(storeID);
        }
예제 #15
0
        public static HREmployeeEntity GetStoreInCharge(Int64 storeID)
        {
            HREmployeeEntity ent = new HREmployeeEntity();

            try
            {
                INVStoreEntity store = FCCINVStore.GetFacadeCreate().GetByID(storeID);

                ent = FCCHREmployee.GetFacadeCreate().GetByID(store.StoreInChargeEmployeeID);
            }
            catch (Exception ex)
            {
            }

            return(ent);
        }
예제 #16
0
        public static INVStoreEntity GetStoreByTracNumber(String tracNumber)
        {
            INVStoreEntity ent = new INVStoreEntity();

            try
            {
                String fe = SqlExpressionBuilder.PrepareFilterExpression(INVStoreEntity.FLD_NAME_StoreTrackNumber, tracNumber, SQLMatchType.Equal);

                IList <INVStoreEntity> lst = FCCINVStore.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);

                if (lst != null && lst.Count > 0)
                {
                    ent = lst[0];
                }
            }
            catch (Exception ex)
            {
            }

            return(ent);
        }
예제 #17
0
        public static Boolean DisableStore(Int64 storeID)
        {
            Boolean result = false;

            try
            {
                INVStoreEntity ent = INVManager.GetStoreByID(storeID);

                ent.IsRemoved = true;

                String fe = SqlExpressionBuilder.PrepareFilterExpression(INVStoreEntity.FLD_NAME_StoreID, ent.StoreID.ToString(), SQLMatchType.Equal);

                storeID = FCCINVStore.GetFacadeCreate().Update(ent, fe, DatabaseOperationType.Update, TransactionRequired.No);

                result = true;
            }
            catch (Exception ex)
            {
            }

            return(result);
        }
예제 #18
0
        private Int64 Delete(INVStoreEntity iNVStoreEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.INVStore_SET";

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


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

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

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

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

            return(returnCode);
        }
예제 #19
0
        public static INVStoreEntity GetDefaultStore(Int64 projectID)
        {
            INVStoreEntity ent = new INVStoreEntity();

            try
            {
                String fe1 = SqlExpressionBuilder.PrepareFilterExpression(INVStoreEntity.FLD_NAME_ProjectID, projectID.ToString(), SQLMatchType.Equal);
                String fe2 = SqlExpressionBuilder.PrepareFilterExpression(INVStoreEntity.FLD_NAME_IsDefault, "1", SQLMatchType.Equal);
                String fe  = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2);

                IList <INVStoreEntity> lst = FCCINVStore.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);

                if (lst != null && lst.Count > 0)
                {
                    ent = lst[0];
                }
            }
            catch (Exception ex)
            {
            }

            return(ent);
        }
예제 #20
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _StoreID        = 0;
     _INVStoreEntity = new INVStoreEntity();
     PrepareInitialView();
 }
        private void BuildINVStoreIssueNoteItemMapEntity(Int64 sinID, Int64 projectID)
        {
            try
            {
                String fe_itemMap = SqlExpressionBuilder.PrepareFilterExpression(PRMMaterialReceiveItemMapEntity.FLD_NAME_MaterialReceiveID, ddlMaterialReceiveID.SelectedValue.ToString(), SQLMatchType.Equal);
                IList <PRMMaterialReceiveItemMapEntity> lst = FCCPRMMaterialReceiveItemMap.GetFacadeCreate().GetIL(null, null, String.Empty, fe_itemMap, DatabaseOperationType.LoadWithFilterExpression);

                if (lst != null && lst.Count > 0)
                {
                    foreach (PRMMaterialReceiveItemMapEntity ent in lst)
                    {
                        INVStoreIssueNoteItemMapEntity iNVStoreIssueNoteItemMapEntity = new INVStoreIssueNoteItemMapEntity();

                        REQRequisitionItemEntity rEQRequisitionItemEntity = FCCREQRequisitionItem.GetFacadeCreate().GetByID(ent.RequisitionItemID);

                        if (rEQRequisitionItemEntity != null && rEQRequisitionItemEntity.ItemID > 0)
                        {
                            iNVStoreIssueNoteItemMapEntity.StoreIssueNoteID = sinID;
                            iNVStoreIssueNoteItemMapEntity.ItemID           = rEQRequisitionItemEntity.ItemID;
                            iNVStoreIssueNoteItemMapEntity.FolioNo          = String.Empty;
                            iNVStoreIssueNoteItemMapEntity.RequestQty       = ent.ReceiveQty;
                            iNVStoreIssueNoteItemMapEntity.IssueQty         = ent.ReceiveQty;
                        }

                        String fe_transaction1 = SqlExpressionBuilder.PrepareFilterExpression(INVTransactionEntity.FLD_NAME_ItemID, rEQRequisitionItemEntity.ItemID.ToString(), SQLMatchType.Equal);
                        String fe_transaction2 = SqlExpressionBuilder.PrepareFilterExpression(INVTransactionEntity.FLD_NAME_MRRNumber, ddlMaterialReceiveID.Text.ToString(), SQLMatchType.Equal);
                        String fe_transaction  = SqlExpressionBuilder.PrepareFilterExpression(fe_transaction1, SQLJoinType.AND, fe_transaction2);

                        IList <INVTransactionEntity> lstINVTransactionEntity = FCCINVTransaction.GetFacadeCreate().GetIL(null, null, String.Empty, fe_transaction, DatabaseOperationType.LoadWithFilterExpression);

                        if (lstINVTransactionEntity != null && lstINVTransactionEntity.Count > 0)
                        {
                            iNVStoreIssueNoteItemMapEntity.BatchNo = lstINVTransactionEntity[0].BatchNumber;
                        }

                        //    iNVStoreIssueNoteItemMapEntity.BatchNo = txtBatchNo.Text.Trim();
                        String fe_store1 = SqlExpressionBuilder.PrepareFilterExpression(INVStoreEntity.FLD_NAME_ProjectID, projectID.ToString(), SQLMatchType.Equal);
                        String fe_store2 = SqlExpressionBuilder.PrepareFilterExpression(INVStoreEntity.FLD_NAME_IsDefault, "1", SQLMatchType.Equal);
                        String fe_store  = SqlExpressionBuilder.PrepareFilterExpression(fe_store1, SQLJoinType.AND, fe_store2);

                        IList <INVStoreEntity> lstINVStoreEntity = FCCINVStore.GetFacadeCreate().GetIL(null, null, String.Empty, fe_store, DatabaseOperationType.LoadWithFilterExpression);

                        if (lstINVStoreEntity != null && lstINVStoreEntity.Count > 0)
                        {
                            iNVStoreIssueNoteItemMapEntity.IssuedFromStoreID = lstINVStoreEntity[0].StoreID;

                            String fe_storeUnit1 = SqlExpressionBuilder.PrepareFilterExpression(INVStoreUnitEntity.FLD_NAME_StoreID, lstINVStoreEntity[0].StoreID.ToString(), SQLMatchType.Equal);
                            String fe_storeUnit2 = SqlExpressionBuilder.PrepareFilterExpression(INVStoreUnitEntity.FLD_NAME_IsDefault, "1", SQLMatchType.Equal);
                            String fe_storeUnit  = SqlExpressionBuilder.PrepareFilterExpression(fe_storeUnit1, SQLJoinType.AND, fe_storeUnit2);

                            IList <INVStoreUnitEntity> lstINVStoreUnitEntity = FCCINVStoreUnit.GetFacadeCreate().GetIL(null, null, String.Empty, fe_storeUnit, DatabaseOperationType.LoadWithFilterExpression);

                            if (lstINVStoreUnitEntity != null && lstINVStoreUnitEntity.Count > 0)
                            {
                                iNVStoreIssueNoteItemMapEntity.IssuedFromStoreUnitID = lstINVStoreUnitEntity[0].StoreUnitID;
                            }
                        }


                        iNVStoreIssueNoteItemMapEntity.ReceivedDate         = System.DateTime.Now;
                        iNVStoreIssueNoteItemMapEntity.ReceivedByEmployeeID = 168;

                        iNVStoreIssueNoteItemMapEntity.ReturnQty            = null;
                        iNVStoreIssueNoteItemMapEntity.ReturnDate           = null;
                        iNVStoreIssueNoteItemMapEntity.ReturnToStoreID      = null;
                        iNVStoreIssueNoteItemMapEntity.ReturnToStoreUnitID  = null;
                        iNVStoreIssueNoteItemMapEntity.ReturnedByEmployeeID = null;

                        iNVStoreIssueNoteItemMapEntity.ActualUse = null;
                        iNVStoreIssueNoteItemMapEntity.Amount    = ent.WOItemTotalRate / ent.ReceiveQty;

                        iNVStoreIssueNoteItemMapEntity.PurposeOfWorks = "Adjustment Entry";

                        INVStoreEntity storeEntity = INVManager.GetDefaultStore(projectID);

                        INVStoreUnitEntity storeUnitEntity = INVManager.GetDefaultStoreUnit(storeEntity.StoreID);

                        iNVStoreIssueNoteItemMapEntity.IssuedFromStoreID = storeEntity.StoreID;
                        iNVStoreIssueNoteItemMapEntity.IssuedFromStoreID = storeUnitEntity.StoreUnitID;

                        FCCINVStoreIssueNoteItemMap.GetFacadeCreate().Add(iNVStoreIssueNoteItemMapEntity, DatabaseOperationType.Add, TransactionRequired.No);

                        #region Inventory


                        String  batchNumber    = String.Empty;
                        Decimal transactionQty = 0;
                        Boolean invResult      = false;

                        invResult = INVManager.RemoveItemsFromStoreUnit(rEQRequisitionItemEntity.ItemID, rEQRequisitionItemEntity.BrandID, rEQRequisitionItemEntity.RegionID, rEQRequisitionItemEntity.CountryID, lstINVTransactionEntity[0].BatchNumber, Int64.Parse(transactionQty.ToString()), MiscUtil.GetLocalIP(), MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember), 0, String.Empty, String.Empty, String.Empty, "", projectID, storeEntity.StoreID, storeUnitEntity.StoreUnitID);

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                MiscUtil.ShowMessage(lblMessage, "Some Error Occured " + ex.Message, true);
            }
        }
        private void SavePRMMaterialReceiveEntity()
        {
            if (IsValid)
            {
                try
                {
                    PRMMaterialReceiveEntity pRMMaterialReceiveEntity = BuildPRMMaterialReceiveEntity();

                    #region Requisition

                    String RequisitionNo = String.Empty;

                    if (txtRequisition.Text.IsNotNullOrEmpty())
                    {
                        RequisitionNo = "BL-" + txtRequisition.Text.ToString();
                    }

                    Int64 resultRequisition     = -1;
                    Int64 resultRequisitionItem = -1;

                    String fe = SqlExpressionBuilder.PrepareFilterExpression(REQRequisitionEntity.FLD_NAME_RequisitionNo, RequisitionNo, SQLMatchType.Equal);
                    IList <REQRequisitionEntity> lstRequisition = FCCREQRequisition.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);

                    REQRequisitionItemEntity rEQRequisitionItemEntity = null;

                    if (lstRequisition != null && lstRequisition.Count > 0)
                    {
                        rEQRequisitionItemEntity = BuildREQRequisitionItemEntity(lstRequisition[0].RequisitionID);
                        pRMMaterialReceiveEntity.RequisitionID = lstRequisition[0].RequisitionID;
                    }
                    else
                    {
                        REQRequisitionEntity rEQRequisitionEntity = BuildREQRequisitionEntity();
                        resultRequisition = FCCREQRequisition.GetFacadeCreate().Add(rEQRequisitionEntity, DatabaseOperationType.Add, TransactionRequired.No);
                        pRMMaterialReceiveEntity.RequisitionID = resultRequisition;

                        if (resultRequisition > 0)
                        {
                            rEQRequisitionItemEntity = BuildREQRequisitionItemEntity(resultRequisition);
                        }
                    }

                    if (rEQRequisitionItemEntity != null)
                    {
                        resultRequisitionItem = FCCREQRequisitionItem.GetFacadeCreate().Add(rEQRequisitionItemEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }

                    #endregion

                    #region MRR

                    Int64 resultOne = -1;

                    if (pRMMaterialReceiveEntity.IsNew)
                    {
                        resultOne = FCCPRMMaterialReceive.GetFacadeCreate().Add(pRMMaterialReceiveEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(PRMMaterialReceiveEntity.FLD_NAME_MaterialReceiveID, pRMMaterialReceiveEntity.MaterialReceiveID.ToString(), SQLMatchType.Equal);
                        resultOne = FCCPRMMaterialReceive.GetFacadeCreate().Update(pRMMaterialReceiveEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    #endregion

                    if (resultOne > 0 && resultRequisitionItem > 0)
                    {
                        #region Material Receive Item Map

                        Int64 resultTwo = -1;

                        PRMMaterialReceiveItemMapEntity pRMMaterialReceiveItemMapEntity = BuildPRMMaterialReceiveItemMapEntity(resultOne, resultRequisitionItem);
                        resultTwo = FCCPRMMaterialReceiveItemMap.GetFacadeCreate().Add(pRMMaterialReceiveItemMapEntity, DatabaseOperationType.Add, TransactionRequired.No);

                        #endregion

                        try
                        {
                            #region Inventory

                            Int64 _employeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember);
                            Int64 _projectID  = Int64.Parse(ddlProjectID.SelectedValue);

                            INVStoreEntity storeEntity = INVManager.GetDefaultStore(_projectID);
                            Int64          storeID     = storeEntity.StoreID;

                            INVStoreUnitEntity storeUnitEntity = INVManager.GetDefaultStoreUnit(storeID);
                            Int64 storeUnitID = storeUnitEntity.StoreUnitID;

                            String fe_requisitionItem = SqlExpressionBuilder.PrepareFilterExpression("REQRequisitionItem." + REQRequisitionItemEntity.FLD_NAME_RequisitionItemID, resultRequisitionItem.ToString(), SQLMatchType.Equal);
                            IList <REQRequisitionItem_DetailedEntity> lst = FCCREQRequisitionItem_Detailed.GetFacadeCreate().GetIL(10000, 1, String.Empty, fe_requisitionItem);

                            Int64   _itemID   = 0;
                            Decimal _rate     = 0;
                            Int64   brandID   = MasterDataConstants.ItemDefaults.DEFAULT_BRAD;
                            Int64   regionID  = MasterDataConstants.ItemDefaults.DEFAULT_REGION;
                            Int64   countryID = MasterDataConstants.ItemDefaults.DEFAULT_COUNTRY;

                            if (lst != null && lst.Count > 0)
                            {
                                _itemID   = lst[0].ItemID;
                                brandID   = (Int64)lst[0].BrandID;
                                regionID  = (Int64)lst[0].RegionID;
                                countryID = (Int64)lst[0].CountryID;
                                _rate     = lst[0].Rate;
                            }

                            Boolean invResult = INVManager.AddItemsToStoreUnit(_itemID, brandID, regionID, countryID, "", Int64.Parse(txtReceiveQty.Text.ToString()), MiscUtil.GetLocalIP(), _employeeID, _rate, txtRequisition.Text, ddlWorkOrderID.SelectedItem.Text, resultOne.ToString(), "", Int64.Parse(ddlProjectID.SelectedValue), storeID, storeUnitID);

                            #endregion
                        }
                        catch (Exception ex)
                        {
                        }

                        _MaterialReceiveID = resultOne;
                        PrepareInitialViewSave();
                        btnAddNew.Visible = true;

                        if (pRMMaterialReceiveEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Material Receive Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Material Receive Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (pRMMaterialReceiveEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Material Receive Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Material Receive Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
예제 #23
0
 Int64 IINVStoreFacade.Delete(INVStoreEntity iNVStoreEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateINVStoreDataAccess().Delete(iNVStoreEntity, filterExpression, option, reqTran));
 }
예제 #24
0
 Int64 IINVStoreFacade.Add(INVStoreEntity iNVStoreEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateINVStoreDataAccess().Add(iNVStoreEntity, option, reqTran));
 }