コード例 #1
0
    public void testValid()
    {
        var goodName = new UserName("bob");
        var goodCode = new AccountCode("A1234");

        Validation.validateDetails(goodName, goodCode); // what bug makes this throw an exception ???
    }
コード例 #2
0
        /// <summary>
        /// convert accountCode to view model
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public AccountCodeViewModel ConvertToView(AccountCode code)
        {
            AccountCodeViewModel model = new AccountCodeViewModel();

            var _customerDynamicsRepository = new CustomerDynamicsRepository();
            var _bucketRepository           = new BucketRepository();

            var dynamicsCustomer = _customerDynamicsRepository.GetCustomer(code.CustomerId);
            var bucket           = _bucketRepository.GetBucket(code.AccountCodeId);

            model.AccountCodeId = code.AccountCodeId;
            model.Description   = (!string.IsNullOrEmpty(code.Description)) ? code.Description : "N/A";
            model.CustomerId    = code.CustomerId;
            model.CustomerName  = (dynamicsCustomer != null && !string.IsNullOrEmpty(dynamicsCustomer.SHRTNAME)) ? dynamicsCustomer.SHRTNAME : "N/A";
            model.BucketName    = (bucket != null && !string.IsNullOrEmpty(bucket.Name)) ? bucket.Name : "N/A";

            if (_customerDynamicsRepository != null)
            {
                _customerDynamicsRepository.Dispose();
                _customerDynamicsRepository = null;
            }
            if (_bucketRepository != null)
            {
                _bucketRepository.Dispose();
                _bucketRepository = null;
            }

            return(model);
        }
コード例 #3
0
        public async Task <AccountCode> GetOrCreateAccountCode(string accountCodeName,
                                                               string accountCodeDescription,
                                                               IMEXDbContext dbContext,
                                                               CancellationToken cancellationToken = default)
        {
            if (accountCodeName.IsNullOrWhiteSpace())
            {
                return(null);
            }

            var accountCode = await dbContext.AccountCodes.FirstOrDefaultAsync(x => x.AccountCodeName.Trim().ToLower() == accountCodeName.Trim().ToLower(), cancellationToken);

            if (accountCode is null)
            {
                accountCode = new AccountCode()
                {
                    AccountCodeName        = accountCodeName,
                    AccountCodeDescription = accountCodeDescription,
                    IsActive = true
                };

                dbContext.AccountCodes.Add(accountCode);
            }

            return(accountCode);
        }
コード例 #4
0
ファイル: AccoutHandle.cs プロジェクト: ztw312/Unity-Script
    /// <summary>
    /// 登录请求处理
    /// </summary>
    /// <param name="code"></param>
    private void LoginResponse(AccountCode code)
    {
        if (code == AccountCode.Success)
        {
            Dispatch(AreaCode.SCENE, UIEvent.Scene, new LoadSceneMsg
            {
                SceneIndex    = 1,
                OnSceneLoaded = () =>
                {
                    Dispatch(AreaCode.NET, 0, new SocketMsg
                    {
                        OpCode  = MsgType.User,
                        SubCode = UserCode.GetInfoRequest
                    });
                }
            });
            return;
        }
        switch (code)
        {
        case AccountCode.AccountDoesNotExist:
            promptMsg.Text = "账号不存在";
            break;

        case AccountCode.AccountOnline:
            promptMsg.Text = "账号在线";
            break;

        case AccountCode.AccountPasswordDoesNotMatch:
            promptMsg.Text = "账号密码不匹配";
            break;
        }
        Dispatch(AreaCode.UI, UIEvent.Prompt_Msg, promptMsg);
    }
コード例 #5
0
        /// <summary>
        /// save new account code
        /// </summary>
        /// <param name="newAccountCode"></param>
        /// <returns></returns>
        public OperationResult SaveAccountCode(AccountCode newAccountCode)
        {
            var operationResult = new OperationResult();

            try
            {
                var existingAccountCode = _db.AccountCode.FirstOrDefault(x => x.AccountCodeId == newAccountCode.AccountCodeId);

                if (existingAccountCode == null)
                {
                    _db.AccountCode.Add(newAccountCode);

                    _db.SaveChanges();

                    operationResult.Success = true;
                    operationResult.Message = "Success";
                }
                else
                {
                    operationResult.Success = false;
                    operationResult.Message = "Duplicate Entry";
                }
            }
            catch (Exception ex)
            {
                operationResult.Success = false;
                operationResult.Message = "Error";
                logger.ErrorFormat("Error saving new account code: { 0} ", ex.ToString());
            }

            return(operationResult);
        }
コード例 #6
0
    static string validateAccountCode(AccountCode code)
    {
        var re = new Regex("^[AB][0-9]+$");

        if (!re.IsMatch(code._stringValue))
        {
            return("account code not valid: [${code}]");
        }
        return("true");
    }
コード例 #7
0
        /// <summary>
        /// convert AccountCode view model to domain
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public AccountCode ConvertToDomain(AccountCodeViewModel model)
        {
            AccountCode code = new AccountCode();

            code.AccountCodeId = model.AccountCodeId;
            code.Description   = model.Description;
            code.CustomerId    = model.CustomerId;

            return(code);
        }
コード例 #8
0
        public void OnReceiveMessage(ClientPeer clientPeer, int subOperationCode, object dataValue)
        {
            AccountCode accountCode = (AccountCode)Enum.Parse(typeof(AccountCode), subOperationCode.ToString());

            switch (accountCode)
            {
            case AccountCode.Register_Request:
                break;

            case AccountCode.Login_Request:
                break;
            }
        }
コード例 #9
0
    public static void validateDetails(UserName userName, AccountCode accountCode)
    {
        var msg = validateAccountCode(accountCode);

        if (msg != "true")
        {
            throw new System.Exception(msg);
        }
        msg = validateUserName(accountCode);
        if (msg != "true")
        {
            throw new System.Exception(msg);
        }
    }
コード例 #10
0
 /// <summary>
 /// Converts to string.
 /// </summary>
 /// <returns>
 /// A <see cref = "T:System.String"/> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     try
     {
         return Verify.Input( AccountCode?.GetValue() )
             ? AccountCode?.GetValue()
             : string.Empty;
     }
     catch( Exception ex )
     {
         Fail( ex );
         return string.Empty;
     }
 }
コード例 #11
0
        /// <summary>
        /// get account code by id
        /// </summary>
        /// <param name="accountCodeId"></param>
        /// <returns></returns>
        public AccountCode GetAccountCode(Guid accountCodeId)
        {
            var accountCode = new AccountCode();

            try
            {
                accountCode = _db.AccountCode.FirstOrDefault(x => x.AccountCodeId == accountCodeId);
            }
            catch (Exception e)
            {
                logger.ErrorFormat("Error getting account code: {0} ", e.ToString());
            }

            return(accountCode);
        }
コード例 #12
0
 private void CommandEdit()
 {
     try
     {
         AccountCode objAccountCode = (AccountCode)Session["SelectedAccountCode"];
         tbCode.Text = objAccountCode.AccountCode1;
         tbDesc.Text = objAccountCode.AccountDesc;
         //tbKeterangan.Text = objAccountCode.Keterangan;
         //tbPengiraan.Text = objAccountCode.Pengiraan;
         ddlStatus.SelectedIndex = -1;
         ddlStatus.Items.FindByValue(new Helper().GetItemStatusEnumName(Convert.ToChar(objAccountCode.Status))).Selected = true;
     }
     catch (Exception ex)
     {
         ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
     }
 }
コード例 #13
0
        public async Task Save(AccountCode token)
        {
            var existing = await DbContext.AccountCodes.FindAsync(token.Hash);

            if (existing != null)
            {
                existing.Code        = token.Code;
                existing.WhenCreated = token.WhenCreated;
                DbContext.AccountCodes.Update(existing);
            }
            else
            {
                DbContext.AccountCodes.Add(token);
            }

            await DbContext.SaveChangesAsync();
        }
コード例 #14
0
        /// <summary>
        /// convert bucket view model to domain
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Bucket ConvertToDomain(BucketViewModel model)
        {
            Bucket bucket = new Bucket();

            bucket.BucketId         = model.BucketId;
            bucket.FoundryInvoiceId = model.FoundryInvoiceId;
            bucket.Name             = model.BucketName;
            bucket.Value            = model.BucketValue;

            AccountCode accountCode = new AccountCode();

            accountCode.CustomerId  = null;
            accountCode.Description = "50100";

            bucket.AccountCode = accountCode;

            return(bucket);
        }
コード例 #15
0
ファイル: BillsTest.cs プロジェクト: webdev2/NajranService
        public void AccountCode()
        {
            int count = uow.AccountCodes.GetAll().AsQueryable<AccountCode>().Count<AccountCode>();

            #region Add

            AccountCode newEntity = new AccountCode()
            {
                AccountName = "AccountName",
                BranchAcountCode = "BranchAcountCode",
                ParentAcountCode = "ParentAcountCode"
            };
            uow.AccountCodes.Add<AccountCode, int>(newEntity);
            uow.AccountCodes.Commit();
            var result = uow.AccountCodes.GetAll().AsQueryable<AccountCode>();
            Assert.AreEqual(count + 1, result.Count<AccountCode>(), "Adding Error");

            #endregion

            #region Update

            AccountCode entity = uow.AccountCodes.GetById(newEntity.ID);
            entity.AccountName = "AccountName2";
            entity.BranchAcountCode = "BranchAcountCode2";
            entity.ParentAcountCode = "ParentAcountCode2";
            uow.AccountCodes.Update(entity);
            uow.AccountCodes.Commit();
            AccountCode entity2 = uow.AccountCodes.GetById(newEntity.ID);
            Assert.AreEqual("AccountName2", entity2.AccountName, "Updating Error");
            Assert.AreEqual("BranchAcountCode2", entity2.BranchAcountCode, "Updating Error");
            Assert.AreEqual("ParentAcountCode2", entity2.ParentAcountCode, "Updating Error");

            #endregion

            #region Delete

            AccountCode entityDeleted = uow.AccountCodes.GetById(newEntity.ID);
            uow.AccountCodes.Delete(entity2);
            uow.AccountCodes.Commit();
            Assert.AreEqual(count, uow.AccountCodes.GetAll().AsQueryable<AccountCode>().Count<AccountCode>(), "Deleting Error");

            #endregion
        }
コード例 #16
0
        private void CommandPaste(string ParentAccountCodeID)
        {
            try
            {
                AccountCode cutAccountCode = (AccountCode)Session["SelectedAccountCode"];

                List <AccountCode> data   = (List <AccountCode>)Session["AccountCodesData"];
                AccountCode        parent = new AccountCode()
                {
                    ParentAccountCode = ParentAccountCodeID
                };
                do
                {
                    parent = data.Where(x => x.AccountCode1 == parent.ParentAccountCode).FirstOrDefault();
                    if (parent == null || parent.AccountCode1 == cutAccountCode.AccountCode1)
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "You can not paste a parent under its child");
                        return;
                    }
                } while (parent.ParentAccountCode != string.Empty);

                cutAccountCode.ParentAccountCode = ParentAccountCodeID;
                new AccountCodeDAL().UpdateAccountCode(cutAccountCode);
                SelectedNodes = (List <string>)Session["SelectedNodes"];
                if (!SelectedNodes.Contains(ParentAccountCodeID))
                {
                    if (((List <AccountCodeTreeHelper>)Session["AccountCodesTree"]).Where(x => x.AccountCode == ParentAccountCodeID).FirstOrDefault().ChildCount > 0)
                    {
                        SelectedNodes.Add(ParentAccountCodeID);
                    }
                }
                Session["SelectedNodes"] = SelectedNodes;
                //GetData();
                //CreateTreeData();
            }
            catch (Exception ex)
            {
                ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
            }
        }
コード例 #17
0
        public async Task <IActionResult> SendDeleteAccount(string idcard)
        {
            var customers = _context.Customers.Include(i => i.User).Where(w => w.IDCard == idcard);

            if (_conf.SendEmail == true)
            {
                foreach (var customer in customers)
                {
                    GetCustomerClass(customer);
                }
                this._context.SaveChanges();

                var codes = new List <string>();
                foreach (var customer in customers)
                {
                    var accode = new AccountCode();
                    accode.Code       = this.CreateAccountCode();
                    accode.Create_On  = DateUtil.Now();
                    accode.Create_By  = customer.User.UserName;
                    accode.CustomerID = customer.ID;
                    accode.Status     = StatusType.Active;
                    codes.Add(accode.Code);
                    this._context.AccountCodes.Add(accode);

                    var point       = this._context.CustomerPoints.Where(w => w.CustomerID == customer.ID).Sum(s => s.Point);
                    var redeempoint = this._context.Redeems.Where(w => w.CustomerID == customer.ID).Sum(s => s.Point);

                    var totalPoint = point - redeempoint;
                    customer.Point         = NumUtil.ParseInteger(totalPoint);
                    customer.CustomerClass = _context.CustomerClasses.Where(w => w.ID == customer.CustomerClassID).FirstOrDefault();
                }
                this._context.SaveChanges();
                await MailDeleteAccount(customers, codes);
            }
            var model = new List <string>();

            model = customers.Select(s => s.Email).ToList();
            return(View(model));
        }
コード例 #18
0
        /// <summary>
        /// update account code
        /// </summary>
        /// <param name="accountCode"></param>
        /// <returns></returns>
        public OperationResult UpdateAccountCode(AccountCode accountCode)
        {
            var operationResult = new OperationResult();

            var existingAccountCode = GetAccountCode(accountCode.AccountCodeId);

            if (existingAccountCode != null)
            {
                logger.Debug("Account Code is being updated....");

                try
                {
                    _db.AccountCode.Attach(existingAccountCode);

                    _db.Entry(existingAccountCode).CurrentValues.SetValues(accountCode);

                    _db.SaveChanges();

                    operationResult.Success = true;
                    operationResult.Message = "Success";
                }
                catch (Exception ex)
                {
                    operationResult.Success = false;
                    operationResult.Message = "Error";
                    logger.ErrorFormat("Error updating account code: { 0} ", ex.ToString());
                }
            }
            else
            {
                operationResult.Success = false;
                operationResult.Message = "Unable to find selected account code.";
            }

            return(operationResult);
        }
コード例 #19
0
 private void MakeRoot()
 {
     try
     {
         AccountCode cutAccountCode = (AccountCode)Session["SelectedAccountCode"];
         cutAccountCode.ParentAccountCode = string.Empty;
         new AccountCodeDAL().UpdateAccountCode(cutAccountCode);
         SelectedNodes = (List <string>)Session["SelectedNodes"];
         if (!SelectedNodes.Contains(cutAccountCode.AccountCode1))
         {
             if (((List <AccountCodeTreeHelper>)Session["AccountCodesTree"]).Where(x => x.AccountCode == cutAccountCode.AccountCode1).FirstOrDefault().ChildCount > 0)
             {
                 SelectedNodes.Add(cutAccountCode.AccountCode1);
             }
         }
         Session["SelectedNodes"] = SelectedNodes;
         GetData();
         CreateTreeData();
     }
     catch (Exception ex)
     {
         ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
     }
 }
コード例 #20
0
ファイル: AccoutHandle.cs プロジェクト: ztw312/Unity-Script
    /// <summary>
    /// 注册请求处理
    /// </summary>
    /// <param name="code"></param>
    private void RegistResponse(AccountCode code)
    {
        if (code == AccountCode.Success)
        {
            promptMsg.Text = "注册成功";
            Dispatch(AreaCode.UI, UIEvent.Prompt_Msg, promptMsg);
            return;
        }
        switch (code)
        {
        case AccountCode.AccountAlreadyExists:
            promptMsg.Text = "账号已存在";
            break;

        case AccountCode.AccountEntryIsIllegal:
            promptMsg.Text = "账号输入不合法";
            break;

        case AccountCode.ThePasswordIsIllegal:
            promptMsg.Text = "密码不合法,应在4~16个字符之间";
            break;
        }
        Dispatch(AreaCode.UI, UIEvent.Prompt_Msg, promptMsg);
    }
コード例 #21
0
 public override int GetHashCode()
 {
     return(AccountCode.GetHashCode());
 }
コード例 #22
0
 public override int GetHashCode()
 {
     return(AccountCode?.GetHashCode() ?? 0);
 }
コード例 #23
0
 public static CssCommandResult ChangeAccountCode(CssAccountFile file, AccountList list, AccountCode newCode, Note changeNote, CssCredentials cssCredentials)
 {
     return(ChangeIt2(file, list, "", "", "", newCode.Code, changeNote, cssCredentials));
 }
コード例 #24
0
 public async Task Delete(AccountCode token)
 {
     DbContext.AccountCodes.Remove(token);
     await DbContext.SaveChangesAsync();
 }
コード例 #25
0
        protected override bool ValidData()
        {
            if (string.IsNullOrEmpty(AccountCode))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResAccountCode"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtAccountCode.Focus();
                return(false);
            }
            var listAccount = _accountsPresenter.GetAccountsActive();

            foreach (var accountModel in listAccount)
            {
                // option Edit
                if (AccountId > 0)
                {
                    if (accountModel.AccountId != AccountId)
                    {
                        if (accountModel.AccountCode == AccountCode)
                        {
                            XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResCheckAccountsCode"),
                                                ResourceHelper.GetResourceValueByName("ResDetailContent"),
                                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtAccountCode.Focus();
                            return(false);
                        }
                    }
                }
                // option Add New
                else
                {
                    if (accountModel.AccountCode == AccountCode)
                    {
                        XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResCheckAccountsCode"),
                                            ResourceHelper.GetResourceValueByName("ResDetailContent"),
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtAccountCode.Focus();
                        return(false);
                    }
                }
            }
            // Kiểm tra khi có tài khoản tiết con thì mã của Cha chứa mã con
            if (!AccountCode.Contains(grdLockUpParentID.Text))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResContainCodesParentError"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtAccountCode.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(AccountName))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResAccountName"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtAccountName.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(grdLockUpCategoryID.Text))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResAccountCategory"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                grdLockUpCategoryID.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(cboBalance.Text))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResBalanceSide"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboBalance.Focus();
                return(false);
            }
            if (AccountCode == grdLockUpParentID.Text)
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResCodeSameAsParentError"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                grdLockUpParentID.Focus();
                return(false);
            }

            return(true);
        }
コード例 #26
0
 protected void gvAccountCodes_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         List <AccountCodeTreeHelper> TreeData = (List <AccountCodeTreeHelper>)Session["AccountCodesTree"];
         GridViewRow selectedRow = gvAccountCodes.Rows[Convert.ToInt32(e.CommandArgument)];
         string      AccountCode = gvAccountCodes.DataKeys[selectedRow.RowIndex]["AccountCode"].ToString();
         if (e.CommandName == "Expand")
         {
             SelectedNodes = (List <string>)Session["SelectedNodes"];
             if (!SelectedNodes.Contains(AccountCode))
             {
                 if (TreeData.Where(x => x.AccountCode == AccountCode).FirstOrDefault().ChildCount > 0)
                 {
                     SelectedNodes.Add(AccountCode);
                 }
             }
             else
             {
                 SelectedNodes.Remove(AccountCode);
             }
             CreateTreeData();
         }
         else if (e.CommandName == "AddItem")
         {
             //ChangeSeletedNodeStyle(selectedRow);
             Session["PageMode"] = Helper.PageMode.New;
             tbCode.Enabled      = true;
             EditForm.Visible    = true;
         }
         else if (e.CommandName == "AddChild")
         {
             ClearPageData();
             ChangeSeletedNodeStyle(selectedRow);
             AssignSelectedNode(AccountCode);
             Session["PageMode"] = Helper.PageMode.New;
             tbCode.Enabled      = true;
             EditForm.Visible    = true;
         }
         else if (e.CommandName == "MakeRoot")
         {
             ChangeSeletedNodeStyle(selectedRow);
             AssignSelectedNode(AccountCode);
             MakeRoot();
             ClearPageData();
             Session["SelectedAccountCode"] = null;
         }
         else if (e.CommandName == "CmdEdit")
         {
             ChangeSeletedNodeStyle(selectedRow);
             AssignSelectedNode(AccountCode);
             CommandEdit();
             Session["PageMode"] = Helper.PageMode.Edit;
             EditForm.Visible    = true;
             tbCode.Enabled      = false;
         }
         else if (e.CommandName == "CmdDelete")
         {
             AssignSelectedNode(AccountCode);
             AccountCode objAccountCode = (AccountCode)Session["SelectedAccountCode"];
             objAccountCode.Status            = "D";
             objAccountCode.ModifiedBy        = LoggedInUser.UserID;
             objAccountCode.ModifiedTimeStamp = DateTime.Now;
             if (new AccountCodeDAL().UpdateAccountCode(objAccountCode))
             {
                 ((SiteMaster)this.Master).ShowMessage("Success", "Account Code updated successfully");
             }
             else
             {
                 ((SiteMaster)this.Master).ShowMessage("Failure", "An error occurred while updating Account Code");
             }
             ClearPageData();
             Session["SelectedAccountCode"] = null;
             GetData();
             CreateTreeData();
             //Session["PageMode"] = Helper.PageMode.Edit;
         }
         else if (e.CommandName == "CmdCut")
         {
             ChangeSeletedNodeStyle(selectedRow);
             AssignSelectedNode(AccountCode);
         }
         else if (e.CommandName == "CmdPaste")
         {
             CommandPaste(AccountCode);
             GetData();
             CreateTreeData();
         }
     }
     catch (Exception ex)
     {
         ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
     }
 }
コード例 #27
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                AccountCode objAccountCode = new AccountCode();
                objAccountCode.AccountCode1 = tbCode.Text.Trim();
                objAccountCode.AccountDesc  = tbDesc.Text.Trim();
                //objAccountCode.Keterangan = tbKeterangan.Text.Trim();
                //objAccountCode.Pengiraan = tbPengiraan.Text.Trim();
                objAccountCode.Status = new Helper().GetItemStatusEnumValueByName(ddlStatus.SelectedValue);
                if ((AccountCode)Session["SelectedAccountCode"] == null)
                {
                    objAccountCode.ParentAccountCode = string.Empty;
                }
                else
                {
                    objAccountCode.ParentAccountCode = ((AccountCode)Session["SelectedAccountCode"]).AccountCode1;
                }

                if (((Helper.PageMode)Session["PageMode"]) == Helper.PageMode.New)
                {
                    if (new AccountCodeDAL().GetAccountCodes().Where(x => x.AccountCode1.ToUpper().Trim() == tbCode.Text.ToUpper().Trim()).Count() > 0)
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "AccountCode already exists");
                        return;
                    }
                    objAccountCode.CreatedBy         = LoggedInUser.UserID;
                    objAccountCode.CreatedTimeStamp  = DateTime.Now;
                    objAccountCode.ModifiedBy        = LoggedInUser.UserID;
                    objAccountCode.ModifiedTimeStamp = DateTime.Now;

                    if (new AccountCodeDAL().InsertAccountCode(objAccountCode))
                    {
                        ((SiteMaster)this.Master).ShowMessage("Success", "Account Code saved successfully");
                    }
                    else
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "An error occurred while saving Account Code");
                    }
                }
                else
                {
                    objAccountCode.ModifiedBy        = LoggedInUser.UserID;
                    objAccountCode.ModifiedTimeStamp = DateTime.Now;

                    objAccountCode.AccountCode1      = ((AccountCode)Session["SelectedAccountCode"]).AccountCode1;
                    objAccountCode.ParentAccountCode = ((AccountCode)Session["SelectedAccountCode"]).ParentAccountCode;
                    if (new AccountCodeDAL().UpdateAccountCode(objAccountCode))
                    {
                        ((SiteMaster)this.Master).ShowMessage("Success", "Account Code updated successfully");
                    }
                    else
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "An error occurred while updating Account Code");
                    }
                }

                ClearPageData();
                Session["SelectedAccountCode"] = null;
                GetData();
                CreateTreeData();
            }
            catch (Exception ex)
            {
                ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
            }
        }
コード例 #28
0
ファイル: Lookups.cs プロジェクト: webdev2/NajranService
 static int AccountCode()
 {
     AccountCode e = new AccountCode()
     {
         AccountName = "AccountName",
         BranchAcountCode = "BranchAcountCode",
         ParentAcountCode = "ParentAcountCode"
     };
     billsUow.AccountCodes.Add<AccountCode, int>(e);
     billsUow.AccountCodes.Commit();
     return e.ID;
 }
コード例 #29
0
        public void AccountCodeFileUpload(DataSet ds, ref List <object> ListExcluded)
        {
            object ReturnObj = new object();

            List <string> lstErrors = new List <string>();
            DataTable     dt        = new DataTable();

            dt = new ReportHelper().Validate <AccountCodeImport>(ds, "", ref lstErrors);

            if (lstErrors.Count == 0)
            {
                List <AccountCode> AccountCodesData = (List <AccountCode>)HttpContext.Current.Session["AccountCodesData"];
                List <AccountCode> UploadedData     = new ReportHelper().DataTableToList <AccountCodeImport>(dt).Select(x => new AccountCode()
                {
                    AccountCode1      = Convert.ChangeType(x.AccountCode, typeof(string)).ToString(),
                    AccountDesc       = x.AccountDesc,
                    Status            = ((x.Status == "Active") ? "A" : "D"),
                    ParentAccountCode = ((Convert.ChangeType(x.UpperLevel, typeof(string)).ToString() == "0") ? "" :
                                         Convert.ChangeType(x.UpperLevel, typeof(string)).ToString())
                }).ToList();

                if (UploadedData.Count > 0)
                {
                    foreach (AccountCode item in UploadedData)
                    {
                        AccountCode objAccountCode = new AccountCode();

                        if (AccountCodesData.Where(x => x.AccountCode1 == item.AccountCode1).Count() > 0)
                        {
                            ReturnObj = new
                            {
                                status  = "Error",
                                message = "Account Code **" + item.AccountCode1 + "** already exists. It`ll be excluded."
                            };
                        }
                        else
                        {
                            objAccountCode.AccountCode1      = item.AccountCode1;
                            objAccountCode.AccountDesc       = item.AccountDesc;
                            objAccountCode.Status            = item.Status;
                            objAccountCode.ParentAccountCode = item.ParentAccountCode;
                            objAccountCode.CreatedBy         = new UsersDAL().GetValidUser(HttpContext.Current.User.Identity.Name).UserID;
                            objAccountCode.CreatedTimeStamp  = DateTime.Now;
                            objAccountCode.ModifiedBy        = new UsersDAL().GetValidUser(HttpContext.Current.User.Identity.Name).UserID;
                            objAccountCode.ModifiedTimeStamp = DateTime.Now;

                            if (new AccountCodeDAL().InsertAccountCode(objAccountCode))
                            {
                                ReturnObj = new
                                {
                                    status  = "Success",
                                    message = "Account Code **" + item.AccountCode1 + "** uploaded successfully"
                                };
                            }
                            else
                            {
                                ReturnObj = new
                                {
                                    status  = "Failure",
                                    message = "An error occurred while uploading Account Code"
                                };
                            }
                        }

                        ListExcluded.Add(ReturnObj);
                    }
                }
            }
            else
            {
                ListExcluded.Add(ReturnObj = new
                {
                    status  = "Error",
                    message = lstErrors.Aggregate((a, b) => a + "<br/>" + b)
                });
            }
        }