コード例 #1
0
        public SavingResult SaveNewRecord(tblEmployeeEarningDeduction SaveModel)
        {
            SavingResult res = new SavingResult();

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

            //--
            using (dbVisionEntities db = new dbVisionEntities())
            {
                //tblEmployeeEarningDeduction SaveModel;
                if (SaveModel.EmployeeEarningDeductionName == "")
                {
                    res.ValidationError = "Can not accept blank value. Please enter Earning & Deduction Name.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }
                else if (IsDuplicateRecord(SaveModel.EmployeeEarningDeductionName, SaveModel.EmployeeEarningDeductionID, db))
                {
                    res.ValidationError = "Can not accept duplicate value. The Earning & Deduction Name is already exists.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }

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

                //--
                try
                {
                    db.SaveChanges();
                    res.PrimeKeyValue   = SaveModel.EmployeeEarningDeductionID;
                    res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                }
                catch (Exception ex)
                {
                    CommonFunctions.GetFinalError(res, ex);
                }
            }
            return(res);
        }
コード例 #2
0
        public override void FillSelectedRecordInContent(object RecordToFill)
        {
            tblEmployeeEarningDeduction EditingRecord = DALObject.FindSaveModelByPrimeKey(((EarningDeductionEditListModel)RecordToFill).EmployeeEarningDeductionID);

            if (EditingRecord == null)
            {
                return;
            }

            cmbEarningDeductionType.SelectedIndex = (int)EditingRecord.EarningDeductionType;
            txtEarningDeductionNo.EditValue       = EditingRecord.EmployeeEarningDeductionNo;
            txtEarningDeductionName.Text          = EditingRecord.EmployeeEarningDeductionName;
            cmbTaxable.SelectedIndex   = (EditingRecord.Taxable ? 1 : 0);
            cmbRecurring.SelectedIndex = (EditingRecord.Recurring ? 1 : 0);
            cmbValueType.SelectedIndex = (int)EditingRecord.ValueType;
            txtRemarks.Text            = EditingRecord.Remarks;
        }
コード例 #3
0
        public SavingResult DeleteRecord(long DeleteID)
        {
            SavingResult res = new SavingResult();

            using (dbVisionEntities db = new dbVisionEntities())
            {
                if (DeleteID != 0)
                {
                    tblEmployeeEarningDeduction RecordToDelete = db.tblEmployeeEarningDeductions.FirstOrDefault(r => r.EmployeeEarningDeductionID == 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.tblEmployeeEarningDeductions.Remove(RecordToDelete);
                        byte RecordState_Deleted = (byte)eRecordState.Deleted;
                        RecordToDelete.rstate = RecordState_Deleted;
                        db.tblEmployeeEarningDeductions.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);
        }