Exemplo n.º 1
0
        public SavingResult SaveNewRecord(tblLoanApplicationNoPrefix SaveModel)
        {
            SavingResult res = new SavingResult();

            //-- Perform Validation
            //res.ExecutionResult = eExecutionResult.ValidationError;
            //res.ValidationError = "Validation error message";
            //return res;

            //--
            using (dbVisionEntities db = new dbVisionEntities())
            {
                //tblLoanApplicationNoPrefix SaveModel;
                if (SaveModel.LoanApplicationNoPrefixName == "")
                {
                    res.ValidationError = "Can not accept blank value. Please enter Prefix Name.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }
                else if (IsDuplicateRecord(SaveModel.LoanApplicationNoPrefixName, SaveModel.LoanApplicationNoPrefixID, db))
                {
                    res.ValidationError = "Can not accept duplicate value. The Prefix Name is already exists.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }

                if (SaveModel.LoanApplicationNoPrefixID == 0) // New Entry
                {
                    SaveModel.rcuid     = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.rcdt      = DateTime.Now;
                    SaveModel.CompanyID = Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID;
                    db.tblLoanApplicationNoPrefixes.Add(SaveModel);
                }
                else
                {
                    SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.redt  = DateTime.Now;
                    db.tblLoanApplicationNoPrefixes.Attach(SaveModel);
                    db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified;
                }

                //--
                try
                {
                    db.SaveChanges();
                    res.PrimeKeyValue   = SaveModel.LoanApplicationNoPrefixID;
                    res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                }
                catch (Exception ex)
                {
                    CommonFunctions.GetFinalError(res, ex);
                }
            }
            return(res);
        }
Exemplo n.º 2
0
        public override void FillSelectedRecordInContent(object RecordToFill)
        {
            tblLoanApplicationNoPrefix EditingRecord = DALObject.FindSaveModelByPrimeKey(((LoanApplicationNoPrefixEditListModel)RecordToFill).LoanApplicationNoPrefixID);

            if (EditingRecord == null)
            {
                return;
            }

            txtLoanApplicationNoPrefixName.Text = EditingRecord.LoanApplicationNoPrefixName;
        }
Exemplo n.º 3
0
        public SavingResult DeleteRecord(long DeleteID)
        {
            SavingResult res = new SavingResult();

            using (dbVisionEntities db = new dbVisionEntities())
            {
                if (DeleteID != 0)
                {
                    tblLoanApplicationNoPrefix RecordToDelete = db.tblLoanApplicationNoPrefixes.FirstOrDefault(r => r.LoanApplicationNoPrefixID == DeleteID);

                    if (RecordToDelete == null)
                    {
                        res.ValidationError = "Selected record not found. May be it has been deleted by another user over network.";
                        res.ExecutionResult = eExecutionResult.ValidationError;
                        return(res);
                    }
                    else
                    {
                        //db.tblLoanApplicationNoPrefixes.Remove(RecordToDelete);
                        byte RecordState_Deleted = (byte)eRecordState.Deleted;
                        RecordToDelete.rstate = RecordState_Deleted;
                        db.tblLoanApplicationNoPrefixes.Attach(RecordToDelete);
                        db.Entry(RecordToDelete).State = System.Data.Entity.EntityState.Modified;
                    }

                    try
                    {
                        db.SaveChanges();
                        res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                    }
                    catch (Exception ex)
                    {
                        CommonFunctions.GetFinalError(res, ex);
                    }
                }
            }
            return(res);
        }