public int SaveAccountMaster(AccountMasterEntities account)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["AccountantDBConnectionString"].ConnectionString);

            con.Open();
            SqlCommand cmd = new SqlCommand("usp_InsertAccountMaster", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@AccountName", account.AccountName);
            cmd.Parameters.AddWithValue("@GroupId", account.GroupId);

            if (string.IsNullOrEmpty(account.AccountCode.ToString()))
            {
                cmd.Parameters.AddWithValue("@AccountCode", account.AccountCode);
            }
            else
            {
                cmd.Parameters.AddWithValue("@AccountCode", account.AccountCode);
            }


            cmd.Parameters.AddWithValue("@YearId", account.YearId);
            cmd.Parameters.AddWithValue("@isActive", account.isActive);
            cmd.Parameters.AddWithValue("@OpeningBalance", account.OpeningBalance);
            cmd.Parameters.AddWithValue("@ClosingBalance", account.ClosingBalance);
            cmd.Parameters.AddWithValue("@CompanyId", account.CompanyId);


            if (string.IsNullOrEmpty(account.ReferenceAccountId.ToString()) || (account.ReferenceAccountId == 0))
            {
                cmd.Parameters.AddWithValue("@ReferenceAccountId", account.ReferenceAccountId);
            }
            else
            {
                cmd.Parameters.AddWithValue("@ReferenceAccountId", account.ReferenceAccountId);
            }


            cmd.Parameters.Add(new SqlParameter("@AccountId", SqlDbType.Int));
            cmd.Parameters[9].Direction = ParameterDirection.Output;


            cmd.ExecuteNonQuery();

            int accountId = (int)cmd.Parameters[9].Value;


            con.Close();

            return(accountId);
        }
示例#2
0
        public int SaveAccountMaster(AccountMasterEntities accounts)
        {
            AccountMasterDAL accountDal = new AccountMasterDAL();

            return(accountDal.SaveAccountMaster(accounts));
        }